openssl fixes for windows

This commit is contained in:
2024-10-11 10:02:39 +02:00
parent f622d76ec8
commit e655a4e89f
3 changed files with 16 additions and 2 deletions

1
.gitignore vendored
View File

@@ -52,3 +52,4 @@ compile_commands.json
*creator.user* *creator.user*
*_qmlcache.qrc *_qmlcache.qrc
build/

View File

@@ -22,13 +22,20 @@ add_executable(flotten-updater
setarbitraryapikeydialog.ui setarbitraryapikeydialog.ui
) )
find_package(OpenSSL)
if (OpenSSL_Found)
target_compile_definitions(flotten-updater HAS_OPENSSL)
target_link_libraries(flotten-updater PUBLIC
OpenSSL::SSL
OpenSSL::Crypto
)
endif()
target_link_libraries(flotten-updater PUBLIC target_link_libraries(flotten-updater PUBLIC
Qt6::Core Qt6::Core
Qt6::Gui Qt6::Gui
Qt6::Widgets Qt6::Widgets
Qt6::WebSockets Qt6::WebSockets
ssl
crypto
goecommon goecommon
) )

View File

@@ -7,11 +7,15 @@
#include <QInputDialog> #include <QInputDialog>
#include <QSslSocket> #include <QSslSocket>
#ifdef HAS_OPENSSL
#include <openssl/provider.h> #include <openssl/provider.h>
#endif
#ifdef HAS_OPENSSL
namespace { namespace {
OSSL_PROVIDER *legacy{}; OSSL_PROVIDER *legacy{};
} }
#endif
ImportCertificateDialog::ImportCertificateDialog(QWidget *parent) : ImportCertificateDialog::ImportCertificateDialog(QWidget *parent) :
QDialog{parent}, QDialog{parent},
@@ -70,12 +74,14 @@ void ImportCertificateDialog::loadP12File()
QSslCertificate cert; QSslCertificate cert;
QList<QSslCertificate> certChain; QList<QSslCertificate> certChain;
#ifdef HAS_OPENSSL
if (QSslSocket::activeBackend() == "openssl" && !legacy) if (QSslSocket::activeBackend() == "openssl" && !legacy)
{ {
legacy = OSSL_PROVIDER_load(NULL, "legacy"); legacy = OSSL_PROVIDER_load(NULL, "legacy");
if (!legacy) if (!legacy)
QMessageBox::warning(this, tr("Failed to load openssl legacy provider!"), tr("Failed to load openssl legacy provider!")); QMessageBox::warning(this, tr("Failed to load openssl legacy provider!"), tr("Failed to load openssl legacy provider!"));
} }
#endif
if (!QSslCertificate::importPkcs12(&file, &key, &cert, &certChain, password)) if (!QSslCertificate::importPkcs12(&file, &key, &cert, &certChain, password))
{ {