12#include <QtNetwork/private/qsslpresharedkeyauthenticator_p.h>
13#include <QtNetwork/private/qsslcertificate_p.h>
14#include <QtNetwork/private/qocspresponse_p.h>
15#include <QtNetwork/private/qsslsocket_p.h>
17#include <QtNetwork/qsslpresharedkeyauthenticator.h>
19#include <QtCore/qscopedvaluerollback.h>
20#include <QtCore/qscopeguard.h>
38 switch (typeString[0]) {
40 return AlertLevel::Warning;
42 return AlertLevel::Fatal;
47 return AlertLevel::Unknown;
53 if (!description.
size())
54 description =
"no description provided"_L1;
73 for (
const auto &tlsError : tlsErrors) {
74 switch (tlsError.error()) {
77 certToFetch = tlsError.certificate();
84#ifdef QSSLSOCKET_DEBUG
85 qCDebug(lcTlsBackend) << tlsError.errorString();
93 const auto extensions = certToFetch.
extensions();
94 for (
const auto &
ext : extensions) {
122 ErrorListPtr errors =
nullptr;
147 if (tls->isInSslRead()) {
151 tls->setRenegotiated(
true);
160 qCWarning(lcTlsBackend,
"Neither X509_STORE, nor SSL contains error list, handshake failure");
182 qCWarning(lcTlsBackend,
"Invalid store context (nullptr)");
194 qCWarning(lcTlsBackend,
"No external data (SSL) found in X509 store object");
202 qCWarning(lcTlsBackend,
"No external data (TlsCryptographOpenSSL) found in SSL object");
206 return crypto->emitErrorFromCallback(
ctx);
211#ifndef OPENSSL_NO_PSK
213 unsigned char *psk,
unsigned max_psk_len)
220 unsigned int max_psk_len)
224 return tls->pskServerTlsCallback(identity, psk, max_psk_len);
228static unsigned q_ssl_psk_restore_client(SSL *ssl,
const char *
hint,
char *identity,
unsigned max_identity_len,
229 unsigned char *psk,
unsigned max_psk_len)
256static int q_ssl_psk_use_session_callback(SSL *ssl,
const EVP_MD *md,
const unsigned char **
id,
257 size_t *idlen, SSL_SESSION **sess)
277int q_ssl_sess_set_new_cb(SSL *ssl, SSL_SESSION *session)
280 qCWarning(lcTlsBackend,
"Invalid SSL (nullptr)");
284 qCWarning(lcTlsBackend,
"Invalid SSL_SESSION (nullptr)");
290 return tls->handleNewSessionTicket(ssl);
298int qt_OCSP_status_server_callback(SSL *ssl,
void *ocspRequest)
302 return SSL_TLSEXT_ERR_ALERT_FATAL;
306 return SSL_TLSEXT_ERR_ALERT_FATAL;
310 const QByteArray &response = crypto->ocspResponseDer;
313 unsigned char *derCopy =
static_cast<unsigned char *
>(
q_OPENSSL_malloc(
size_t(response.
size())));
315 return SSL_TLSEXT_ERR_ALERT_FATAL;
317 std::copy(response.
data(), response.
data() + response.
size(), derCopy);
320 q_SSL_set_tlsext_status_ocsp_resp(ssl, derCopy, response.
size());
322 return SSL_TLSEXT_ERR_OK;
333#ifdef QSSLSOCKET_DEBUG
334 qCWarning(lcTlsBackend,
"Invalid 'connection' parameter (nullptr)");
344#ifdef QSSLSOCKET_DEBUG
345 qCWarning(lcTlsBackend,
"No external data (socket backend) found for parameter 'connection'");
350 if (!(from & SSL_CB_ALERT)) {
355 if (from & SSL_CB_WRITE)
356 crypto->alertMessageSent(
value);
358 crypto->alertMessageReceived(
value);
369 case OCSP_RESPONSE_STATUS_MALFORMEDREQUEST:
371 case OCSP_RESPONSE_STATUS_INTERNALERROR:
373 case OCSP_RESPONSE_STATUS_TRYLATER:
375 case OCSP_RESPONSE_STATUS_SIGREQUIRED:
377 case OCSP_RESPONSE_STATUS_UNAUTHORIZED:
379 case OCSP_RESPONSE_STATUS_SUCCESSFUL:
389 case OCSP_REVOKED_STATUS_NOSTATUS:
391 case OCSP_REVOKED_STATUS_UNSPECIFIED:
393 case OCSP_REVOKED_STATUS_KEYCOMPROMISE:
395 case OCSP_REVOKED_STATUS_CACOMPROMISE:
397 case OCSP_REVOKED_STATUS_AFFILIATIONCHANGED:
399 case OCSP_REVOKED_STATUS_SUPERSEDED:
401 case OCSP_REVOKED_STATUS_CESSATIONOFOPERATION:
403 case OCSP_REVOKED_STATUS_CERTIFICATEHOLD:
405 case OCSP_REVOKED_STATUS_REMOVEFROMCRL:
414bool qt_OCSP_certificate_match(OCSP_SINGLERESP *singleResponse, X509 *peerCert, X509 *issuer)
420 Q_ASSERT(singleResponse && peerCert && issuer);
422 const OCSP_CERTID *certId = q_OCSP_SINGLERESP_get0_id(singleResponse);
424 qCWarning(lcTlsBackend,
"A SingleResponse without CertID");
428 ASN1_OBJECT *md =
nullptr;
429 ASN1_INTEGER *reportedSerialNumber =
nullptr;
430 const int result = q_OCSP_id_get0_info(
nullptr, &md,
nullptr, &reportedSerialNumber,
const_cast<OCSP_CERTID *
>(certId));
431 if (
result != 1 || !md || !reportedSerialNumber) {
432 qCWarning(lcTlsBackend,
"Failed to extract a hash and serial number from CertID structure");
440 qCWarning(lcTlsBackend,
"No serial number in peer's ceritificate");
445 if (nid == NID_undef) {
446 qCWarning(lcTlsBackend,
"Unknown hash algorithm in CertID");
452 qCWarning(lcTlsBackend) <<
"No digest for nid" << nid;
456 OCSP_CERTID *recreatedId = q_OCSP_cert_to_id(digest, peerCert, issuer);
458 qCWarning(lcTlsBackend,
"Failed to re-create CertID");
463 if (q_OCSP_id_cmp(
const_cast<OCSP_CERTID *
>(certId), recreatedId)) {
464 qCDebug(lcTlsBackend,
"Certificate ID mismatch");
486 ocspResponses.
clear();
489 systemOrSslErrorDetected =
false;
490 handshakeInterrupted =
false;
492 fetchAuthorityInformation =
false;
498 if (!sslContextPointer)
499 sslContextPointer = std::move(tlsContext);
504 return sslContextPointer;
514 if (!initSslContext()) {
529 if (!initSslContext()) {
551 if (inSetAndEmitError)
556 pendingFatalAlert =
false;
557 errorsReportedFromCallback =
false;
572 if (!lastErrors.
isEmpty() || errorsReportedFromCallback)
577 auto configuration =
q->sslConfiguration();
578 if (!errorsReportedFromCallback) {
579 const auto &peerCertificateChain = configuration.peerCertificateChain();
580 for (
const auto ¤tError : std::as_const(lastErrors)) {
582 peerCertificateChain.value(currentError.depth)));
588 errorList << lastErrors;
597 case SSL_ERROR_WANT_READ:
598 case SSL_ERROR_WANT_WRITE:
603#ifdef QSSLSOCKET_DEBUG
604 qCDebug(lcTlsBackend) <<
"TlsCryptographOpenSSL::startHandshake: error!" << errorString;
607 const ScopedBool bg(inSetAndEmitError,
true);
609 if (pendingFatalAlert) {
611 pendingFatalAlert =
false;
626 configuration =
q->sslConfiguration();
628 const auto &peerCertificateChain = configuration.peerCertificateChain();
646 if (!configuration.peerCertificate().isNull() && configuration.ocspStaplingEnabled() && doVerifyPeer) {
647 if (!checkOcspStatus()) {
650 const ScopedBool bg(inSetAndEmitError,
true);
670 if (!configuration.peerCertificate().isNull()) {
675 QString peerName = (verificationPeerName.isEmpty () ?
q->peerName() : verificationPeerName);
677 if (!isMatchingHostname(configuration.peerCertificate(), peerName)) {
700 for (
const auto &
error : std::as_const(errorList))
714 certToFetch = findCertificateToFetch(sslErrors, !fetchEnabled);
717 if (!certToFetch.
isNull()) {
718 fetchAuthorityInformation = !fetchEnabled;
725 fetchCaRootForCert(certToFetch);
746 handshakeInterrupted =
false;
751 fetchAuthorityInformation =
false;
767 plainSocket->setReadBufferSize(maxSize);
770 QTlsBackend::setPeerSessionShared(
d,
true);
772#ifdef QT_DECRYPT_SSL_TRAFFIC
780 reinterpret_cast<unsigned char*
>(masterKey.
data()),
783 clientRandom.
size());
785 QByteArray debugLineClientRandom(
"CLIENT_RANDOM ");
787 debugLineClientRandom.
append(
" ");
789 debugLineClientRandom.
append(
"\n");
794 qCWarning(lcTlsBackend) <<
"could not open file" << sslKeyFile <<
"for appending";
796 qCWarning(lcTlsBackend) <<
"could not write to file" << sslKeyFile;
799 qCWarning(lcTlsBackend,
"could not decrypt SSL traffic");
803 const auto &configuration =
q->sslConfiguration();
806 if (!sslContextPointer->cacheSession(ssl)) {
807 sslContextPointer.reset();
811 if (!sslContextPointer->sessionASN1().isEmpty())
812 QTlsBackend::setSessionAsn1(
d, sslContextPointer->sessionASN1());
813 QTlsBackend::setSessionLifetimeHint(
d, sslContextPointer->sessionTicketLifeTimeHint());
818#if !defined(OPENSSL_NO_NEXTPROTONEG)
820 QTlsBackend::setAlpnStatus(
d, sslContextPointer->npnContext().status);
827 const unsigned char *proto =
nullptr;
828 unsigned int proto_len = 0;
841 QTlsBackend::setNegotiatedProtocol(
d,
QByteArray(
reinterpret_cast<const char *
>(proto), proto_len));
843 QTlsBackend::setNegotiatedProtocol(
d,{});
857 q->disconnectFromHost();
868 if (inSetAndEmitError)
883 transmitting =
false;
888 qint64 totalBytesWritten = 0;
889 int nextDataBlockSize;
890 while ((nextDataBlockSize =
writeBuffer.nextDataBlockSize()) > 0) {
892 if (writtenBytes <= 0) {
895 if (
error == SSL_ERROR_WANT_WRITE) {
898 }
else if (
error == SSL_ERROR_WANT_READ) {
900 transmitting =
false;
904 const ScopedBool bg(inSetAndEmitError,
true);
906 QSslSocket::tr(
"Unable to write data: %1").
arg(
911#ifdef QSSLSOCKET_DEBUG
912 qCDebug(lcTlsBackend) <<
"TlsCryptographOpenSSL::transmit: encrypted" << writtenBytes <<
"bytes";
915 totalBytesWritten += writtenBytes;
917 if (writtenBytes < nextDataBlockSize) {
924 if (totalBytesWritten > 0) {
926 if (!emittedBytesWritten) {
927 emittedBytesWritten =
true;
928 emit q->bytesWritten(totalBytesWritten);
929 emittedBytesWritten =
false;
931 emit q->channelBytesWritten(0, totalBytesWritten);
938 while (plainSocket->isValid() && (pendingBytes =
q_BIO_pending(writeBio)) > 0
941 data.resize(pendingBytes);
942 int encryptedBytesRead =
q_BIO_read(writeBio,
data.data(), pendingBytes);
945 qint64 actualWritten = plainSocket->write(
data.constData(), encryptedBytesRead);
946#ifdef QSSLSOCKET_DEBUG
947 qCDebug(lcTlsBackend) <<
"TlsCryptographOpenSSL::transmit: wrote" << encryptedBytesRead
948 <<
"encrypted bytes to the socket" << actualWritten <<
"actual.";
950 if (actualWritten < 0) {
952 const ScopedBool bg(inSetAndEmitError,
true);
953 setErrorAndEmit(
d, plainSocket->error(), plainSocket->
errorString());
961 while ((pendingBytes = plainSocket->bytesAvailable()) > 0) {
963 data.resize(pendingBytes);
965 int encryptedBytesRead = plainSocket->peek(
data.data(), pendingBytes);
967#ifdef QSSLSOCKET_DEBUG
968 qCDebug(lcTlsBackend) <<
"TlsCryptographOpenSSL::transmit: read" << encryptedBytesRead <<
"encrypted bytes from the socket";
971 int writtenToBio =
q_BIO_write(readBio,
data.constData(), encryptedBytesRead);
974 if (writtenToBio > 0) {
975 plainSocket->skip(writtenToBio);
978 const ScopedBool bg(inSetAndEmitError,
true);
980 QSslSocket::tr(
"Unable to decrypt data: %1")
990 if (!
q->isEncrypted()) {
991#ifdef QSSLSOCKET_DEBUG
992 qCDebug(lcTlsBackend) <<
"TlsCryptographOpenSSL::transmit: testing encryption";
995#ifdef QSSLSOCKET_DEBUG
996 qCDebug(lcTlsBackend) <<
"TlsCryptographOpenSSL::transmit: encryption established";
1001#ifdef QSSLSOCKET_DEBUG
1002 qCDebug(lcTlsBackend) <<
"TlsCryptographOpenSSL::transmit: connection lost";
1009#ifdef QSSLSOCKET_DEBUG
1010 qCDebug(lcTlsBackend) <<
"TlsCryptographOpenSSL::transmit: encryption not done yet";
1025 const int bytesToRead = 4096;
1027 if (
q->readChannelCount() == 0) {
1036 renegotiated =
false;
1038 const auto peerCertificate =
1041 if (peerCertificate !=
q->peerCertificate()) {
1042 const ScopedBool bg(inSetAndEmitError,
true);
1046 "TLS certificate unexpectedly changed during renegotiation!"));
1051 if (readBytes > 0) {
1052#ifdef QSSLSOCKET_DEBUG
1053 qCDebug(lcTlsBackend) <<
"TlsCryptographOpenSSL::transmit: decrypted" << readBytes <<
"bytes";
1055 buffer.chop(bytesToRead - readBytes);
1058 *readyReadEmittedPointer =
true;
1059 emit q->readyRead();
1060 emit q->channelReadyRead(0);
1061 transmitting =
true;
1064 buffer.chop(bytesToRead);
1068 case SSL_ERROR_WANT_READ:
1069 case SSL_ERROR_WANT_WRITE:
1072 case SSL_ERROR_ZERO_RETURN:
1074#ifdef QSSLSOCKET_DEBUG
1075 qCDebug(lcTlsBackend) <<
"TlsCryptographOpenSSL::transmit: remote disconnect";
1079 const ScopedBool bg(inSetAndEmitError,
true);
1081 QSslSocket::tr(
"The TLS/SSL connection has been closed"));
1084 case SSL_ERROR_SYSCALL:
1088 systemOrSslErrorDetected =
true;
1090 const ScopedBool bg(inSetAndEmitError,
true);
1092 QSslSocket::tr(
"Error while reading: %1")
1103 const ScopedBool bg(inSetAndEmitError,
true);
1105 QSslSocket::tr(
"Error while reading: %1")
1110 }
while (ssl && readBytes > 0);
1111 }
while (ssl && transmitting);
1117 if (!shutdown && !
q_SSL_in_init(ssl) && !systemOrSslErrorDetected) {
1129 plainSocket->disconnectFromHost();
1139 if (plainSocket->bytesAvailable() <= 0) {
1140 destroySslContext();
1172 return QSsl::TlsV1_0;
1174 return QSsl::TlsV1_1;
1187 return ocspResponses;
1198 emit q->sslErrors(sslErrors);
1200 const auto vfyMode =
q->peerVerifyMode();
1207 if (doVerifyPeer && doEmitSslError) {
1215 plainSocket->disconnectFromHost();
1238 if (!currentSession) {
1240 "New session ticket callback, the session is invalid (nullptr)");
1249#ifdef TLS1_3_VERSION
1250 if (!q_SSL_SESSION_is_resumable(currentSession)) {
1251 qCDebug(lcTlsBackend,
"New session ticket, but the session is non-resumable");
1257 if (sessionSize <= 0) {
1258 qCWarning(lcTlsBackend,
"could not store persistent version of SSL session");
1264 auto data =
reinterpret_cast<unsigned char *
>(sessionTicket.
data());
1266 qCWarning(lcTlsBackend,
"could not store persistent version of SSL session");
1270 QTlsBackend::setSessionAsn1(
d, sessionTicket);
1273 emit q->newSessionTicketReceived();
1285 pendingFatalAlert =
true;
1310 const ScopedBool bg(inSetAndEmitError,
true);
1314 qCWarning(lcTlsBackend,
"Could not obtain the certificate (that failed to verify)");
1322 errorsReportedFromCallback =
true;
1323 handshakeInterrupted =
true;
1324 emit q->handshakeInterruptedOnError(tlsError);
1332 errorList->
append(errorAndDepth);
1336 return !handshakeInterrupted;
1346 pendingFatalAlert =
false;
1348 int pendingBytes = 0;
1349 while (plainSocket->isValid() && (pendingBytes =
q_BIO_pending(writeBio)) > 0
1352 data.resize(pendingBytes);
1353 const int bioReadBytes =
q_BIO_read(writeBio,
data.data(), pendingBytes);
1356 qint64 actualWritten = plainSocket->write(
data.constData(), bioReadBytes);
1357 if (actualWritten < 0)
1359 plainSocket->flush();
1363bool TlsCryptographOpenSSL::initSslContext()
1371 const auto configuration =
q->sslConfiguration();
1372 if (!sslContextPointer)
1377 sslContextPointer.reset();
1382 if (!(ssl = sslContextPointer->createSsl())) {
1391 QString tlsHostName = verificationPeerName.
isEmpty() ?
q->peerName() : verificationPeerName;
1403 if (!
q_SSL_ctrl(ssl, SSL_CTRL_SET_TLSEXT_HOSTNAME, TLSEXT_NAMETYPE_host_name, ace.
data()))
1404 qCWarning(lcTlsBackend,
"could not set SSL_CTRL_SET_TLSEXT_HOSTNAME, Server Name Indication disabled");
1414 if (!readBio || !writeBio) {
1434#ifndef OPENSSL_NO_PSK
1441#if OPENSSL_VERSION_NUMBER >= 0x10101006L
1452 if (configuration.ocspStaplingEnabled()) {
1455 QSslSocket::tr(
"Server-side QSslSocket does not support OCSP stapling"));
1460 QSslSocket::tr(
"Failed to enable OCSP stapling"));
1466 const auto backendConfig = configuration.backendConfiguration();
1467 auto responsePos = backendConfig.find(
"Qt-OCSP-response");
1468 if (responsePos != backendConfig.end()) {
1480 QSslSocket::tr(
"Client-side sockets do not send OCSP responses"));
1489void TlsCryptographOpenSSL::destroySslContext()
1505 sslContextPointer.reset();
1519 QTlsBackend::storePeerCertificate(
d, peerCertificate);
1521 auto peerCertificateChain =
q->peerCertificateChain();
1522 if (peerCertificateChain.isEmpty()) {
1525 peerCertificateChain.prepend(peerCertificate);
1526 QTlsBackend::storePeerCertificateChain(
d, peerCertificateChain);
1532bool TlsCryptographOpenSSL::checkOcspStatus()
1537 const auto &configuration =
q->sslConfiguration();
1545 ocspResponses.
clear();
1546 ocspErrorDescription.
clear();
1549 const unsigned char *responseData =
nullptr;
1550 const long responseLength = q_SSL_get_tlsext_status_ocsp_resp(ssl, &responseData);
1551 if (responseLength <= 0 || !responseData) {
1556 OCSP_RESPONSE *response = q_d2i_OCSP_RESPONSE(
nullptr, &responseData, responseLength);
1559 ocspErrorDescription = QSslSocket::tr(
"Failed to decode OCSP response");
1564 const int ocspStatus = q_OCSP_response_status(response);
1565 if (ocspStatus != OCSP_RESPONSE_STATUS_SUCCESSFUL) {
1571 OCSP_BASICRESP *basicResponse = q_OCSP_response_get1_basic(response);
1572 if (!basicResponse) {
1574 ocspErrorDescription = QSslSocket::tr(
"Failed to extract basic OCSP response");
1584 ocspErrorDescription = QSslSocket::tr(
"No certificate verification store, cannot verify OCSP response");
1588 STACK_OF(X509) *peerChain = q_SSL_get_peer_cert_chain(ssl);
1606 const unsigned long verificationFlags = 0;
1607 const int success = q_OCSP_basic_verify(basicResponse, peerChain, store, verificationFlags);
1611 if (q_OCSP_resp_count(basicResponse) != 1) {
1616 OCSP_SINGLERESP *singleResponse = q_OCSP_resp_get0(basicResponse, 0);
1617 if (!singleResponse) {
1620 ocspErrorDescription = QSslSocket::tr(
"Failed to decode a SingleResponse from OCSP status response");
1629 dResponse->
subjectCert = configuration.peerCertificate();
1630 bool matchFound =
false;
1632 dResponse->
signerCert = configuration.peerCertificate();
1633 matchFound = qt_OCSP_certificate_match(singleResponse, peerX509, peerX509);
1635 const STACK_OF(X509) *
certs = q_SSL_get_peer_cert_chain(ssl);
1637 certs = q_OCSP_resp_get0_certs(basicResponse);
1645 matchFound = qt_OCSP_certificate_match(singleResponse, peerX509, issuer);
1663 ASN1_GENERALIZEDTIME *revTime =
nullptr;
1664 ASN1_GENERALIZEDTIME *thisUpdate =
nullptr;
1665 ASN1_GENERALIZEDTIME *nextUpdate =
nullptr;
1667 const int certStatus = q_OCSP_single_get0_status(singleResponse, &reason, &revTime, &thisUpdate, &nextUpdate);
1672 ocspResponses.
clear();
1673 ocspErrorDescription = QSslSocket::tr(
"Failed to extract 'this update time' from the SingleResponse");
1686 if (!q_OCSP_check_validity(thisUpdate, nextUpdate, 60, -1))
1690 switch (certStatus) {
1691 case V_OCSP_CERTSTATUS_GOOD:
1695 case V_OCSP_CERTSTATUS_REVOKED:
1700 case V_OCSP_CERTSTATUS_UNKNOWN:
1705 return !ocspErrors.
size();
1712 unsigned max_identity_len,
1713 unsigned char *psk,
unsigned max_psk_len)
1719 const int hintLength =
hint ? int(std::strlen(
hint)) : 0;
1722 emit q->preSharedKeyAuthenticationRequired(&authenticator);
1731 identity[identityLength] = 0;
1739 unsigned max_psk_len)
1748 emit q->preSharedKeyAuthenticationRequired(&authenticator);
1767 this->renegotiated = renegotiated;
1780 if (fetchAuthorityInformation)
1781 customRoots =
q->sslConfiguration().caCertificates();
1787 q->peerVerifyName());
1797 if (caToFetch !=
cert) {
1808 if (fetchAuthorityInformation) {
1809 if (!
q->sslConfiguration().caCertificates().contains(trustedRoot))
1811 fetchAuthorityInformation =
false;
1818 defaultConfig.addCaCertificate(trustedRoot);
1822 QTlsBackend::addTustedRoot(
d, trustedRoot);
1824 for (
int i=sslErrors.
count() - 1;
i >= 0; --
i) {
1846 plainSocket->resume();
@ SslInvalidUserDataError
@ SslHandshakeFailedError
char * data()
\macro QT_NO_CAST_FROM_BYTEARRAY
bool endsWith(char c) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
QByteArray toUpper() const &
void chop(qsizetype n)
Removes n bytes from the end of the byte array.
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
void clear()
Clears the contents of the byte array and makes it null.
QByteArray & append(char c)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QByteArray toHex(char separator='\0') const
Returns a hex encoded copy of the byte array.
static QString tempPath()
Returns the absolute canonical path of the system's temporary directory.
void close() override
Calls QFileDevice::flush() and closes the file.
bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
The QHostAddress class provides an IP address.
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
qsizetype size() const noexcept
bool isEmpty() const noexcept
void removeAt(qsizetype i)
void push_back(parameter_type t)
const_reference at(qsizetype i) const noexcept
qsizetype count() const noexcept
const T & constFirst() const noexcept
void reserve(qsizetype size)
void append(parameter_type t)
QOcspRevocationReason revocationReason
QSslCertificate subjectCert
QSslCertificate signerCert
QOcspCertificateStatus certificateStatus
This class represents Online Certificate Status Protocol response.
T * data()
Returns a pointer to the shared data object.
static Q_NETWORK_PRIVATE_EXPORT bool isBlacklisted(const QSslCertificate &certificate)
The QSslCertificate class provides a convenient API for an X509 certificate.
bool isSelfSigned() const
QList< QSslCertificateExtension > extensions() const
Returns a list containing the X509 extensions of this certificate.
bool isNull() const
Returns true if this is a null certificate (i.e., a certificate with no contents); otherwise returns ...
bool isBlacklisted() const
Returns true if this certificate is blacklisted; otherwise returns false.
void clear()
Clears the contents of this certificate, making it a null certificate.
The QSslCipher class represents an SSL cryptographic cipher.
static void setDefaultConfiguration(const QSslConfiguration &configuration)
Sets the default SSL configuration to be used in new SSL connections to be configuration.
static QSslConfiguration defaultConfiguration()
Returns the default SSL configuration to be used in new SSL connections.
@ NextProtocolNegotiationUnsupported
@ NextProtocolNegotiationNegotiated
static std::shared_ptr< QSslContext > sharedFromConfiguration(QSslSocket::SslMode mode, const QSslConfiguration &configuration, bool allowRootCertOnDemandLoading)
The QSslError class provides an SSL error.
SslError error() const
Returns the type of the error.
QString errorString() const
Returns a short localized human-readable description of the error.
SslError
Describes all recognized errors that can occur during an SSL handshake.
@ OcspResponseCannotBeTrusted
@ UnableToVerifyFirstCertificate
@ OcspResponseCertIdUnknown
@ UnableToGetLocalIssuerCertificate
@ SelfSignedCertificateInChain
QSslCertificate certificate() const
Returns the certificate associated with this error, or a null certificate if the error does not relat...
The QSslKey class provides an interface for private and public keys.
The QSslPreSharedKeyAuthenticator class provides authentication data for pre shared keys (PSK) cipher...
Q_NETWORK_EXPORT QByteArray preSharedKey() const
Returns the pre shared key.
Q_NETWORK_EXPORT int maximumIdentityLength() const
Returns the maximum length, in bytes, of the PSK client identity.
Q_NETWORK_EXPORT QByteArray identity() const
Returns the PSK client identity.
Q_NETWORK_EXPORT int maximumPreSharedKeyLength() const
Returns the maximum length, in bytes, of the pre shared key.
bool * readyReadPointer()
bool verifyErrorsHaveBeenIgnored()
void setEncrypted(bool enc)
void setMaxReadBufferSize(qint64 maxSize)
QTcpSocket * plainTcpSocket() const
QString verificationName() const
bool isAutoStartingHandshake() const
bool isRootsOnDemandAllowed() const
qint64 maxReadBufferSize() const
bool & tlsEmittedBytesWritten()
QString tlsHostName() const
QRingBufferRef & tlsBuffer()
static bool rootCertOnDemandLoadingSupported()
void setPendingClose(bool pc)
static void pauseSocketNotifiers(QSslSocket *)
QRingBufferRef & tlsWriteBuffer()
QSslSocket::SslMode tlsMode() const
bool isPendingClose() const
The QSslSocket class provides an SSL encrypted socket for both clients and servers.
static long sslLibraryBuildVersionNumber()
\macro QT_RESTRICTED_CAST_FROM_ASCII
void clear()
Clears the contents of the string and makes it null.
qsizetype size() const
Returns the number of characters in this string.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
static QSslCipher qt_OpenSSL_cipher_to_QSslCipher(const SSL_CIPHER *cipher)
static void logAndClearErrorQueue()
static void clearErrorQueue()
static QString msgErrorsDuringHandshake()
static int s_indexForSSLExtraData
static QString getErrorsFromOpenSsl()
static void setupClientPskAuth(QSslPreSharedKeyAuthenticator *auth, const char *hint, int hintLength, unsigned maxIdentityLen, unsigned maxPskLen)
static void setupServerPskAuth(QSslPreSharedKeyAuthenticator *auth, const char *identity, const QByteArray &identityHint, unsigned maxPskLen)
void checkSettingSslContext(std::shared_ptr< QSslContext > tlsContext) override
unsigned pskClientTlsCallback(const char *hint, char *identity, unsigned max_identity_len, unsigned char *psk, unsigned max_psk_len)
void enableHandshakeContinuation() override
QByteArray ocspResponseDer
void alertMessageReceived(int encoded)
std::shared_ptr< QSslContext > sslContext() const override
int handleNewSessionTicket(SSL *connection)
QList< QOcspResponse > ocsps() const override
int emitErrorFromCallback(X509_STORE_CTX *ctx)
void disconnectFromHost() override
void alertMessageSent(int encoded)
void continueHandshake() override
unsigned pskServerTlsCallback(const char *identity, unsigned char *psk, unsigned max_psk_len)
void startClientEncryption() override
QSsl::SslProtocol sessionProtocol() const override
void init(QSslSocket *qObj, QSslSocketPrivate *dObj) override
void disconnected() override
void storePeerCertificates()
void cancelCAFetch() override
QList< QSslError > tlsErrors() const override
void startServerEncryption() override
void setRenegotiated(bool renegotiated)
QSslCipher sessionCipher() const override
static QSslErrorEntry errorEntryFromStoreContext(X509_STORE_CTX *ctx)
static QSslCertificate certificateFromX509(X509 *x)
static QSslError openSSLErrorToQSslError(int errorCode, const QSslCertificate &cert)
static QList< QSslCertificate > stackOfX509ToQSslCertificates(STACK_OF(X509) *x509)
static QByteArray toAce(const QString &domain, AceProcessingOptions options={})
void finished(QSslCertificate brokenChain, QSslCertificate caroot)
@ SslOptionDisableSessionPersistence
@ SslOptionDisableServerNameIndication
@ SslOptionDisableSessionSharing
SslProtocol
Describes the protocol of the cipher.
Combined button and popup list for selecting options.
Namespace containing onternal types that TLS backends implement.
int q_X509Callback(int ok, X509_STORE_CTX *ctx)
static unsigned q_ssl_psk_client_callback(SSL *ssl, const char *hint, char *identity, unsigned max_identity_len, unsigned char *psk, unsigned max_psk_len)
void qt_AlertInfoCallback(const SSL *connection, int from, int value)
static unsigned int q_ssl_psk_server_callback(SSL *ssl, const char *identity, unsigned char *psk, unsigned int max_psk_len)
int q_X509CallbackDirect(int ok, X509_STORE_CTX *ctx)
constexpr Initialization Uninitialized
#define QByteArrayLiteral(str)
#define QT_WARNING_DISABLE_DEPRECATED
DBusConnection const char DBusError * error
DBusConnection * connection
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define qCWarning(category,...)
#define qCDebug(category,...)
constexpr const T & qMin(const T &a, const T &b)
GLenum GLuint GLint level
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLdouble GLdouble GLdouble GLdouble q
QScopeGuard< typename std::decay< F >::type > qScopeGuard(F &&f)
[qScopeGuard]
void q_SSL_get0_next_proto_negotiated(const SSL *s, const unsigned char **data, unsigned *len)
int q_SSL_in_init(const SSL *s)
const SSL_CIPHER * q_SSL_get_current_cipher(SSL *a)
int q_OBJ_obj2nid(const ASN1_OBJECT *a)
SSL_CTX * q_SSL_get_SSL_CTX(SSL *a)
void * q_X509_STORE_get_ex_data(X509_STORE *r, int idx)
int q_SSL_get_ex_data_X509_STORE_CTX_idx()
int q_SSL_session_reused(SSL *a)
X509 * q_X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx)
void q_SSL_set_connect_state(SSL *a)
#define q_SSL_get_server_tmp_key(ssl, key)
#define q_sk_X509_num(st)
int q_SSL_get_error(SSL *a, int b)
X509 * q_SSL_get_peer_certificate(SSL *a)
void * q_X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx, int idx)
#define q_OPENSSL_malloc(num)
void q_SSL_set_accept_state(SSL *a)
STACK_OF(X509) *q_X509_STORE_CTX_get0_chain(X509_STORE_CTX *ctx)
int q_SSL_shutdown(SSL *a)
BIO * q_BIO_new(const BIO_METHOD *a)
X509_STORE * q_SSL_CTX_get_cert_store(const SSL_CTX *a)
void q_SSL_set_psk_use_session_callback(SSL *s, q_SSL_psk_use_session_cb_func_t)
unsigned long q_SSL_SESSION_get_ticket_lifetime_hint(const SSL_SESSION *session)
#define q_EVP_get_digestbynid(a)
int q_SSL_write(SSL *a, const void *b, int c)
int q_i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp)
const char * q_SSL_alert_desc_string_long(int value)
long q_SSL_ctrl(SSL *ssl, int cmd, long larg, void *parg)
void * q_SSL_get_ex_data(const SSL *ssl, int idx)
SSL_SESSION * q_SSL_get_session(const SSL *ssl)
ASN1_INTEGER * q_X509_get_serialNumber(X509 *a)
int q_SSL_read(SSL *a, void *b, int c)
int q_X509_check_issued(X509 *a, X509 *b)
int q_SSL_version(const SSL *a)
const BIO_METHOD * q_BIO_s_mem()
const char * q_SSL_alert_type_string(int value)
void q_SSL_get0_alpn_selected(const SSL *ssl, const unsigned char **data, unsigned *len)
int q_BIO_read(BIO *a, void *b, int c)
void q_SSL_set_bio(SSL *a, BIO *b, BIO *c)
void q_X509_free(X509 *a)
int q_SSL_connect(SSL *a)
size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen)
void q_SSL_set_psk_server_callback(SSL *ssl, q_psk_server_callback_t callback)
#define q_sk_X509_value(st, i)
int q_BIO_write(BIO *a, const void *b, int c)
void q_SSL_set_info_callback(SSL *ssl, void(*cb)(const SSL *ssl, int type, int val))
X509_STORE * q_X509_STORE_CTX_get0_store(X509_STORE_CTX *ctx)
void q_SSL_set_psk_client_callback(SSL *ssl, q_psk_client_callback_t callback)
int q_SSL_set_ex_data(SSL *ssl, int idx, void *arg)
#define q_SSL_set_tlsext_status_type(ssl, type)
size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen)
#define QStringLiteral(str)
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) noexcept
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
QList< QSslCertificate > cert
[0]