QSslConfiguration Class

The QSslConfiguration class holds the configuration and state of an SSL connection. More...

Header: #include <QSslConfiguration>
qmake: QT += network
Since: Qt 4.4

This class was introduced in Qt 4.4.

Note: All functions in this class are reentrant.

Public Types

enum NextProtocolNegotiationStatus { NextProtocolNegotiationNone, NextProtocolNegotiationNegotiated, NextProtocolNegotiationUnsupported }

Static Public Members

const char[] NextProtocolHttp1_1
const char[] NextProtocolSpdy3_0

Detailed Description

QSslConfiguration is used by Qt networking classes to relay information about an open SSL connection and to allow the application to control certain features of that connection.

The settings that QSslConfiguration currently supports are:

  • The SSL/TLS protocol to be used
  • The certificate to be presented to the peer during connection and its associated private key
  • The ciphers allowed to be used for encrypting the connection
  • The list of Certificate Authorities certificates that are used to validate the peer's certificate

These settings are applied only during the connection handshake. Setting them after the connection has been established has no effect.

The state that QSslConfiguration supports are:

  • The certificate the peer presented during handshake, along with the chain leading to a CA certificate
  • The cipher used to encrypt this session

The state can only be obtained once the SSL connection starts, but not necessarily before it's done. Some settings may change during the course of the SSL connection without need to restart it (for instance, the cipher can be changed over time).

State in QSslConfiguration objects cannot be changed.

QSslConfiguration can be used with QSslSocket and the Network Access API.

Note that changing settings in QSslConfiguration is not enough to change the settings in the related SSL connection. You must call setSslConfiguration on a modified QSslConfiguration object to achieve that. The following example illustrates how to change the protocol to TLSv1_0 in a QSslSocket object:

 QSslConfiguration config = sslSocket.sslConfiguration();
 config.setProtocol(QSsl::TlsV1_0);
 sslSocket.setSslConfiguration(config);

See also QSsl::SslProtocol, QSslCertificate, QSslCipher, QSslKey, QSslSocket, QNetworkAccessManager, QSslSocket::sslConfiguration(), and QSslSocket::setSslConfiguration().

Member Type Documentation

enum QSslConfiguration::NextProtocolNegotiationStatus

Describes the status of the Next Protocol Negotiation (NPN) or Application-Layer Protocol Negotiation (ALPN).

ConstantValueDescription
QSslConfiguration::NextProtocolNegotiationNone0No application protocol has been negotiated (yet).
QSslConfiguration::NextProtocolNegotiationNegotiated1A next protocol has been negotiated (see nextNegotiatedProtocol()).
QSslConfiguration::NextProtocolNegotiationUnsupported2The client and server could not agree on a common next application protocol.

Member Variable Documentation

const char[] QSslConfiguration::NextProtocolHttp1_1

This variable holds the value used for negotiating HTTP 1.1 during the Next Protocol Negotiation.

const char[] QSslConfiguration::NextProtocolSpdy3_0

This variable holds the value used for negotiating SPDY 3.0 during the Next Protocol Negotiation.