355#include <QtCore/qdebug.h>
356#include <QtCore/qdir.h>
357#include <QtCore/qmutex.h>
358#include <QtCore/qurl.h>
359#include <QtCore/qelapsedtimer.h>
360#include <QtNetwork/qhostaddress.h>
361#include <QtNetwork/qhostinfo.h>
388 QExplicitlySharedDataPointer<QSslConfigurationPrivate>
config;
389 QExplicitlySharedDataPointer<QSslConfigurationPrivate>
dtlsConfig;
402#ifdef QSSLSOCKET_DEBUG
403 qCDebug(lcSsl) <<
"QSslSocket::QSslSocket(" << parent <<
"), this =" << (
void *)
this;
415#ifdef QSSLSOCKET_DEBUG
416 qCDebug(lcSsl) <<
"QSslSocket::~QSslSocket(), this =" << (
void *)
this;
418 delete d->plainSocket;
419 d->plainSocket =
nullptr;
489 "QSslSocket::connectToHostEncrypted() called when already connecting/connected");
494 qCWarning(lcSsl,
"QSslSocket::connectToHostEncrypted: TLS initialization failed");
499 if (!
d->verifyProtocolSupported(
"QSslSocket::connectToHostEncrypted:"))
503 d->autoStartHandshake =
true;
504 d->initialized =
true;
529 "QSslSocket::connectToHostEncrypted() called when already connecting/connected");
534 qCWarning(lcSsl,
"QSslSocket::connectToHostEncrypted: TLS initialization failed");
540 d->autoStartHandshake =
true;
541 d->initialized =
true;
542 d->verificationPeerName = sslPeerName;
564#ifdef QSSLSOCKET_DEBUG
571 d->cachedSocketDescriptor =
d->plainSocket->socketDescriptor();
572 d->setError(
d->plainSocket->error(),
d->plainSocket->errorString());
580 d->readChannelCount =
d->plainSocket->readChannelCount();
581 d->writeChannelCount =
d->plainSocket->writeChannelCount();
608 return d->plainSocket->socketOption(
option);
647 return d->connectionEncrypted;
658 return d->configuration.protocol;
689 return d->configuration.peerVerifyMode;
712 d->configuration.peerVerifyMode =
mode;
731 return d->configuration.peerVerifyDepth;
751 qCWarning(lcSsl,
"QSslSocket::setPeerVerifyDepth: cannot set negative depth of %d",
depth);
754 d->configuration.peerVerifyDepth =
depth;
768 return d->verificationPeerName;
782 d->verificationPeerName = hostName;
809 return d->plainSocket ?
d->plainSocket->bytesToWrite() : 0;
810 return d->writeBuffer.size();
825 return d->plainSocket->bytesAvailable();
839 return d->plainSocket->bytesToWrite();
861#ifdef QSSLSOCKET_DEBUG
862 qCDebug(lcSsl) <<
"QSslSocket::close()";
869 if (
auto *backend =
d->backend.get())
870 backend->cancelCAFetch();
874 if (
d->plainSocket) {
876 d->plainSocket->abort();
878 d->plainSocket->close();
884 d->writeBuffer.clear();
906 d->readBufferMaxSize =
size;
909 d->plainSocket->setReadBufferSize(
size);
932 copy->ref.storeRelaxed(0);
933 copy->sessionCipher =
d->sessionCipher();
934 copy->sessionProtocol =
d->sessionProtocol();
955 d->configuration.privateKey = configuration.
privateKey();
956 d->configuration.ciphers = configuration.
ciphers();
963 d->configuration.protocol = configuration.
protocol();
965 d->configuration.sslOptions = configuration.d->
sslOptions;
974#if QT_CONFIG(openssl)
982 d->allowRootCertOnDemandLoading =
false;
983 d->configuration.allowRootCertOnDemandLoading =
false;
997 d->configuration.localCertificateChain = localChain;
1010 return d->configuration.localCertificateChain;
1035 d->configuration.localCertificateChain = QList<QSslCertificate>();
1036 d->configuration.localCertificateChain += certificate;
1064 if (
d->configuration.localCertificateChain.isEmpty())
1066 return d->configuration.localCertificateChain[0];
1097 return d->configuration.peerCertificate;
1126 return d->configuration.peerCertificateChain;
1148 return d->sessionCipher();
1162 return d->sessionProtocol();
1177 if (
const auto *backend =
d->backend.get())
1178 return backend->ocsps();
1198 d->configuration.privateKey =
key;
1226 qCWarning(lcSsl,
"QSslSocket::setPrivateKey: Couldn't open file for reading");
1232 qCWarning(lcSsl,
"QSslSocket::setPrivateKey: "
1233 "The specified file does not contain a valid key");
1238 d->configuration.privateKey =
key;
1249 return d->configuration.privateKey;
1262 if (!
d->plainSocket)
1264 bool retVal =
d->plainSocket->waitForConnected(msecs);
1267 d->setError(
d->plainSocket->error(),
d->plainSocket->errorString());
1291 if (!
d->plainSocket ||
d->connectionEncrypted)
1295 if (!
d->verifyProtocolSupported(
"QSslSocket::waitForEncrypted:"))
1303 if (!
d->plainSocket->waitForConnected(msecs))
1307 while (!
d->connectionEncrypted) {
1316 return d->connectionEncrypted;
1325 if (!
d->plainSocket)
1328 return d->plainSocket->waitForReadyRead(msecs);
1334 bool readyReadEmitted =
false;
1335 bool *previousReadyReadEmittedPointer =
d->readyReadEmittedPointer;
1336 d->readyReadEmittedPointer = &readyReadEmitted;
1341 if (!
d->connectionEncrypted) {
1344 d->readyReadEmittedPointer = previousReadyReadEmittedPointer;
1349 if (!
d->writeBuffer.isEmpty()) {
1356 while (!readyReadEmitted &&
1360 d->readyReadEmittedPointer = previousReadyReadEmittedPointer;
1361 return readyReadEmitted;
1370 if (!
d->plainSocket)
1373 return d->plainSocket->waitForBytesWritten(msecs);
1378 if (!
d->connectionEncrypted) {
1383 if (!
d->writeBuffer.isEmpty()) {
1404 qCWarning(lcSsl,
"QSslSocket::waitForDisconnected() is not allowed in UnconnectedState");
1408 if (!
d->plainSocket)
1412 return d->plainSocket->waitForDisconnected(msecs);
1417 if (!
d->connectionEncrypted) {
1424 if (!
d->writeBuffer.isEmpty())
1436 d->setError(
d->plainSocket->error(),
d->plainSocket->errorString());
1454 if (
const auto *backend =
d->backend.get())
1455 return backend->tlsErrors();
1478 return tlsBackend->tlsLibraryVersionNumber();
1492 return tlsBackend->tlsLibraryVersionString();
1506 return tlsBackend->tlsLibraryBuildVersionNumber();
1521 return tlsBackend->tlsLibraryBuildVersionString();
1582 qCWarning(lcSsl,
"Invalid parameter (backend name cannot be an empty string)");
1589 <<
"as active, another backend is already in use";
1629 return versions.contains(
protocol);
1700 "QSslSocket::startClientEncryption: cannot start handshake on non-plain connection");
1705 "QSslSocket::startClientEncryption: cannot start handshake when not connected");
1710 qCWarning(lcSsl,
"QSslSocket::startClientEncryption: TLS initialization failed");
1715 if (!
d->verifyProtocolSupported(
"QSslSocket::startClientEncryption:"))
1718#ifdef QSSLSOCKET_DEBUG
1719 qCDebug(lcSsl) <<
"QSslSocket::startClientEncryption()";
1723 d->startClientEncryption();
1750 qCWarning(lcSsl,
"QSslSocket::startServerEncryption: cannot start handshake on non-plain connection");
1753#ifdef QSSLSOCKET_DEBUG
1754 qCDebug(lcSsl) <<
"QSslSocket::startServerEncryption()";
1757 qCWarning(lcSsl,
"QSslSocket::startServerEncryption: TLS initialization failed");
1761 if (!
d->verifyProtocolSupported(
"QSslSocket::startServerEncryption"))
1766 d->startServerEncryption();
1797 d->ignoreAllSslErrors =
true;
1824 d->ignoreErrorsList = errors;
1841 if (
auto *backend =
d->backend.get())
1842 backend->enableHandshakeContinuation();
1851 d->preferredNetworkLayerProtocol =
protocol;
1852 if (!
d->initialized)
1854 d->initialized =
false;
1856#ifdef QSSLSOCKET_DEBUG
1857 qCDebug(lcSsl) <<
"QSslSocket::connectToHost("
1860 if (!
d->plainSocket) {
1861#ifdef QSSLSOCKET_DEBUG
1862 qCDebug(lcSsl) <<
"\tcreating internal plain socket";
1866#ifndef QT_NO_NETWORKPROXY
1867 d->plainSocket->setProtocolTag(
d->protocolTag);
1868 d->plainSocket->setProxy(
proxy());
1871 d->readChannelCount =
d->writeChannelCount = 0;
1872 d->plainSocket->connectToHost(hostName,
port,
openMode,
d->preferredNetworkLayerProtocol);
1873 d->cachedSocketDescriptor =
d->plainSocket->socketDescriptor();
1882#ifdef QSSLSOCKET_DEBUG
1883 qCDebug(lcSsl) <<
"QSslSocket::disconnectFromHost()";
1885 if (!
d->plainSocket)
1890 d->plainSocket->disconnectFromHost();
1894 d->pendingClose =
true;
1899 if (
auto *backend =
d->backend.get())
1900 backend->cancelCAFetch();
1908 if (!
d->writeBuffer.isEmpty()) {
1909 d->pendingClose =
true;
1914 d->plainSocket->disconnectFromHost();
1916 d->disconnectFromHost();
1929 readBytes =
d->plainSocket->read(
data, maxlen);
1930#ifdef QSSLSOCKET_DEBUG
1931 qCDebug(lcSsl) <<
"QSslSocket::readData(" << (
void *)
data <<
',' << maxlen <<
") =="
1936 if (
d->plainSocket->bytesAvailable() ||
d->hasUndecryptedData())
1951#ifdef QSSLSOCKET_DEBUG
1952 qCDebug(lcSsl) <<
"QSslSocket::writeData(" << (
void *)
data <<
',' <<
len <<
')';
1955 return d->plainSocket->write(
data,
len);
1960 if (!
d->flushTriggered) {
1961 d->flushTriggered =
true;
1974 : initialized(
false)
1976 , autoStartHandshake(
false)
1977 , connectionEncrypted(
false)
1978 , ignoreAllSslErrors(
false)
1979 , readyReadEmittedPointer(
nullptr)
1980 , allowRootCertOnDemandLoading(true)
1983 , flushTriggered(
false)
1993 qCWarning(lcSsl,
"No TLS backend is available");
1999 <<
"does not support TLS";
2068 auto protocolName =
"DTLS"_L1;
2073 protocolName =
"UnknownProtocol"_L1;
2077 case QSsl::DtlsV1_0:
2079 case QSsl::DtlsV1_0OrLater:
2081 qCWarning(lcSsl) << where <<
"QSslConfiguration with unexpected protocol" << protocolName;
2083 QSslSocket::tr(
"Attempted to use an unsupported protocol."));
2098 return globalData()->config->ciphers;
2108 return globalData()->supportedCiphers;
2117 globalData()->config.detach();
2118 globalData()->config->ciphers = ciphers;
2127 globalData()->config.detach();
2128 globalData()->supportedCiphers = ciphers;
2144 QList<QSslEllipticCurve> curves;
2145 curves.reserve(
ids.size());
2146 for (
int id :
ids) {
2149 curves.append(curve);
2165 globalData()->dtlsConfig.detach();
2166 globalData()->dtlsConfig->ciphers = ciphers;
2176 return globalData()->dtlsConfig->ciphers;
2186 return globalData()->supportedEllipticCurves;
2195 globalData()->config.detach();
2196 globalData()->dtlsConfig.detach();
2197 globalData()->supportedEllipticCurves = curves;
2207 return globalData()->config->caCertificates;
2217 globalData()->config.detach();
2218 globalData()->config->caCertificates =
certs;
2219 globalData()->dtlsConfig.detach();
2220 globalData()->dtlsConfig->caCertificates =
certs;
2233 if (globalData()->
config->caCertificates.contains(
cert))
2235 globalData()->config.detach();
2236 globalData()->config->caCertificates +=
cert;
2237 globalData()->dtlsConfig.
detach();
2238 globalData()->dtlsConfig->caCertificates +=
cert;
2248 globalData()->config.detach();
2249 globalData()->config->caCertificates +=
certs;
2250 globalData()->dtlsConfig.detach();
2251 globalData()->dtlsConfig->caCertificates +=
certs;
2271 if (globalData()->
config == configuration.d)
2289 ptr->ref.storeRelaxed(1);
2290 ptr->peerCertificate =
global->peerCertificate;
2291 ptr->peerCertificateChain =
global->peerCertificateChain;
2292 ptr->localCertificateChain =
global->localCertificateChain;
2294 ptr->sessionCipher =
global->sessionCipher;
2295 ptr->sessionProtocol =
global->sessionProtocol;
2297 ptr->caCertificates =
global->caCertificates;
2298 ptr->allowRootCertOnDemandLoading =
global->allowRootCertOnDemandLoading;
2300 ptr->peerVerifyMode =
global->peerVerifyMode;
2301 ptr->peerVerifyDepth =
global->peerVerifyDepth;
2303 ptr->ellipticCurves =
global->ellipticCurves;
2304 ptr->backendConfig =
global->backendConfig;
2306 ptr->dtlsCookieEnabled =
global->dtlsCookieEnabled;
2309 ptr->ocspStaplingEnabled =
global->ocspStaplingEnabled;
2311#if QT_CONFIG(openssl)
2312 ptr->reportFromCallback =
global->reportFromCallback;
2313 ptr->missingCertIsFatal =
global->missingCertIsFatal;
2335 if (globalData()->dtlsConfig == configuration.d)
2387#ifndef QT_NO_NETWORKPROXY
2403 if (!
socket->d_func()->plainSocket)
2410 if (!
socket->d_func()->plainSocket)
2432#ifdef QSSLSOCKET_DEBUG
2436#ifdef QSSLSOCKET_DEBUG
2437 qCDebug(lcSsl) <<
"\tcreating internal plain socket";
2464#ifdef QSSLSOCKET_DEBUG
2465 qCDebug(lcSsl) <<
"QSslSocket::_q_connectedSlot()";
2466 qCDebug(lcSsl) <<
"\tstate =" <<
q->state();
2467 qCDebug(lcSsl) <<
"\tpeer =" <<
q->peerName() <<
q->peerAddress() <<
q->peerPort();
2469 <<
q->localAddress() <<
q->localPort();
2473 q->startClientEncryption();
2475 emit q->connected();
2479 q->disconnectFromHost();
2489#ifdef QSSLSOCKET_DEBUG
2490 qCDebug(lcSsl) <<
"QSslSocket::_q_hostFoundSlot()";
2491 qCDebug(lcSsl) <<
"\tstate =" <<
q->state();
2493 emit q->hostFound();
2502#ifdef QSSLSOCKET_DEBUG
2503 qCDebug(lcSsl) <<
"QSslSocket::_q_disconnectedSlot()";
2504 qCDebug(lcSsl) <<
"\tstate =" <<
q->state();
2507 emit q->disconnected();
2523#ifdef QSSLSOCKET_DEBUG
2524 qCDebug(lcSsl) <<
"QSslSocket::_q_stateChangedSlot(" <<
state <<
')';
2526 q->setSocketState(
state);
2536#ifdef QSSLSOCKET_DEBUG
2538 qCDebug(lcSsl) <<
"QSslSocket::_q_errorSlot(" <<
error <<
')';
2539 qCDebug(lcSsl) <<
"\tstate =" <<
q->state();
2540 qCDebug(lcSsl) <<
"\terrorString =" <<
q->errorString();
2559#ifdef QSSLSOCKET_DEBUG
2565 emit q->readyRead();
2588#ifdef QSSLSOCKET_DEBUG
2589 qCDebug(lcSsl) <<
"QSslSocket::_q_bytesWrittenSlot(" << written <<
')';
2593 emit q->bytesWritten(written);
2595 emit q->encryptedBytesWritten(written);
2597 q->disconnectFromHost();
2616 emit q->readChannelFinished();
2655 const auto sslErrors =
backend->tlsErrors();
2672 bool doEmitSslError;
2677 const auto &sslErrors =
backend->tlsErrors();
2678 doEmitSslError =
false;
2679 for (
int a = 0;
a < sslErrors.size();
a++) {
2681 doEmitSslError =
true;
2691 return !doEmitSslError;
2795 return (
r > 0 ?
r :
r2);
2817 if (
ret.size() == maxSize)
2838 return d->plainSocket->skip(maxSize);
2851#ifdef QSSLSOCKET_DEBUG
2852 qCDebug(lcSsl) <<
"QSslSocketPrivate::flush()";
2868 backend->startClientEncryption();
2877 backend->startServerEncryption();
2895 backend->disconnectFromHost();
2913 return backend->sessionCipher();
2924 return backend->sessionProtocol();
2959 const auto ba = [](
const auto &cstr)
constexpr {
2963 ba(
"/etc/ssl/certs/"),
2964 ba(
"/usr/lib/ssl/certs/"),
2965 ba(
"/usr/share/ssl/"),
2966 ba(
"/usr/local/ssl/"),
2967 ba(
"/var/ssl/certs/"),
2968 ba(
"/usr/local/ssl/certs/"),
2969 ba(
"/etc/openssl/certs/"),
2970 ba(
"/opt/openssl/certs/"),
2976 if (!vxworksCertsDir.isEmpty())
2977 result.push_back(vxworksCertsDir);
2991 backend->checkSettingSslContext(tlsContext);
3011 if (!hostAddress.isNull()) {
3012 const auto subjectAlternativeNames =
cert.subjectAlternativeNames();
3015 for (
auto it = ipAddresses.first;
it != ipAddresses.second;
it++) {
3024 for (
const QString &commonName : commonNames) {
3029 const auto subjectAlternativeNames =
cert.subjectAlternativeNames();
3030 const auto altNames = subjectAlternativeNames.equal_range(
QSsl::DnsEntry);
3031 for (
auto it = altNames.first;
it != altNames.second; ++
it) {
3052 qsizetype secondCnDot = cn.indexOf(u
'.', firstCnDot+1);
3055 if ((-1 == secondCnDot) || (secondCnDot+1 >= cn.size()))
3059 if (wildcard+1 != firstCnDot)
3063 if (cn.lastIndexOf(u
'*') != wildcard)
3104 qCWarning(lcSsl,
"No functional TLS backend was found");
3168#include "moc_qsslsocket.cpp"
IOBluetoothL2CAPChannel * channel
qintptr cachedSocketDescriptor
void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator) override
QHostAddress localAddress
static void pauseSocketNotifiers(QAbstractSocket *)
QAbstractSocket::SocketState state
static void resumeSocketNotifiers(QAbstractSocket *)
void setErrorAndEmit(QAbstractSocket::SocketError errorCode, const QString &errorString)
SocketState
This enum describes the different states in which a socket can be.
bool flush()
This function writes as much as possible from the internal write buffer to the underlying network soc...
void stateChanged(QAbstractSocket::SocketState)
This signal is emitted whenever QAbstractSocket's state changes.
quint16 peerPort() const
Returns the port of the connected peer if the socket is in ConnectedState; otherwise returns 0.
virtual qintptr socketDescriptor() const
Returns the native socket descriptor of the QAbstractSocket object if this is available; otherwise re...
void setPeerPort(quint16 port)
qint64 bytesAvailable() const override
Returns the number of incoming bytes that are waiting to be read.
QHostAddress localAddress() const
Returns the host address of the local socket if available; otherwise returns QHostAddress::Null.
QString peerName() const
Returns the name of the peer as specified by connectToHost(), or an empty QString if connectToHost() ...
QNetworkProxy proxy() const
virtual bool bind(const QHostAddress &address, quint16 port=0, BindMode mode=DefaultForPlatform)
virtual void disconnectFromHost()
Attempts to close the socket.
void setPeerAddress(const QHostAddress &address)
void setLocalPort(quint16 port)
void setLocalAddress(const QHostAddress &address)
SocketState state() const
Returns the state of the socket.
SocketError
This enum describes the socket errors that can occur.
@ SslInvalidUserDataError
@ SslHandshakeFailedError
void setSocketState(SocketState state)
Sets the state of the socket to state.
quint16 localPort() const
Returns the host port number (in native byte order) of the local socket if available; otherwise retur...
void setPeerName(const QString &name)
SocketError error() const
Returns the type of error that last occurred.
QHostAddress peerAddress() const
Returns the address of the connected peer if the socket is in ConnectedState; otherwise returns QHost...
The QAuthenticator class provides an authentication object.
void reserve(qsizetype size)
Attempts to allocate memory for at least size bytes.
static QByteArray fromRawData(const char *data, qsizetype size)
Constructs a QByteArray that uses the first size bytes of the data array.
void start() noexcept
\typealias QElapsedTimer::Duration Synonym for std::chrono::nanoseconds.
QFILE_MAYBE_NODISCARD bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
The QHostAddress class provides an IP address.
bool isEqual(const QHostAddress &address, ConversionMode mode=TolerantConversion) const
static QHostInfo fromName(const QString &name)
Looks up the IP address(es) for the given host name.
qint64 peek(char *data, qint64 maxLength, qint64 pos=0) const
QIODevice::OpenMode openMode
virtual qint64 peek(char *data, qint64 maxSize)
QRingBufferRef writeBuffer
virtual bool open(QIODeviceBase::OpenMode mode)
Opens the device and sets its OpenMode to mode.
int writeChannelCount() const
virtual qint64 size() const
For open random-access devices, this function returns the size of the device.
void setOpenMode(QIODeviceBase::OpenMode openMode)
Sets the OpenMode of the device to openMode.
QByteArray readAll()
Reads all remaining data from the device, and returns it as a byte array.
QIODeviceBase::OpenMode openMode() const
Returns the mode in which the device has been opened; i.e.
qint64 peek(char *data, qint64 maxlen)
QString errorString() const
Returns a human-readable description of the last device error that occurred.
virtual void close()
First emits aboutToClose(), then closes the device and sets its OpenMode to NotOpen.
virtual bool atEnd() const
Returns true if the current read and write position is at the end of the device (i....
int readChannelCount() const
virtual bool canReadLine() const
Returns true if a complete line of data can be read from the device; otherwise returns false.
bool empty() const noexcept
static QList< T > fromReadOnlyData(const T(&t)[N]) noexcept
void unlock() noexcept
Unlocks this mutex locker.
The QNetworkProxy class provides a network layer proxy.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
const T * constData() const noexcept
Returns a const pointer to the shared data object.
The QSslCertificate class provides a convenient API for an X509 certificate.
void clear()
Clears the contents of this certificate, making it a null certificate.
The QSslCipher class represents an SSL cryptographic cipher.
QSsl::SslProtocol protocol
QSsl::SslOptions sslOptions
bool allowRootCertOnDemandLoading
static QSslConfiguration defaultConfiguration()
static void setDefaultDtlsConfiguration(const QSslConfiguration &configuration)
static void deepCopyDefaultConfiguration(QSslConfigurationPrivate *config)
QList< QSslCertificate > peerCertificateChain
static void setDefaultConfiguration(const QSslConfiguration &configuration)
QSslCertificate peerCertificate
static QSslConfiguration defaultDtlsConfiguration()
The QSslConfiguration class holds the configuration and state of an SSL connection.
QList< QByteArray > allowedNextProtocols() const
QList< QSslCertificate > caCertificates() const
Returns this connection's CA certificate database.
bool ocspStaplingEnabled() const
QList< QSslCertificate > localCertificateChain() const
Returns the certificate chain to be presented to the peer during the SSL handshake process.
QSslSocket::PeerVerifyMode peerVerifyMode() const
Returns the verify mode.
QSsl::SslProtocol protocol() const
Returns the protocol setting for this SSL configuration.
QSslDiffieHellmanParameters diffieHellmanParameters() const
QByteArray preSharedKeyIdentityHint() const
int sessionTicketLifeTimeHint() const
int peerVerifyDepth() const
Returns the maximum number of certificates in the peer's certificate chain to be checked during the S...
QByteArray nextNegotiatedProtocol() const
QSslKey privateKey() const
Returns the \l {QSslKey} {SSL key} assigned to this connection or a null key if none has been assigne...
QList< QSslEllipticCurve > ellipticCurves() const
QList< QSslCipher > ciphers() const
Returns this connection's current cryptographic cipher suite.
QByteArray sessionTicket() const
bool handshakeMustInterruptOnError() const
bool missingCertificateIsFatal() const
QMap< QByteArray, QVariant > backendConfiguration() const
NextProtocolNegotiationStatus nextProtocolNegotiationStatus() const
Represents an elliptic curve for use by elliptic-curve cipher algorithms.
The QSslKey class provides an interface for private and public keys.
QExplicitlySharedDataPointer< QSslConfigurationPrivate > dtlsConfig
QExplicitlySharedDataPointer< QSslConfigurationPrivate > config
QList< QSslEllipticCurve > supportedEllipticCurves
QList< QSslCipher > supportedCiphers
bool * readyReadPointer()
bool verifyErrorsHaveBeenIgnored()
static void setDefaultCaCertificates(const QList< QSslCertificate > &certs)
void setEncrypted(bool enc)
static void setDefaultDtlsCiphers(const QList< QSslCipher > &ciphers)
static bool supportsSsl()
void setMaxReadBufferSize(qint64 maxSize)
static void addDefaultCaCertificate(const QSslCertificate &cert)
QTcpSocket * plainTcpSocket() const
QString verificationName() const
void _q_readChannelFinishedSlot()
void startServerEncryption()
QSslCipher sessionCipher() const
bool isAutoStartingHandshake() const
bool * readyReadEmittedPointer
static QTlsBackend * tlsBackendInUse()
void _q_flushReadBuffer()
static void setDefaultCiphers(const QList< QSslCipher > &ciphers)
static void resumeSocketNotifiers(QSslSocket *)
QString verificationPeerName
qint64 peek(char *data, qint64 maxSize) override
void _q_channelReadyReadSlot(int)
static void setRootCertOnDemandLoadingSupported(bool supported)
bool isRootsOnDemandAllowed() const
static std::shared_ptr< QSslContext > sslContext(QSslSocket *socket)
static QList< QSslCertificate > defaultCaCertificates()
bool allowRootCertOnDemandLoading
static void ensureInitialized()
void _q_flushWriteBuffer()
qint64 maxReadBufferSize() const
bool & tlsEmittedBytesWritten()
QString tlsHostName() const
static QList< QByteArray > unixRootCertDirectories()
std::unique_ptr< QTlsPrivate::TlsCryptograph > backend
QRingBufferRef & tlsBuffer()
static QList< QSslCipher > defaultDtlsCiphers()
bool verifyProtocolSupported(const char *where)
static void checkSettingSslContext(QSslSocket *, std::shared_ptr< QSslContext >)
static QList< QSslCipher > supportedCiphers()
void _q_stateChangedSlot(QAbstractSocket::SocketState)
static bool rootCertOnDemandLoadingSupported()
static QString activeBackendName
static QList< QSslEllipticCurve > supportedEllipticCurves()
static void addDefaultCaCertificates(const QList< QSslCertificate > &certs)
static QMutex backendMutex
void _q_errorSlot(QAbstractSocket::SocketError)
void _q_resumeImplementation()
void createPlainSocket(QIODevice::OpenMode openMode)
void setPendingClose(bool pc)
virtual ~QSslSocketPrivate()
static void pauseSocketNotifiers(QSslSocket *)
bool hasUndecryptedData() const
void _q_bytesWrittenSlot(qint64)
QRingBufferRef & tlsWriteBuffer()
QSsl::SslProtocol sessionProtocol() const
void _q_channelBytesWrittenSlot(int, qint64)
QList< QSslError > ignoreErrorsList
static QList< QSslCertificate > systemCaCertificates()
static void resetDefaultEllipticCurves()
static void setDefaultSupportedEllipticCurves(const QList< QSslEllipticCurve > &curves)
static bool isMatchingHostname(const QSslCertificate &cert, const QString &peerName)
void disconnectFromHost()
static bool s_loadRootCertsOnDemand
QSslSocket::SslMode tlsMode() const
static QList< QSslCipher > defaultCiphers()
static void setDefaultSupportedCiphers(const QList< QSslCipher > &ciphers)
bool bind(const QHostAddress &address, quint16, QAbstractSocket::BindMode) override
static QTlsBackend * tlsBackend
void _q_disconnectedSlot()
bool isPendingClose() const
QSslConfigurationPrivate configuration
void startClientEncryption()
The QSslSocket class provides an SSL encrypted socket for both clients and servers.
QList< QSslCertificate > peerCertificateChain() const
Returns the peer's chain of digital certificates, or an empty list of certificates.
void resume() override
\reimp
static QString sslLibraryBuildVersionString()
static QList< QSsl::ImplementedClass > implementedClasses(const QString &backendName={})
QSslConfiguration sslConfiguration() const
void setLocalCertificateChain(const QList< QSslCertificate > &localChain)
Sets the certificate chain to be presented to the peer during the SSL handshake to be localChain.
bool isEncrypted() const
Returns true if the socket is encrypted; otherwise, false is returned.
bool canReadLine() const override
\reimp
void disconnectFromHost() override
QList< QOcspResponse > ocspResponses() const
bool waitForReadyRead(int msecs=30000) override
\reimp
static bool setActiveBackend(const QString &backendName)
bool waitForBytesWritten(int msecs=30000) override
\reimp
void setPrivateKey(const QSslKey &key)
Sets the socket's private \l {QSslKey} {key} to key.
qint64 skipData(qint64 maxSize) override
\reimp
static QList< QSsl::SslProtocol > supportedProtocols(const QString &backendName={})
virtual void setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value) override
QSslCipher sessionCipher() const
Returns the socket's cryptographic \l {QSslCipher} {cipher}, or a null cipher if the connection isn't...
void startServerEncryption()
Starts a delayed SSL handshake for a server connection.
QString peerVerifyName() const
void ignoreSslErrors()
This slot tells QSslSocket to ignore errors during QSslSocket's handshake phase and continue connecti...
bool setSocketDescriptor(qintptr socketDescriptor, SocketState state=ConnectedState, OpenMode openMode=ReadWrite) override
Initializes QSslSocket with the native socket descriptor socketDescriptor.
static long sslLibraryVersionNumber()
QSslSocket::PeerVerifyMode peerVerifyMode() const
SslMode
Describes the connection modes available for QSslSocket.
void setPeerVerifyMode(QSslSocket::PeerVerifyMode mode)
SslMode mode() const
Returns the current mode for the socket; either UnencryptedMode, where QSslSocket behaves identially ...
qint64 writeData(const char *data, qint64 len) override
\reimp
QSsl::SslProtocol protocol() const
Returns the socket's SSL protocol.
QList< QSslError > sslHandshakeErrors() const
static QList< QSsl::SupportedFeature > supportedFeatures(const QString &backendName={})
qint64 bytesToWrite() const override
\reimp
int peerVerifyDepth() const
bool waitForEncrypted(int msecs=30000)
Waits until the socket has completed the SSL handshake and has emitted encrypted(),...
qint64 readData(char *data, qint64 maxlen) override
\reimp
qint64 encryptedBytesAvailable() const
void close() override
\reimp
static bool supportsSsl()
Returns true if this platform supports SSL; otherwise, returns false.
void setSslConfiguration(const QSslConfiguration &config)
void connectToHost(const QString &hostName, quint16 port, OpenMode openMode=ReadWrite, NetworkLayerProtocol protocol=AnyIPProtocol) override
~QSslSocket()
Destroys the QSslSocket.
bool waitForDisconnected(int msecs=30000) override
Waits until the socket has disconnected or msecs milliseconds, whichever comes first.
static long sslLibraryBuildVersionNumber()
virtual QVariant socketOption(QAbstractSocket::SocketOption option) override
static QString sslLibraryVersionString()
void connectToHostEncrypted(const QString &hostName, quint16 port, OpenMode mode=ReadWrite, NetworkLayerProtocol protocol=AnyIPProtocol)
Starts an encrypted connection to the device hostName on port, using mode as the \l OpenMode.
void setPeerVerifyName(const QString &hostName)
QSslCertificate localCertificate() const
Returns the socket's local \l {QSslCertificate} {certificate}, or an empty certificate if no local ce...
qint64 encryptedBytesToWrite() const
void continueInterruptedHandshake()
static bool isClassImplemented(QSsl::ImplementedClass cl, const QString &backendName={})
void setReadBufferSize(qint64 size) override
QSsl::SslProtocol sessionProtocol() const
Returns the socket's SSL/TLS protocol or UnknownProtocol if the connection isn't encrypted.
static bool isProtocolSupported(QSsl::SslProtocol protocol, const QString &backendName={})
static QList< QString > availableBackends()
void setPeerVerifyDepth(int depth)
static bool isFeatureSupported(QSsl::SupportedFeature feat, const QString &backendName={})
QSslKey privateKey() const
Returns this socket's private key.
void setProtocol(QSsl::SslProtocol protocol)
Sets the socket's SSL protocol to protocol.
QList< QSslCertificate > localCertificateChain() const
Returns the socket's local \l {QSslCertificate} {certificate} chain, or an empty list if no local cer...
void modeChanged(QSslSocket::SslMode newMode)
This signal is emitted when QSslSocket changes from \l QSslSocket::UnencryptedMode to either \l QSslS...
bool waitForConnected(int msecs=30000) override
Waits until the socket is connected, or msecs milliseconds, whichever happens first.
qint64 bytesAvailable() const override
\reimp
static QString activeBackend()
void startClientEncryption()
Starts a delayed SSL handshake for a client connection.
bool atEnd() const override
\reimp
QSslCertificate peerCertificate() const
Returns the peer's digital certificate (i.e., the immediate certificate of the host you are connected...
void setLocalCertificate(const QSslCertificate &certificate)
Sets the socket's local certificate to certificate.
constexpr QStringView left(qsizetype n) const noexcept
constexpr QStringView mid(qsizetype pos, qsizetype n=-1) const noexcept
Returns the substring of length length starting at position start in this object.
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString left(qsizetype n) const &
qsizetype indexOf(QLatin1StringView s, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString mid(qsizetype position, qsizetype n=-1) const &
The QTcpSocket class provides a TCP socket.
QTlsBackend is a factory class, providing implementations for the QSsl classes.
virtual QList< QSsl::SupportedFeature > supportedFeatures() const =0
virtual QList< QSsl::SslProtocol > supportedProtocols() const =0
static QList< QString > availableBackendNames()
virtual QList< QSsl::ImplementedClass > implementedClasses() const =0
static QString defaultBackendName()
static QTlsBackend * findBackend(const QString &backendName)
static QByteArray toAce(const QString &domain, AceProcessingOptions options={})
QSet< QString >::iterator it
SupportedFeature
Enumerates possible features that a TLS backend supports.
ImplementedClass
Enumerates classes that a TLS backend implements.
KeyAlgorithm
Describes the different key algorithms supported by QSslKey.
EncodingFormat
Describes supported encoding formats for certificates and keys.
SslProtocol
Describes the protocol of the cipher.
Combined button and popup list for selecting options.
static jboolean copy(JNIEnv *, jobject)
#define QT_WARNING_DISABLE_DEPRECATED
DBusConnection const char DBusError * error
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
int qt_subtract_from_timeout(int timeout, int elapsed)
#define qCWarning(category,...)
#define qCDebug(category,...)
static ControlElement< T > * ptr(QWidget *widget)
static bool contains(const QJsonArray &haystack, unsigned needle)
GLenum GLsizei GLuint GLint * bytesWritten
GLint GLenum GLsizei GLsizei GLsizei depth
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei const GLuint * ids
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLsizei GLsizei GLenum format
GLuint GLuint64EXT address
GLdouble GLdouble GLdouble GLdouble q
GLsizei const GLchar *const * path
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
static int compare(quint64 a, quint64 b)
QList< QSslCertificate > cert
[0]
bool contains(const AT &t) const noexcept