312 #include <QtCore/qdebug.h> 313 #include <QtCore/qdir.h> 314 #include <QtCore/qmutex.h> 315 #include <QtCore/qelapsedtimer.h> 316 #include <QtNetwork/qhostaddress.h> 317 #include <QtNetwork/qhostinfo.h> 331 return timeout < 0 ? 0 : timeout;
354 #ifdef QSSLSOCKET_DEBUG 355 qDebug() <<
"QSslSocket::QSslSocket(" << parent <<
"), this =" << (
void *)
this;
367 #ifdef QSSLSOCKET_DEBUG 368 qDebug() <<
"QSslSocket::~QSslSocket(), this =" << (
void *)
this;
370 delete d->plainSocket;
417 if (
d->state == ConnectedState ||
d->state == ConnectingState) {
418 qWarning(
"QSslSocket::connectToHostEncrypted() called when already connecting/connected");
423 d->autoStartHandshake =
true;
424 d->initialized =
true;
428 connectToHost(hostName, port, mode);
446 const QString &sslPeerName, OpenMode mode)
449 if (
d->state == ConnectedState ||
d->state == ConnectingState) {
450 qWarning(
"QSslSocket::connectToHostEncrypted() called when already connecting/connected");
455 d->autoStartHandshake =
true;
456 d->initialized =
true;
457 d->verificationPeerName = sslPeerName;
461 connectToHost(hostName, port, mode);
479 #ifdef QSSLSOCKET_DEBUG 480 qDebug() <<
"QSslSocket::setSocketDescriptor(" << socketDescriptor <<
',' 481 << state <<
',' << openMode <<
')';
484 d->createPlainSocket(openMode);
485 bool retVal =
d->plainSocket->setSocketDescriptor(socketDescriptor, state, openMode);
486 d->cachedSocketDescriptor =
d->plainSocket->socketDescriptor();
487 setSocketError(
d->plainSocket->error());
488 setSocketState(state);
489 setOpenMode(openMode);
490 setLocalPort(
d->plainSocket->localPort());
491 setLocalAddress(
d->plainSocket->localAddress());
492 setPeerPort(
d->plainSocket->peerPort());
493 setPeerAddress(
d->plainSocket->peerAddress());
494 setPeerName(
d->plainSocket->peerName());
511 d->plainSocket->setSocketOption(option, value);
527 return d->plainSocket->socketOption(option);
566 return d->connectionEncrypted;
577 return d->configuration.protocol;
588 d->configuration.protocol = protocol;
611 return d->configuration.peerVerifyMode;
637 d->configuration.peerVerifyMode = mode;
659 return d->configuration.peerVerifyDepth;
682 qWarning(
"QSslSocket::setPeerVerifyDepth: cannot set negative depth of %d", depth);
685 d->configuration.peerVerifyDepth = depth;
702 return d->verificationPeerName;
719 d->verificationPeerName = hostName;
734 if (
d->mode == UnencryptedMode)
751 if (
d->mode == UnencryptedMode)
752 return d->plainSocket ?
d->plainSocket->bytesToWrite() : 0;
753 return d->writeBuffer.size();
769 if (
d->mode == UnencryptedMode)
771 return d->plainSocket->bytesAvailable();
786 if (
d->mode == UnencryptedMode)
788 return d->plainSocket->bytesToWrite();
803 if (
d->mode == UnencryptedMode)
813 #ifdef QSSLSOCKET_DEBUG 814 qDebug() <<
"QSslSocket::close()";
818 d->plainSocket->close();
822 d->readBuffer.clear();
823 d->writeBuffer.clear();
836 if (
d->mode == UnencryptedMode)
859 #ifdef QSSLSOCKET_DEBUG 860 qDebug() <<
"QSslSocket::flush()";
862 if (
d->mode != UnencryptedMode)
866 return d->plainSocket ?
d->plainSocket->flush() :
false;
880 d->readBufferMaxSize = size;
883 d->plainSocket->setReadBufferSize(size);
896 #ifdef QSSLSOCKET_DEBUG 897 qDebug() <<
"QSslSocket::abort()";
900 d->plainSocket->abort();
950 d->configuration.privateKey = configuration.
privateKey();
951 d->configuration.ciphers = configuration.
ciphers();
955 d->configuration.protocol = configuration.
protocol();
956 d->configuration.sslOptions = configuration.
d->
sslOptions;
962 d->allowRootCertOnDemandLoading =
false;
980 d->configuration.localCertificate = certificate;
1011 return d->configuration.localCertificate;
1042 return d->configuration.peerCertificate;
1071 return d->configuration.peerCertificateChain;
1091 return d->sessionCipher();
1110 d->configuration.privateKey =
key;
1140 QFile file(fileName);
1155 return d->configuration.privateKey;
1186 return d->configuration.ciphers;
1202 d->configuration.ciphers = ciphers;
1222 d->configuration.ciphers.clear();
1224 for (
int i = 0; i < 3; ++i) {
1228 d->configuration.ciphers << cipher;
1303 d->configuration.caCertificates += certs;
1319 d->configuration.caCertificates += certificate;
1334 d->configuration.caCertificates += certificates;
1352 d->configuration.caCertificates = certificates;
1353 d->allowRootCertOnDemandLoading =
false;
1371 return d->configuration.caCertificates;
1478 if (!
d->plainSocket)
1480 bool retVal =
d->plainSocket->waitForConnected(msecs);
1482 setSocketState(
d->plainSocket->state());
1483 setSocketError(
d->plainSocket->error());
1484 setErrorString(
d->plainSocket->errorString());
1508 if (!
d->plainSocket ||
d->connectionEncrypted)
1510 if (
d->mode == UnencryptedMode && !
d->autoStartHandshake)
1518 if (!
d->plainSocket->waitForConnected(msecs))
1522 while (!
d->connectionEncrypted) {
1524 if (
d->mode == UnencryptedMode)
1525 startClientEncryption();
1531 return d->connectionEncrypted;
1540 if (!
d->plainSocket)
1542 if (
d->mode == UnencryptedMode && !
d->autoStartHandshake)
1543 return d->plainSocket->waitForReadyRead(msecs);
1549 bool readyReadEmitted =
false;
1550 bool *previousReadyReadEmittedPointer =
d->readyReadEmittedPointer;
1551 d->readyReadEmittedPointer = &readyReadEmitted;
1556 if (!
d->connectionEncrypted) {
1558 if (!waitForEncrypted(msecs)) {
1559 d->readyReadEmittedPointer = previousReadyReadEmittedPointer;
1564 if (!
d->writeBuffer.isEmpty()) {
1571 while (!readyReadEmitted &&
1575 d->readyReadEmittedPointer = previousReadyReadEmittedPointer;
1576 return readyReadEmitted;
1585 if (!
d->plainSocket)
1587 if (
d->mode == UnencryptedMode)
1588 return d->plainSocket->waitForBytesWritten(msecs);
1593 if (!
d->connectionEncrypted) {
1595 if (!waitForEncrypted(msecs))
1598 if (!
d->writeBuffer.isEmpty()) {
1618 if (state() == UnconnectedState) {
1619 qWarning(
"QSslSocket::waitForDisconnected() is not allowed in UnconnectedState");
1623 if (!
d->plainSocket)
1625 if (
d->mode == UnencryptedMode)
1626 return d->plainSocket->waitForDisconnected(msecs);
1631 if (!
d->connectionEncrypted) {
1633 if (!waitForEncrypted(msecs))
1638 setSocketState(
d->plainSocket->state());
1639 setSocketError(
d->plainSocket->error());
1640 setErrorString(
d->plainSocket->errorString());
1656 return d->sslErrors;
1685 if (
d->mode != UnencryptedMode) {
1686 qWarning(
"QSslSocket::startClientEncryption: cannot start handshake on non-plain connection");
1689 #ifdef QSSLSOCKET_DEBUG 1690 qDebug() <<
"QSslSocket::startClientEncryption()";
1692 d->mode = SslClientMode;
1693 emit modeChanged(
d->mode);
1694 d->startClientEncryption();
1720 if (
d->mode != UnencryptedMode) {
1721 qWarning(
"QSslSocket::startServerEncryption: cannot start handshake on non-plain connection");
1724 #ifdef QSSLSOCKET_DEBUG 1725 qDebug() <<
"QSslSocket::startServerEncryption()";
1727 d->mode = SslServerMode;
1728 emit modeChanged(
d->mode);
1729 d->startServerEncryption();
1760 d->ignoreAllSslErrors =
true;
1789 d->ignoreErrorsList = errors;
1799 if (!
d->initialized)
1801 d->initialized =
false;
1803 #ifdef QSSLSOCKET_DEBUG 1804 qDebug() <<
"QSslSocket::connectToHostImplementation(" 1805 << hostName <<
',' << port <<
',' << openMode <<
')';
1807 if (!
d->plainSocket) {
1808 #ifdef QSSLSOCKET_DEBUG 1809 qDebug() <<
"\tcreating internal plain socket";
1811 d->createPlainSocket(openMode);
1813 #ifndef QT_NO_NETWORKPROXY 1814 d->plainSocket->setProxy(proxy());
1816 d->plainSocket->setProperty(
"_q_user-agent",
property(
"_q_user-agent"));
1819 d->plainSocket->connectToHost(hostName, port, openMode);
1820 d->cachedSocketDescriptor =
d->plainSocket->socketDescriptor();
1829 #ifdef QSSLSOCKET_DEBUG 1830 qDebug() <<
"QSslSocket::disconnectFromHostImplementation()";
1832 if (!
d->plainSocket)
1834 if (
d->state == UnconnectedState)
1836 if (
d->mode == UnencryptedMode && !
d->autoStartHandshake) {
1837 d->plainSocket->disconnectFromHost();
1840 if (
d->state <= ConnectingState) {
1841 d->pendingClose =
true;
1846 if (
d->state != ClosingState) {
1847 d->state = ClosingState;
1848 emit stateChanged(
d->state);
1851 if (!
d->writeBuffer.isEmpty())
1854 if (
d->mode == UnencryptedMode) {
1855 d->plainSocket->disconnectFromHost();
1857 d->disconnectFromHost();
1869 if (
d->mode == UnencryptedMode && !
d->autoStartHandshake) {
1870 readBytes =
d->plainSocket->read(data, maxlen);
1873 const char *readPtr =
d->readBuffer.readPointer();
1874 int bytesToRead = qMin<int>(maxlen - readBytes,
d->readBuffer.nextDataBlockSize());
1875 ::memcpy(data + readBytes, readPtr, bytesToRead);
1876 readBytes += bytesToRead;
1877 d->readBuffer.free(bytesToRead);
1878 }
while (!
d->readBuffer.isEmpty() && readBytes < maxlen);
1880 #ifdef QSSLSOCKET_DEBUG 1881 qDebug() <<
"QSslSocket::readData(" << (
void *)data <<
',' << maxlen <<
") ==" << readBytes;
1885 if (
d->readBuffer.isEmpty() &&
d->plainSocket->bytesAvailable())
1897 #ifdef QSSLSOCKET_DEBUG 1898 qDebug() <<
"QSslSocket::writeData(" << (
void *)data <<
',' << len <<
')';
1900 if (
d->mode == UnencryptedMode && !
d->autoStartHandshake)
1901 return d->plainSocket->write(data, len);
1903 char *writePtr =
d->writeBuffer.reserve(len);
1904 ::memcpy(writePtr, data, len);
1916 : initialized(false)
1918 , autoStartHandshake(false)
1919 , connectionEncrypted(false)
1921 , ignoreAllSslErrors(false)
1922 , readyReadEmittedPointer(0)
1923 , allowRootCertOnDemandLoading(true)
1963 return globalData()->config->ciphers;
1973 return globalData()->supportedCiphers;
1982 globalData()->config.detach();
1983 globalData()->config->ciphers = ciphers;
1992 globalData()->config.detach();
1993 globalData()->supportedCiphers = ciphers;
2004 return globalData()->config->caCertificates;
2014 globalData()->config.detach();
2015 globalData()->config->caCertificates = certs;
2033 globalData()->config.detach();
2034 globalData()->config->caCertificates += certs;
2045 globalData()->config.detach();
2046 globalData()->config->caCertificates += cert;
2056 globalData()->config.detach();
2057 globalData()->config->caCertificates += certs;
2077 if (globalData()->config == configuration.
d)
2117 q->setOpenMode(openMode);
2127 #ifndef QT_NO_BEARERMANAGEMENT 2152 #ifndef QT_NO_NETWORKPROXY 2168 if (!socket->d_func()->plainSocket)
2175 if (!socket->d_func()->plainSocket)
2193 #ifdef QSSLSOCKET_DEBUG 2194 qDebug() <<
"QSslSocket::_q_connectedSlot()";
2195 qDebug() <<
"\tstate =" << q->state();
2196 qDebug() <<
"\tpeer =" << q->peerName() << q->peerAddress() << q->peerPort();
2198 << q->localAddress() << q->localPort();
2200 emit q->connected();
2203 q->startClientEncryption();
2206 q->disconnectFromHost();
2216 #ifdef QSSLSOCKET_DEBUG 2217 qDebug() <<
"QSslSocket::_q_hostFoundSlot()";
2218 qDebug() <<
"\tstate =" << q->state();
2220 emit q->hostFound();
2229 #ifdef QSSLSOCKET_DEBUG 2230 qDebug() <<
"QSslSocket::_q_disconnectedSlot()";
2231 qDebug() <<
"\tstate =" << q->state();
2234 emit q->disconnected();
2243 #ifdef QSSLSOCKET_DEBUG 2244 qDebug() <<
"QSslSocket::_q_stateChangedSlot(" << state <<
')';
2246 q->setSocketState(state);
2247 emit q->stateChanged(state);
2256 #ifdef QSSLSOCKET_DEBUG 2257 qDebug() <<
"QSslSocket::_q_errorSlot(" << error <<
')';
2258 qDebug() <<
"\tstate =" << q->state();
2259 qDebug() <<
"\terrorString =" << q->errorString();
2263 emit q->error(error);
2272 #ifdef QSSLSOCKET_DEBUG 2278 emit q->readyRead();
2291 #ifdef QSSLSOCKET_DEBUG 2292 qDebug() <<
"QSslSocket::_q_bytesWrittenSlot(" << written <<
')';
2296 emit q->bytesWritten(written);
2298 emit q->encryptedBytesWritten(written);
2300 q->disconnectFromHost();
2339 return (r > 0 ? r : r2);
2361 if (ret.
length() == maxSize)
2388 <<
"/usr/lib/ssl/certs/" 2389 <<
"/usr/share/ssl/" 2390 <<
"/usr/local/ssl/" 2391 <<
"/var/ssl/certs/" 2392 <<
"/usr/local/ssl/certs/" 2393 <<
"/etc/openssl/certs/" 2394 <<
"/opt/openssl/certs/";
2401 #include "moc_qsslsocket.cpp" The QVariant class acts like a union for the most common Qt data types.
static bool addDefaultCaCertificates(const QString &path, QSsl::EncodingFormat format, QRegExp::PatternSyntax syntax)
QString peerName() const
Returns the name of the peer as specified by connectToHost(), or an empty QString if connectToHost() ...
int cachedSocketDescriptor
int socketDescriptor() const
Returns the native socket descriptor of the QAbstractSocket object if this is available; otherwise re...
The QSslKey class provides an interface for private and public keys.
QSharedDataPointer< QSslConfigurationPrivate > d
static double elapsed(qint64 after, qint64 before)
#define QT_END_NAMESPACE
This macro expands to.
QList< QSslError > sslErrors() const
Returns a list of the last SSL errors that occurred.
The QMutex class provides access serialization between threads.
void startServerEncryption()
Starts a delayed SSL handshake for a server connection.
QList< QSslCipher > ciphers() const
Returns this connection's current cryptographic cipher suite.
char * data()
Returns a pointer to the data stored in the byte array.
QIODevice::OpenMode openMode
void startClientEncryption()
Starts a delayed SSL handshake for a client connection.
QHostAddress localAddress() const
Returns the host address of the local socket if available; otherwise returns QHostAddress::Null.
static void resumeSocketNotifiers(QSslSocket *)
static void setDefaultSupportedCiphers(const QList< QSslCipher > &ciphers)
qint64 bytesAvailable() const
Returns the number of incoming bytes that are waiting to be read.
void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator)
SslMode mode() const
Returns the current mode for the socket; either UnencryptedMode, where QSslSocket behaves identially ...
bool setSocketDescriptor(int socketDescriptor, SocketState state=ConnectedState, OpenMode openMode=ReadWrite)
Initializes QSslSocket with the native socket descriptor socketDescriptor.
bool open(OpenMode flags)
Opens the file using OpenMode mode, returning true if successful; otherwise false.
static QList< QByteArray > unixRootCertDirectories()
QSsl::SslOptions sslOptions
void createPlainSocket(QIODevice::OpenMode openMode)
QSslConfiguration sslConfiguration() const
Returns the socket's SSL configuration state.
void ignoreSslErrors()
This slot tells QSslSocket to ignore errors during QSslSocket's handshake phase and continue connecti...
virtual qint64 peek(char *data, qint64 maxSize)
~QSslSocket()
Destroys the QSslSocket.
static bool addDefaultCaCertificates(const QString &path, QSsl::EncodingFormat format=QSsl::Pem, QRegExp::PatternSyntax syntax=QRegExp::FixedString)
Searches all files in the path for certificates with the specified encoding and adds them to the defa...
qint64 encryptedBytesToWrite() const
Returns the number of encrypted bytes that are waiting to be written to the network.
QList< QSslCipher > ciphers
QSslCertificate localCertificate() const
Returns the socket's local QSslCertificate {certificate}, or an empty certificate if no local certifi...
The QByteArray class provides an array of bytes.
SocketOption
This enum represents the options that can be set on a socket.
QString errorString() const
Returns a human-readable description of the last device error that occurred.
QIODevicePrivateLinearBuffer buffer
The QSslSocket class provides an SSL encrypted socket for both clients and servers.
static void addDefaultCaCertificate(const QSslCertificate &certificate)
Adds certificate to the default CA certificate database.
static void resumeSocketNotifiers(QAbstractSocket *)
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object's name property to value.
QSsl::SslProtocol protocol() const
Returns the socket's SSL protocol.
void setSslConfiguration(const QSslConfiguration &config)
Sets the socket's SSL configuration to be the contents of configuration.
static void setDefaultCaCertificates(const QList< QSslCertificate > &certificates)
Sets the default CA certificate database to certificates.
quint16 peerPort() const
Returns the port of the connected peer if the socket is in ConnectedState; otherwise returns 0...
void abort()
Aborts the current connection and resets the socket.
static void addDefaultCaCertificate(const QSslCertificate &cert)
static QList< QSslCertificate > defaultCaCertificates()
Returns the current default CA certificate database.
void _q_stateChangedSlot(QAbstractSocket::SocketState)
The QString class provides a Unicode character string.
static QList< QSslCertificate > defaultCaCertificates()
The QObject class is the base class of all Qt objects.
The QElapsedTimer class provides a fast way to calculate elapsed times.
virtual bool atEnd() const
Returns true if the current read and write position is at the end of the device (i.e.
QVariant socketOption(QAbstractSocket::SocketOption option)
Returns the value of the option option.
static bool s_loadRootCertsOnDemand
QSsl::SslProtocol protocol
void setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value)
Sets the given option to the value described by value.
void _q_bytesWrittenSlot(qint64)
The QSslCipher class represents an SSL cryptographic cipher.
qint64 elapsed() const
Returns the number of milliseconds since this QElapsedTimer was last started.
bool waitForBytesWritten(int msecs=30000)
Reimplemented Function
static void deepCopyDefaultConfiguration(QSslConfigurationPrivate *config)
qint64 encryptedBytesAvailable() const
Returns the number of encrypted bytes that are awaiting decryption.
static bool supportsSsl()
Returns true if this platform supports SSL; otherwise, returns false.
bool waitForDisconnected(int msecs=30000)
Waits until the socket has disconnected or msecs milliseconds, whichever comes first.
qint64 readData(char *data, qint64 maxlen)
Reimplemented Function
bool waitForConnected(int msecs=30000)
Waits until the socket is connected, or msecs milliseconds, whichever happens first.
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
void disconnectFromHostImplementation()
qint64 writeData(const char *data, qint64 len)
Reimplemented Function
QSsl::SslProtocol protocol() const
Returns the protocol setting for this SSL configuration.
void _q_disconnectedSlot()
SocketState
This enum describes the different states in which a socket can be.
void setProtocol(QSsl::SslProtocol protocol)
Sets the socket's SSL protocol to protocol.
Q_CORE_EXPORT void qDebug(const char *,...)
void addCaCertificate(const QSslCertificate &certificate)
Adds the certificate to this socket's CA certificate database.
void connectToHostImplementation(const QString &hostName, quint16 port, OpenMode openMode)
static void setDefaultCiphers(const QList< QSslCipher > &ciphers)
QAbstractSocket::SocketState state
The QNetworkProxy class provides a network layer proxy.
QList< QSslCertificate > caCertificates
void setPeerVerifyName(const QString &hostName)
Sets a different host name, given by hostName, for the certificate validation instead of the one used...
#define QT_BEGIN_NAMESPACE
This macro expands to.
static QIntfbScreen * connected
virtual void transmit()=0
QList< QSslCipher > ciphers() const
Returns this socket's current cryptographic cipher suite.
SslProtocol
Describes the protocol of the cipher.
SslMode
Describes the connection modes available for QSslSocket.
int peerVerifyDepth() const
Returns the maximum number of certificates in the peer's certificate chain to be checked during the S...
static QSslConfiguration defaultConfiguration()
QList< QSslCertificate > peerCertificateChain() const
Returns the peer's chain of digital certificates, or an empty list of certificates.
void setPeerVerifyDepth(int depth)
Sets the maximum number of certificates in the peer's certificate chain to be checked during the SSL ...
#define Q_GLOBAL_STATIC(TYPE, NAME)
Declares a global static variable with the given type and name.
qint64 bytesAvailable() const
Returns the number of decrypted bytes that are immediately available for reading. ...
SocketError
This enum describes the socket errors that can occur.
void connectToHostEncrypted(const QString &hostName, quint16 port, OpenMode mode=ReadWrite)
Starts an encrypted connection to the device hostName on port, using mode as the OpenMode ...
static void setDefaultCaCertificates(const QList< QSslCertificate > &certs)
qint64 peek(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, without side effects (i.
QSslSocket::PeerVerifyMode peerVerifyMode
QString peerVerifyName() const
Returns the different hostname for the certificate validation, as set by setPeerVerifyName or by conn...
Q_CORE_EXPORT void qWarning(const char *,...)
const T * constData() const
Returns a const pointer to the shared data object.
static const char * data(const QByteArray &arr)
QSslCertificate peerCertificate() const
Returns the peer's digital certificate (i.e., the immediate certificate of the host you are connected...
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
static int qt_timeout_value(int msecs, int elapsed)
The QTcpSocket class provides a TCP socket.
static QList< QSslCipher > supportedCiphers()
Returns the list of cryptographic ciphers supported by this system.
int peek(char *target, int size)
const T * ptr(const T &t)
void clear()
Removes all items from the list.
static void setDefaultConfiguration(const QSslConfiguration &configuration)
QList< QSslCertificate > caCertificates() const
Returns this socket's CA certificate database.
static QList< QSslCipher > defaultCiphers()
Returns the default cryptographic cipher suite for all sockets in this application.
void close()
Reimplemented Function
void _q_flushReadBuffer()
static bool supportsSsl()
Does the minimum amount of initialization to determine whether SSL is supported or not...
void setLocalCertificate(const QSslCertificate &certificate)
Sets the socket's local certificate to certificate.
void setPrivateKey(const QSslKey &key)
Sets the socket's private QSslKey {key} to key.
bool isEncrypted() const
Returns true if the socket is encrypted; otherwise, false is returned.
void close()
Closes the I/O device for the socket, disconnects the socket's connection with the host...
The QAuthenticator class provides an authentication object.
QSslKey privateKey() const
Returns the QSslKey {SSL key} assigned to this connection or a null key if none has been assigned yet...
static QList< QSslCertificate > systemCaCertificates()
This function provides the CA certificate database provided by the operating system.
QSslConfigurationPrivate configuration
int length() const
Same as size().
QSslCertificate localCertificate
QSslCipher sessionCipher() const
Returns the socket's cryptographic QSslCipher {cipher}, or a null cipher if the connection isn't encr...
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
static QHostInfo fromName(const QString &name)
Looks up the IP address(es) for the given host name.
PatternSyntax
The syntax used to interpret the meaning of the pattern.
The QFile class provides an interface for reading from and writing to files.
EncodingFormat
Describes supported encoding formats for certificates and keys.
void setCaCertificates(const QList< QSslCertificate > &certificates)
Sets this socket's CA certificate database to be certificates.
bool addCaCertificates(const QString &path, QSsl::EncodingFormat format=QSsl::Pem, QRegExp::PatternSyntax syntax=QRegExp::FixedString)
Searches all files in the path for certificates encoded in the specified format and adds them to this...
quint16 localPort() const
Returns the host port number (in native byte order) of the local socket if available; otherwise retur...
bool flush()
This function writes as much as possible from the internal write buffer to the underlying network soc...
virtual void disconnected()=0
bool allowRootCertOnDemandLoading
QExplicitlySharedDataPointer< QSslConfigurationPrivate > config
static QList< QSslCertificate > systemCaCertificates()
int peerVerifyDepth() const
Returns the maximum number of certificates in the peer's certificate chain to be checked during the S...
bool isNull() const
Returns true if this is a null cipher; otherwise returns false.
QSslCertificate localCertificate() const
Returns the certificate to be presented to the peer during the SSL handshake process.
QSslKey privateKey() const
Returns this socket's private key.
void resize(int size)
Sets the size of the byte array to size bytes.
void _q_flushWriteBuffer()
virtual qint64 bytesAvailable() const
Returns the number of bytes that are available for reading.
bool waitForReadyRead(int msecs=30000)
Reimplemented Function
QByteArray readAll()
Reads all available data from the device, and returns it as a QByteArray.
bool canReadLine() const
Returns true if you can read one while line (terminated by a single ASCII ' ' character) of decrypted...
static QList< QSslCertificate > fromPath(const QString &path, QSsl::EncodingFormat format=QSsl::Pem, QRegExp::PatternSyntax syntax=QRegExp::FixedString)
Searches all files in the path for certificates encoded in the specified format and returns them in a...
QHostAddress peerAddress() const
Returns the address of the connected peer if the socket is in ConnectedState; otherwise returns QHost...
void _q_errorSlot(QAbstractSocket::SocketError)
bool * readyReadEmittedPointer
virtual bool open(OpenMode mode)
Opens the device and sets its OpenMode to mode.
virtual ~QSslSocketPrivate()
static void ensureInitialized()
Declared static in QSslSocketPrivate, makes sure the SSL libraries have been initialized.
bool waitForEncrypted(int msecs=30000)
Waits until the socket has completed the SSL handshake and has emitted encrypted(), or msecs milliseconds, whichever comes first.
KeyAlgorithm
Describes the different key algorithms supported by QSslKey.
The QSslCertificate class provides a convenient API for an X509 certificate.
bool atEnd() const
Reimplemented Function
The QSslConfiguration class holds the configuration and state of an SSL connection.
static QList< QSslCipher > supportedCiphers()
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
QSslSocket::PeerVerifyMode peerVerifyMode() const
Returns the verify mode.
QList< QSslCertificate > caCertificates() const
Returns this connection's CA certificate database.
void clear()
Clears the contents of this certificate, making it a null certificate.
static QList< QSslCipher > defaultCiphers()
virtual bool canReadLine() const
Returns true if a complete line of data can be read from the device; otherwise returns false...
The QHostAddress class provides an IP address.
QSslCertificate peerCertificate
QList< QSslCertificate > peerCertificateChain
static void pauseSocketNotifiers(QAbstractSocket *)
void setPeerVerifyMode(QSslSocket::PeerVerifyMode mode)
Sets the socket's verify mode to mode.
qint64 bytesToWrite() const
Returns the number of unencrypted bytes that are waiting to be encrypted and written to the network...
SocketError error() const
Returns the type of error that last occurred.
void reserve(int size)
Attempts to allocate memory for at least size bytes.
void setReadBufferSize(qint64 size)
Sets the size of QSslSocket's internal read buffer to be size bytes.
static void setDefaultCiphers(const QList< QSslCipher > &ciphers)
Sets the default cryptographic cipher suite for all sockets in this application to ciphers...
static QString fileName(const QString &fileUrl)
void start()
Starts this timer.
static void pauseSocketNotifiers(QSslSocket *)
QList< QSslCipher > supportedCiphers
void setCiphers(const QList< QSslCipher > &ciphers)
Sets the cryptographic cipher suite for this socket to ciphers, which must contain a subset of the ci...
QSslSocket::PeerVerifyMode peerVerifyMode() const
Returns the socket's verify mode.
virtual qint64 peek(char *data, qint64 maxSize)
static Q_AUTOTEST_EXPORT bool rootCertOnDemandLoadingSupported()
PeerVerifyMode
Describes the peer verification modes for QSslSocket.