mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-23 02:00:20 +07:00
OpenSSL libs added for Linux
This commit is contained in:
@@ -186,6 +186,11 @@ macx {
|
|||||||
LIBS += -framework Cocoa -framework ApplicationServices -framework CoreServices -framework Foundation -framework AppKit -framework Security
|
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 {
|
android {
|
||||||
QT += androidextras
|
QT += androidextras
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ OpenVpnConfigurator::ConnectionData OpenVpnConfigurator::prepareOpenVpnConfig(co
|
|||||||
connData.host = credentials.hostName;
|
connData.host = credentials.hostName;
|
||||||
|
|
||||||
if (connData.privKey.isEmpty() || connData.request.isEmpty()) {
|
if (connData.privKey.isEmpty() || connData.request.isEmpty()) {
|
||||||
if (errorCode) *errorCode = ErrorCode::EasyRsaExecutableMissing;
|
if (errorCode) *errorCode = ErrorCode::OpenSslFailed;
|
||||||
return connData;
|
return connData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,7 +188,9 @@ OpenVpnConfigurator::ConnectionData OpenVpnConfigurator::createCertRequest()
|
|||||||
ret = X509_REQ_set_version(x509_req, nVersion);
|
ret = X509_REQ_set_version(x509_req, nVersion);
|
||||||
if (ret != 1) {
|
if (ret != 1) {
|
||||||
qWarning() << "Could not get X509!";
|
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
|
// 3. set subject of x509 req
|
||||||
@@ -205,14 +207,18 @@ OpenVpnConfigurator::ConnectionData OpenVpnConfigurator::createCertRequest()
|
|||||||
ret = X509_REQ_set_pubkey(x509_req, pKey);
|
ret = X509_REQ_set_pubkey(x509_req, pKey);
|
||||||
if (ret != 1){
|
if (ret != 1){
|
||||||
qWarning() << "Could not set pubkey!";
|
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
|
// 5. set sign key of x509 req
|
||||||
ret = X509_REQ_sign(x509_req, pKey, EVP_sha256()); // return x509_req->signature->length
|
ret = X509_REQ_sign(x509_req, pKey, EVP_sha256()); // return x509_req->signature->length
|
||||||
if (ret <= 0){
|
if (ret <= 0){
|
||||||
qWarning() << "Could not sign request!";
|
qWarning() << "Could not sign request!";
|
||||||
goto free_all;
|
X509_REQ_free(x509_req);
|
||||||
|
EVP_PKEY_free(pKey);
|
||||||
|
return connData;
|
||||||
}
|
}
|
||||||
|
|
||||||
// save private key
|
// save private key
|
||||||
@@ -220,9 +226,11 @@ OpenVpnConfigurator::ConnectionData OpenVpnConfigurator::createCertRequest()
|
|||||||
q_check_ptr(bp_private);
|
q_check_ptr(bp_private);
|
||||||
if (PEM_write_bio_PrivateKey(bp_private, pKey, nullptr, nullptr, 0, nullptr, nullptr) != 1)
|
if (PEM_write_bio_PrivateKey(bp_private, pKey, nullptr, nullptr, 0, nullptr, nullptr) != 1)
|
||||||
{
|
{
|
||||||
|
qFatal("PEM_write_bio_PrivateKey");
|
||||||
EVP_PKEY_free(pKey);
|
EVP_PKEY_free(pKey);
|
||||||
BIO_free_all(bp_private);
|
BIO_free_all(bp_private);
|
||||||
qFatal("PEM_write_bio_PrivateKey");
|
X509_REQ_free(x509_req);
|
||||||
|
return connData;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * buffer = nullptr;
|
const char * buffer = nullptr;
|
||||||
@@ -231,6 +239,10 @@ OpenVpnConfigurator::ConnectionData OpenVpnConfigurator::createCertRequest()
|
|||||||
connData.privKey = QByteArray(buffer, size);
|
connData.privKey = QByteArray(buffer, size);
|
||||||
if (connData.privKey.isEmpty()) {
|
if (connData.privKey.isEmpty()) {
|
||||||
qFatal("Failed to generate a random private key");
|
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);
|
BIO_free_all(bp_private);
|
||||||
|
|
||||||
@@ -246,11 +258,5 @@ OpenVpnConfigurator::ConnectionData OpenVpnConfigurator::createCertRequest()
|
|||||||
|
|
||||||
EVP_PKEY_free(pKey); // this will also free the rsa key
|
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;
|
return connData;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ WireguardConfigurator::ConnectionData WireguardConfigurator::prepareWireguardCon
|
|||||||
connData.host = credentials.hostName;
|
connData.host = credentials.hostName;
|
||||||
|
|
||||||
if (connData.clientPrivKey.isEmpty() || connData.clientPubKey.isEmpty()) {
|
if (connData.clientPrivKey.isEmpty() || connData.clientPubKey.isEmpty()) {
|
||||||
if (errorCode) *errorCode = ErrorCode::EasyRsaExecutableMissing;
|
if (errorCode) *errorCode = ErrorCode::InternalError;
|
||||||
return connData;
|
return connData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -49,7 +49,6 @@ enum ErrorCode
|
|||||||
|
|
||||||
// Distro errors
|
// Distro errors
|
||||||
OpenVpnExecutableMissing,
|
OpenVpnExecutableMissing,
|
||||||
EasyRsaExecutableMissing,
|
|
||||||
ShadowSocksExecutableMissing,
|
ShadowSocksExecutableMissing,
|
||||||
CloakExecutableMissing,
|
CloakExecutableMissing,
|
||||||
AmneziaServiceConnectionFailed,
|
AmneziaServiceConnectionFailed,
|
||||||
@@ -61,6 +60,7 @@ enum ErrorCode
|
|||||||
OpenVpnTapAdapterError,
|
OpenVpnTapAdapterError,
|
||||||
|
|
||||||
// 3rd party utils errors
|
// 3rd party utils errors
|
||||||
|
OpenSslFailed,
|
||||||
OpenVpnExecutableCrashed,
|
OpenVpnExecutableCrashed,
|
||||||
ShadowSocksExecutableCrashed,
|
ShadowSocksExecutableCrashed,
|
||||||
CloakExecutableCrashed
|
CloakExecutableCrashed
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ QString errorString(ErrorCode code){
|
|||||||
|
|
||||||
// Distro errors
|
// Distro errors
|
||||||
case (OpenVpnExecutableMissing): return QObject::tr("OpenVPN executable missing");
|
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 (AmneziaServiceConnectionFailed): return QObject::tr("Amnezia helper service error");
|
||||||
|
case (OpenSslFailed): return QObject::tr("OpenSSL failed");
|
||||||
|
|
||||||
// VPN errors
|
// VPN errors
|
||||||
case (OpenVpnAdaptersInUseError): return QObject::tr("Can't connect: another VPN connection is active");
|
case (OpenVpnAdaptersInUseError): return QObject::tr("Can't connect: another VPN connection is active");
|
||||||
|
|||||||
+3
-2
@@ -3,12 +3,12 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <Utils.h>
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
QFile Debug::m_file;
|
QFile Debug::m_file;
|
||||||
QTextStream Debug::m_textStream;
|
QTextStream Debug::m_textStream;
|
||||||
@@ -34,7 +34,6 @@ bool Debug::init()
|
|||||||
{
|
{
|
||||||
qSetMessagePattern("%{time yyyy-MM-dd hh:mm:ss} %{type} %{message}");
|
qSetMessagePattern("%{time yyyy-MM-dd hh:mm:ss} %{type} %{message}");
|
||||||
|
|
||||||
#ifndef QT_DEBUG
|
|
||||||
QString path = userLogsDir();
|
QString path = userLogsDir();
|
||||||
QDir appDir(path);
|
QDir appDir(path);
|
||||||
if (!appDir.mkpath(path)) {
|
if (!appDir.mkpath(path)) {
|
||||||
@@ -51,6 +50,8 @@ bool Debug::init()
|
|||||||
}
|
}
|
||||||
m_file.setTextModeEnabled(true);
|
m_file.setTextModeEnabled(true);
|
||||||
m_textStream.setDevice(&m_file);
|
m_textStream.setDevice(&m_file);
|
||||||
|
|
||||||
|
#ifndef QT_DEBUG
|
||||||
qInstallMessageHandler(debugMessageHandler);
|
qInstallMessageHandler(debugMessageHandler);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user