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*
*_qmlcache.qrc
build/

View File

@ -22,13 +22,20 @@ add_executable(flotten-updater
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
Qt6::Core
Qt6::Gui
Qt6::Widgets
Qt6::WebSockets
ssl
crypto
goecommon
)

View File

@ -7,11 +7,15 @@
#include <QInputDialog>
#include <QSslSocket>
#ifdef HAS_OPENSSL
#include <openssl/provider.h>
#endif
#ifdef HAS_OPENSSL
namespace {
OSSL_PROVIDER *legacy{};
}
#endif
ImportCertificateDialog::ImportCertificateDialog(QWidget *parent) :
QDialog{parent},
@ -70,12 +74,14 @@ void ImportCertificateDialog::loadP12File()
QSslCertificate cert;
QList<QSslCertificate> certChain;
#ifdef HAS_OPENSSL
if (QSslSocket::activeBackend() == "openssl" && !legacy)
{
legacy = OSSL_PROVIDER_load(NULL, "legacy");
if (!legacy)
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))
{