Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/plugins/tls/openssl/qopenssl_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
#include <openssl/crypto.h>
#include <openssl/tls1.h>
#include <openssl/dh.h>
#include <openssl/provider.h>


QT_BEGIN_NAMESPACE

Expand Down
14 changes: 12 additions & 2 deletions src/plugins/tls/openssl/qtlsbackend_openssl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,20 @@ bool QTlsBackendOpenSSL::ensureLibraryLoaded()

// Initialize OpenSSL's random seed.
if (!q_RAND_status()) {
#ifndef OPENSSL_NO_DEPRECATED_3_0
qWarning("Random number generator not seeded, disabling SSL support");
return false;
}

#else
// If tpm2 is the default provider the seed is managed by the tpm
// the RAND_status return false.
// So, we check if the tpm2 provider is loaded because q_RAND_status returned false.
// If it is loaded then ignore the status
if (!OSSL_PROVIDER_available(NULL, "tpm2")) {
return false;
}
#endif
}

return true;
}();

Expand Down
17 changes: 14 additions & 3 deletions src/plugins/tls/openssl/qtlskey_openssl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ Qt::HANDLE TlsKeyOpenSSL::handle() const
return Qt::HANDLE(nullptr);
}
#else
qCWarning(lcTlsBackend,
"This version of OpenSSL disabled direct manipulation with RSA/DSA/DH/EC_KEY structures, consider using QSsl::Opaque instead.");
return Qt::HANDLE(nullptr);
/*qCWarning(lcTlsBackend,
"This version of OpenSSL disabled direct manipulation with RSA/DSA/DH/EC_KEY structures, consider using QSsl::Opaque instead.");*/
return Qt::HANDLE(genericKey);
#endif
}

Expand Down Expand Up @@ -321,13 +321,24 @@ QByteArray TlsKeyOpenSSL::toPem(const QByteArray &passPhrase) const
}
#ifndef OPENSSL_NO_EC
} else if (algorithm() == QSsl::Ec) {
#ifdef OPENSSL_NO_DEPRECATED_3_0
EVP_PKEY *result = genericKey;
if (type() == QSsl::PublicKey) {
if (!q_PEM_write_bio_PUBKEY(bio, result))
fail = true;
} else if (!q_PEM_write_bio_PrivateKey(bio, result, cipher, (uchar *)passPhrase.data(),
passPhrase.size(), nullptr, nullptr)) {
fail = true;
}
#else
if (type() == QSsl::PublicKey) {
if (!write_pubkey(EC, ec))
fail = true;
} else {
if (!write_privatekey(EC, ec))
fail = true;
}
#endif
#endif
} else {
fail = true;
Expand Down