OpenSSL libs added for Linux

This commit is contained in:
pokamest 2021-10-17 07:00:00 -07:00
parent 6e9c43c37b
commit ca25e257ef
6 changed files with 28 additions and 16 deletions

View file

@ -186,6 +186,11 @@ macx {
LIBS += -framework Cocoa -framework ApplicationServices -framework CoreServices -framework Foundation -framework AppKit -framework Security
}
linux:!android {
LIBS += /usr/lib/x86_64-linux-gnu/libcrypto.a
LIBS += /usr/lib/x86_64-linux-gnu/libssl.a
}
android {
QT += androidextras

View file

@ -23,7 +23,7 @@ OpenVpnConfigurator::ConnectionData OpenVpnConfigurator::prepareOpenVpnConfig(co
connData.host = credentials.hostName;
if (connData.privKey.isEmpty() || connData.request.isEmpty()) {
if (errorCode) *errorCode = ErrorCode::EasyRsaExecutableMissing;
if (errorCode) *errorCode = ErrorCode::OpenSslFailed;
return connData;
}
@ -188,7 +188,9 @@ OpenVpnConfigurator::ConnectionData OpenVpnConfigurator::createCertRequest()
ret = X509_REQ_set_version(x509_req, nVersion);
if (ret != 1) {
qWarning() << "Could not get X509!";
goto free_all;
X509_REQ_free(x509_req);
EVP_PKEY_free(pKey);
return connData;
}
// 3. set subject of x509 req
@ -205,14 +207,18 @@ OpenVpnConfigurator::ConnectionData OpenVpnConfigurator::createCertRequest()
ret = X509_REQ_set_pubkey(x509_req, pKey);
if (ret != 1){
qWarning() << "Could not set pubkey!";
goto free_all;
X509_REQ_free(x509_req);
EVP_PKEY_free(pKey);
return connData;
}
// 5. set sign key of x509 req
ret = X509_REQ_sign(x509_req, pKey, EVP_sha256()); // return x509_req->signature->length
if (ret <= 0){
qWarning() << "Could not sign request!";
goto free_all;
X509_REQ_free(x509_req);
EVP_PKEY_free(pKey);
return connData;
}
// save private key
@ -220,9 +226,11 @@ OpenVpnConfigurator::ConnectionData OpenVpnConfigurator::createCertRequest()
q_check_ptr(bp_private);
if (PEM_write_bio_PrivateKey(bp_private, pKey, nullptr, nullptr, 0, nullptr, nullptr) != 1)
{
qFatal("PEM_write_bio_PrivateKey");
EVP_PKEY_free(pKey);
BIO_free_all(bp_private);
qFatal("PEM_write_bio_PrivateKey");
X509_REQ_free(x509_req);
return connData;
}
const char * buffer = nullptr;
@ -231,6 +239,10 @@ OpenVpnConfigurator::ConnectionData OpenVpnConfigurator::createCertRequest()
connData.privKey = QByteArray(buffer, size);
if (connData.privKey.isEmpty()) {
qFatal("Failed to generate a random private key");
EVP_PKEY_free(pKey);
BIO_free_all(bp_private);
X509_REQ_free(x509_req);
return connData;
}
BIO_free_all(bp_private);
@ -246,11 +258,5 @@ OpenVpnConfigurator::ConnectionData OpenVpnConfigurator::createCertRequest()
EVP_PKEY_free(pKey); // this will also free the rsa key
return connData;
free_all:
X509_REQ_free(x509_req);
EVP_PKEY_free(pKey);
return connData;
}

View file

@ -89,7 +89,7 @@ WireguardConfigurator::ConnectionData WireguardConfigurator::prepareWireguardCon
connData.host = credentials.hostName;
if (connData.clientPrivKey.isEmpty() || connData.clientPubKey.isEmpty()) {
if (errorCode) *errorCode = ErrorCode::EasyRsaExecutableMissing;
if (errorCode) *errorCode = ErrorCode::InternalError;
return connData;
}

View file

@ -49,7 +49,6 @@ enum ErrorCode
// Distro errors
OpenVpnExecutableMissing,
EasyRsaExecutableMissing,
ShadowSocksExecutableMissing,
CloakExecutableMissing,
AmneziaServiceConnectionFailed,
@ -61,6 +60,7 @@ enum ErrorCode
OpenVpnTapAdapterError,
// 3rd party utils errors
OpenSslFailed,
OpenVpnExecutableCrashed,
ShadowSocksExecutableCrashed,
CloakExecutableCrashed

View file

@ -39,8 +39,8 @@ QString errorString(ErrorCode code){
// Distro errors
case (OpenVpnExecutableMissing): return QObject::tr("OpenVPN executable missing");
case (EasyRsaExecutableMissing): return QObject::tr("EasyRsa executable missing");
case (AmneziaServiceConnectionFailed): return QObject::tr("Amnezia helper service error");
case (OpenSslFailed): return QObject::tr("OpenSSL failed");
// VPN errors
case (OpenVpnAdaptersInUseError): return QObject::tr("Can't connect: another VPN connection is active");

View file

@ -3,12 +3,12 @@
#include <QDir>
#include <QStandardPaths>
#include <QUrl>
#include <Utils.h>
#include <iostream>
#include "debug.h"
#include "defines.h"
#include "utils.h"
QFile Debug::m_file;
QTextStream Debug::m_textStream;
@ -34,7 +34,6 @@ bool Debug::init()
{
qSetMessagePattern("%{time yyyy-MM-dd hh:mm:ss} %{type} %{message}");
#ifndef QT_DEBUG
QString path = userLogsDir();
QDir appDir(path);
if (!appDir.mkpath(path)) {
@ -51,6 +50,8 @@ bool Debug::init()
}
m_file.setTextModeEnabled(true);
m_textStream.setDevice(&m_file);
#ifndef QT_DEBUG
qInstallMessageHandler(debugMessageHandler);
#endif