QSslConfiguration 類

QSslConfiguration 類保持 SSL (安全套接字層) 連接的配置和狀態。 更多...

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

該類在 Qt 4.4 引入。

注意: 此類的所有函數 可重入 .

公共類型

enum NextProtocolNegotiationStatus { NextProtocolNegotiationNone, NextProtocolNegotiationNegotiated, NextProtocolNegotiationUnsupported }

公共函數

QSslConfiguration (const QSslConfiguration & other )
QSslConfiguration ()
QSslConfiguration & operator= (const QSslConfiguration & other )
~QSslConfiguration ()
void addCaCertificate (const QSslCertificate & certificate )
bool addCaCertificates (const QString & path , QSsl::EncodingFormat format = QSsl::Pem, QSslCertificate::PatternSyntax syntax = QSslCertificate::PatternSyntax::FixedString)
void addCaCertificates (const QList<QSslCertificate> & certificates )
QList<QByteArray> allowedNextProtocols () const
QMap<QByteArray, QVariant> backendConfiguration () const
QList<QSslCertificate> caCertificates () const
QList<QSslCipher> ciphers () const
QSslDiffieHellmanParameters diffieHellmanParameters () const
bool dtlsCookieVerificationEnabled () const
QVector<QSslEllipticCurve> ellipticCurves () const
QSslKey ephemeralServerKey () const
bool isNull () const
QSslCertificate localCertificate () const
QList<QSslCertificate> localCertificateChain () const
QByteArray nextNegotiatedProtocol () const
QSslConfiguration::NextProtocolNegotiationStatus nextProtocolNegotiationStatus () const
bool ocspStaplingEnabled () const
QSslCertificate peerCertificate () const
QList<QSslCertificate> peerCertificateChain () const
int peerVerifyDepth () const
QSslSocket::PeerVerifyMode peerVerifyMode () const
QByteArray preSharedKeyIdentityHint () const
QSslKey privateKey () const
QSsl::SslProtocol protocol () const
QSslCipher sessionCipher () const
QSsl::SslProtocol sessionProtocol () const
QByteArray sessionTicket () const
int sessionTicketLifeTimeHint () const
void setAllowedNextProtocols (QList<QByteArray> protocols )
void setBackendConfiguration (const QMap<QByteArray, QVariant> & backendConfiguration = QMap<QByteArray, QVariant>())
void setBackendConfigurationOption (const QByteArray & name , const QVariant & value )
void setCaCertificates (const QList<QSslCertificate> & certificates )
void setCiphers (const QList<QSslCipher> & ciphers )
void setDiffieHellmanParameters (const QSslDiffieHellmanParameters & dhparams )
void setDtlsCookieVerificationEnabled (bool enable )
void setEllipticCurves (const QVector<QSslEllipticCurve> & curves )
void setLocalCertificate (const QSslCertificate & certificate )
void setLocalCertificateChain (const QList<QSslCertificate> & localChain )
void setOcspStaplingEnabled (bool enabled )
void setPeerVerifyDepth (int depth )
void setPeerVerifyMode (QSslSocket::PeerVerifyMode mode )
void setPreSharedKeyIdentityHint (const QByteArray & hint )
void setPrivateKey (const QSslKey & key )
void setProtocol (QSsl::SslProtocol protocol )
void setSessionTicket (const QByteArray & sessionTicket )
void setSslOption (QSsl::SslOption option , bool on )
void swap (QSslConfiguration & other )
bool testSslOption (QSsl::SslOption option ) const
bool operator!= (const QSslConfiguration & other ) const
bool operator== (const QSslConfiguration & other ) const

靜態公共成員

const char [] NextProtocolHttp1_1
const char [] NextProtocolSpdy3_0
QSslConfiguration defaultConfiguration ()
QSslConfiguration defaultDtlsConfiguration ()
void setDefaultConfiguration (const QSslConfiguration & configuration )
void setDefaultDtlsConfiguration (const QSslConfiguration & configuration )
QList<QSslCipher> supportedCiphers ()
QVector<QSslEllipticCurve> supportedEllipticCurves ()
QList<QSslCertificate> systemCaCertificates ()

詳細描述

QSslConfiguration 用於 Qt 網絡類以中繼有關打開 SSL 連接的信息,並允許應用程序控製該連接的某些特徵。

QSslConfiguration 目前支持的設置包括:

  • 要使用的 SSL (安全套接字層)/TLS (傳輸層安全) 協議
  • 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 對象:

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

另請參閱 QSsl::SslProtocol , QSslCertificate , QSslCipher , QSslKey , QSslSocket , QNetworkAccessManager , QSslSocket::sslConfiguration (),和 QSslSocket::setSslConfiguration ().

成員類型文檔編製

enum QSslConfiguration:: NextProtocolNegotiationStatus

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

常量 描述
QSslConfiguration::NextProtocolNegotiationNone 0 No application protocol has been negotiated (yet).
QSslConfiguration::NextProtocolNegotiationNegotiated 1 A next protocol has been negotiated (see nextNegotiatedProtocol ()).
QSslConfiguration::NextProtocolNegotiationUnsupported 2 The client and server could not agree on a common next application protocol.

成員函數文檔編製

QSslConfiguration:: QSslConfiguration (const QSslConfiguration & other )

Copies the configuration and state of other 。若 other is null, this object will be null too.

QSslConfiguration:: QSslConfiguration ()

Constructs an empty SSL configuration. This configuration contains no valid settings and the state will be empty. isNull () will return true after this constructor is called.

Once any setter methods are called, isNull () 將返迴 false。

QSslConfiguration &QSslConfiguration:: operator= (const QSslConfiguration & other )

Copies the configuration and state of other 。若 other is null, this object will be null too.

QSslConfiguration:: ~QSslConfiguration ()

Releases any resources held by QSslConfiguration .

void QSslConfiguration:: addCaCertificate (const QSslCertificate & certificate )

添加 certificate to this configuration's CA certificate database. The certificate database must be set prior to the SSL handshake. The CA certificate database is used by the socket during the handshake phase to validate the peer's certificate.

注意: The default configuration uses the system CA certificate database. If that is not available (as is commonly the case on iOS), the default database is empty.

該函數在 Qt 5.15 引入。

另請參閱 caCertificates (), setCaCertificates (),和 addCaCertificates ().

bool QSslConfiguration:: addCaCertificates (const QString & path , QSsl::EncodingFormat format = QSsl::Pem, QSslCertificate::PatternSyntax syntax = QSslCertificate::PatternSyntax::FixedString)

Searches all files in the path for certificates encoded in the specified format and adds them to this socket's CA certificate database. path must be a file or a pattern matching one or more files, as specified by syntax 。返迴 true if one or more certificates are added to the socket's CA certificate database; otherwise returns false .

The CA certificate database is used by the socket during the handshake phase to validate the peer's certificate.

對於更準確控製,使用 addCaCertificate ().

該函數在 Qt 5.15 引入。

另請參閱 addCaCertificate () 和 QSslCertificate::fromPath ().

void QSslConfiguration:: addCaCertificates (const QList < QSslCertificate > & certificates )

添加 certificates to this configuration's CA certificate database. The certificate database must be set prior to the SSL handshake. The CA certificate database is used by the socket during the handshake phase to validate the peer's certificate.

注意: The default configuration uses the system CA certificate database. If that is not available (as is commonly the case on iOS), the default database is empty.

該函數在 Qt 5.15 引入。

另請參閱 caCertificates (), setCaCertificates (),和 addCaCertificate ().

QList < QByteArray > QSslConfiguration:: allowedNextProtocols () const

This function returns the allowed protocols to be negotiated with the server through the Next Protocol Negotiation (NPN) or Application-Layer Protocol Negotiation (ALPN) TLS extension, as set by setAllowedNextProtocols ().

該函數在 Qt 5.3 引入。

另請參閱 nextNegotiatedProtocol (), nextProtocolNegotiationStatus (), setAllowedNextProtocols (), QSslConfiguration::NextProtocolSpdy3_0 ,和 QSslConfiguration::NextProtocolHttp1_1 .

QMap < QByteArray , QVariant > QSslConfiguration:: backendConfiguration () const

Returns the backend-specific configuration.

Only options set by setBackendConfigurationOption () 或 setBackendConfiguration () will be returned. The internal standard configuration of the backend is not reported.

該函數在 Qt 5.11 引入。

另請參閱 setBackendConfigurationOption () 和 setBackendConfiguration ().

QList < QSslCertificate > QSslConfiguration:: caCertificates () const

Returns this connection's CA certificate database. The CA certificate database is used by the socket during the handshake phase to validate the peer's certificate. It can be modified prior to the handshake with setCaCertificates (), or with addCaCertificate () 和 addCaCertificates ().

另請參閱 setCaCertificates (), addCaCertificate (),和 addCaCertificates ().

QList < QSslCipher > QSslConfiguration:: ciphers () const

Returns this connection's current cryptographic cipher suite. This list is used during the handshake phase for choosing a session cipher. The returned list of ciphers is ordered by descending preference. (i.e., the first cipher in the list is the most preferred cipher). The session cipher will be the first one in the list that is also supported by the peer.

By default, the handshake phase can choose any of the ciphers supported by this system's SSL libraries, which may vary from system to system. The list of ciphers supported by this system's SSL libraries is returned by QSslSocket::supportedCiphers(). You can restrict the list of ciphers used for choosing the session cipher for this socket by calling setCiphers () with a subset of the supported ciphers. You can revert to using the entire set by calling setCiphers () with the list returned by QSslSocket::supportedCiphers().

注意: This is not currently supported in the Schannel backend.

另請參閱 setCiphers () 和 QSslSocket::supportedCiphers ().

[static] QSslConfiguration QSslConfiguration:: defaultConfiguration ()

Returns the default SSL configuration to be used in new SSL connections.

The default SSL configuration consists of:

  • no local certificate and no private key
  • protocol SecureProtocols
  • the system's default CA certificate list
  • the cipher list equal to the list of the SSL libraries' supported SSL ciphers that are 128 bits or more

另請參閱 QSslSocket::supportedCiphers () 和 setDefaultConfiguration ().

[static] QSslConfiguration QSslConfiguration:: defaultDtlsConfiguration ()

Returns the default DTLS configuration to be used in new DTLS connections.

The default DTLS configuration consists of:

  • no local certificate and no private key
  • protocol DtlsV1_2OrLater
  • the system's default CA certificate list
  • the cipher list equal to the list of the SSL libraries' supported TLS 1.2 ciphers that use 128 or more secret bits for the cipher.

另請參閱 setDefaultDtlsConfiguration ().

QSslDiffieHellmanParameters QSslConfiguration:: diffieHellmanParameters () const

Retrieves the current set of Diffie-Hellman parameters.

If no Diffie-Hellman parameters have been set, the QSslConfiguration object defaults to using the 2048-bit MODP group from RFC 3526.

注意: The default parameters may change in future Qt versions. Please check the documentation of the exact Qt version that you are using in order to know what defaults that version uses.

該函數在 Qt 5.8 引入。

另請參閱 setDiffieHellmanParameters ().

bool QSslConfiguration:: dtlsCookieVerificationEnabled () const

This function returns true if DTLS cookie verification was enabled on a server-side socket.

另請參閱 setDtlsCookieVerificationEnabled ().

QVector < QSslEllipticCurve > QSslConfiguration:: ellipticCurves () const

Returns this connection's current list of elliptic curves. This list is used during the handshake phase for choosing an elliptic curve (when using an elliptic curve cipher). The returned list of curves is ordered by descending preference (i.e., the first curve in the list is the most preferred one).

By default, the handshake phase can choose any of the curves supported by this system's SSL libraries, which may vary from system to system. The list of curves supported by this system's SSL libraries is returned by QSslSocket::supportedEllipticCurves().

You can restrict the list of curves used for choosing the session cipher for this socket by calling setEllipticCurves () with a subset of the supported ciphers. You can revert to using the entire set by calling setEllipticCurves () with the list returned by QSslSocket::supportedEllipticCurves().

該函數在 Qt 5.5 引入。

另請參閱 setEllipticCurves .

QSslKey QSslConfiguration:: ephemeralServerKey () const

Returns the ephemeral server key used for cipher algorithms with forward secrecy, e.g. DHE-RSA-AES128-SHA.

The ephemeral key is only available when running in client mode, i.e. QSslSocket::SslClientMode . When running in server mode or using a cipher algorithm without forward secrecy a null key is returned. The ephemeral server key will be set before emitting the encrypted() signal.

該函數在 Qt 5.7 引入。

bool QSslConfiguration:: isNull () const

返迴 true if this is a null QSslConfiguration 對象。

A QSslConfiguration object is null if it has been default-constructed and no setter methods have been called.

另請參閱 setProtocol (), setLocalCertificate (), setPrivateKey (), setCiphers (),和 setCaCertificates ().

QSslCertificate QSslConfiguration:: localCertificate () const

Returns the certificate to be presented to the peer during the SSL handshake process.

另請參閱 setLocalCertificate ().

QList < QSslCertificate > QSslConfiguration:: localCertificateChain () const

Returns the certificate chain to be presented to the peer during the SSL handshake process.

該函數在 Qt 5.1 引入。

另請參閱 setLocalCertificateChain () 和 localCertificate ().

QByteArray QSslConfiguration:: nextNegotiatedProtocol () const

This function returns the protocol negotiated with the server if the Next Protocol Negotiation (NPN) or Application-Layer Protocol Negotiation (ALPN) TLS extension was enabled. In order for the NPN/ALPN extension to be enabled, setAllowedNextProtocols () needs to be called explicitly before connecting to the server.

If no protocol could be negotiated or the extension was not enabled, this function returns a QByteArray which is null.

該函數在 Qt 5.3 引入。

另請參閱 setAllowedNextProtocols () 和 nextProtocolNegotiationStatus ().

QSslConfiguration::NextProtocolNegotiationStatus QSslConfiguration:: nextProtocolNegotiationStatus () const

This function returns the status of the Next Protocol Negotiation (NPN) or Application-Layer Protocol Negotiation (ALPN). If the feature has not been enabled through setAllowedNextProtocols (), this function returns NextProtocolNegotiationNone . The status will be set before emitting the encrypted() signal.

該函數在 Qt 5.3 引入。

另請參閱 setAllowedNextProtocols (), allowedNextProtocols (), nextNegotiatedProtocol (),和 QSslConfiguration::NextProtocolNegotiationStatus .

bool QSslConfiguration:: ocspStaplingEnabled () const

Returns true if OCSP stapling was enabled by setOCSPStaplingEnabled(), otherwise false (which is the default value).

該函數在 Qt 5.13 引入。

另請參閱 setOcspStaplingEnabled ().

QSslCertificate QSslConfiguration:: peerCertificate () const

Returns the peer's digital certificate (i.e., the immediate certificate of the host you are connected to), or a null certificate, if the peer has not assigned a certificate.

The peer certificate is checked automatically during the handshake phase, so this function is normally used to fetch the certificate for display or for connection diagnostic purposes. It contains information about the peer, including its host name, the certificate issuer, and the peer's public key.

Because the peer certificate is set during the handshake phase, it is safe to access the peer certificate from a slot connected to the QSslSocket::sslErrors() signal, QNetworkReply::sslErrors () signal, or the QSslSocket::encrypted () 信號。

If a null certificate is returned, it can mean the SSL handshake failed, or it can mean the host you are connected to doesn't have a certificate, or it can mean there is no connection.

若想要校驗對等方完整證書鏈,使用 peerCertificateChain () 以一次獲取它們所有。

另請參閱 peerCertificateChain (), QSslSocket::sslErrors (), QSslSocket::ignoreSslErrors (), QNetworkReply::sslErrors (),和 QNetworkReply::ignoreSslErrors ().

QList < QSslCertificate > QSslConfiguration:: peerCertificateChain () const

Returns the peer's chain of digital certificates, starting with the peer's immediate certificate and ending with the CA's certificate.

Peer certificates are checked automatically during the handshake phase. This function is normally used to fetch certificates for display, or for performing connection diagnostics. Certificates contain information about the peer and the certificate issuers, including host name, issuer names, and issuer public keys.

Because the peer certificate is set during the handshake phase, it is safe to access the peer certificate from a slot connected to the QSslSocket::sslErrors() signal, QNetworkReply::sslErrors () signal, or the QSslSocket::encrypted () 信號。

If an empty list is returned, it can mean the SSL handshake failed, or it can mean the host you are connected to doesn't have a certificate, or it can mean there is no connection.

若隻想獲得對等方即時證書,使用 peerCertificate ().

另請參閱 peerCertificate (), QSslSocket::sslErrors (), QSslSocket::ignoreSslErrors (), QNetworkReply::sslErrors (),和 QNetworkReply::ignoreSslErrors ().

int QSslConfiguration:: peerVerifyDepth () const

Returns the maximum number of certificates in the peer's certificate chain to be checked during the SSL handshake phase, or 0 (the default) if no maximum depth has been set, indicating that the whole certificate chain should be checked.

The certificates are checked in issuing order, starting with the peer's own certificate, then its issuer's certificate, and so on.

另請參閱 setPeerVerifyDepth () 和 peerVerifyMode ().

QSslSocket::PeerVerifyMode QSslConfiguration:: peerVerifyMode () const

Returns the verify mode. This mode decides whether QSslSocket should request a certificate from the peer (i.e., the client requests a certificate from the server, or a server requesting a certificate from the client), and whether it should require that this certificate is valid.

The default mode is AutoVerifyPeer, which tells QSslSocket to use VerifyPeer for clients, QueryPeer for servers.

另請參閱 setPeerVerifyMode ().

QByteArray QSslConfiguration:: preSharedKeyIdentityHint () const

返迴身份提示。

該函數在 Qt 5.8 引入。

另請參閱 setPreSharedKeyIdentityHint ().

QSslKey QSslConfiguration:: privateKey () const

返迴 SSL key assigned to this connection or a null key if none has been assigned yet.

另請參閱 setPrivateKey () 和 localCertificate ().

QSsl::SslProtocol QSslConfiguration:: protocol () const

Returns the protocol setting for this SSL configuration.

另請參閱 setProtocol ().

QSslCipher QSslConfiguration:: sessionCipher () const

返迴套接字的加密 cipher , or a null cipher if the connection isn't encrypted. The socket's cipher for the session is set during the handshake phase. The cipher is used to encrypt and decrypt data transmitted through the socket.

The SSL infrastructure also provides functions for setting the ordered list of ciphers from which the handshake phase will eventually select the session cipher. This ordered list must be in place before the handshake phase begins.

另請參閱 ciphers (), setCiphers (),和 QSslSocket::supportedCiphers ().

QSsl::SslProtocol QSslConfiguration:: sessionProtocol () const

Returns the socket's SSL/TLS protocol or UnknownProtocol if the connection isn't encrypted. The socket's protocol for the session is set during the handshake phase.

該函數在 Qt 5.4 引入。

另請參閱 protocol () 和 setProtocol ().

QByteArray QSslConfiguration:: sessionTicket () const

QSsl::SslOptionDisableSessionPersistence was turned off, this function returns the session ticket used in the SSL handshake in ASN.1 format, suitable to e.g. be persisted to disk. If no session ticket was used or QSsl::SslOptionDisableSessionPersistence was not turned off, this function returns an empty QByteArray .

注意: When persisting the session ticket to disk or similar, be careful not to expose the session to a potential attacker, as knowledge of the session allows for eavesdropping on data encrypted with the session parameters.

該函數在 Qt 5.2 引入。

另請參閱 setSessionTicket (), QSsl::SslOptionDisableSessionPersistence , setSslOption (),和 QSslSocket::newSessionTicketReceived ().

int QSslConfiguration:: sessionTicketLifeTimeHint () const

QSsl::SslOptionDisableSessionPersistence was turned off, this function returns the session ticket life time hint sent by the server (which might be 0). If the server did not send a session ticket (e.g. when resuming a session or when the server does not support it) or QSsl::SslOptionDisableSessionPersistence was not turned off, this function returns -1.

該函數在 Qt 5.2 引入。

另請參閱 sessionTicket (), QSsl::SslOptionDisableSessionPersistence , setSslOption (),和 QSslSocket::newSessionTicketReceived ().

void QSslConfiguration:: setAllowedNextProtocols ( QList < QByteArray > protocols )

This function sets the allowed protocols to be negotiated with the server through the Next Protocol Negotiation (NPN) or Application-Layer Protocol Negotiation (ALPN) TLS extension; each element in protocols must define one allowed protocol. The function must be called explicitly before connecting to send the NPN/ALPN extension in the SSL handshake. Whether or not the negotiation succeeded can be queried through nextProtocolNegotiationStatus ().

該函數在 Qt 5.3 引入。

另請參閱 nextNegotiatedProtocol (), nextProtocolNegotiationStatus (), allowedNextProtocols (), QSslConfiguration::NextProtocolSpdy3_0 ,和 QSslConfiguration::NextProtocolHttp1_1 .

void QSslConfiguration:: setBackendConfiguration (const QMap < QByteArray , QVariant > & backendConfiguration = QMap<QByteArray, QVariant>())

Sets or clears the backend-specific configuration.

Without a backendConfiguration parameter this function will clear the backend-specific configuration. More information about the supported options is available in the documentation of setBackendConfigurationOption ().

該函數在 Qt 5.11 引入。

另請參閱 backendConfiguration () 和 setBackendConfigurationOption ().

void QSslConfiguration:: setBackendConfigurationOption (const QByteArray & name , const QVariant & value )

設置選項 name in the backend-specific configuration to value .

Options supported by the OpenSSL (>= 1.0.2) backend are available in the supported configuration file commands documentation. The expected type for the value parameter is a QByteArray for all options. The examples show how to use some of the options.

注意: The backend-specific configuration will be applied after the general configuration. Using the backend-specific configuration to set a general configuration option again will overwrite the general configuration option.

該函數在 Qt 5.11 引入。

另請參閱 backendConfiguration () 和 setBackendConfiguration ().

void QSslConfiguration:: setCaCertificates (const QList < QSslCertificate > & certificates )

Sets this socket's CA certificate database to be certificates . The certificate database must be set prior to the SSL handshake. The CA certificate database is used by the socket during the handshake phase to validate the peer's certificate.

注意: The default configuration uses the system CA certificate database. If that is not available (as is commonly the case on iOS), the default database is empty.

另請參閱 caCertificates (), addCaCertificates (),和 addCaCertificate ().

void QSslConfiguration:: setCiphers (const QList < QSslCipher > & ciphers )

Sets the cryptographic cipher suite for this socket to ciphers , which must contain a subset of the ciphers in the list returned by supportedCiphers ().

Restricting the cipher suite must be done before the handshake phase, where the session cipher is chosen.

注意: This is not currently supported in the Schannel backend.

另請參閱 ciphers () 和 QSslSocket::supportedCiphers ().

[static] void QSslConfiguration:: setDefaultConfiguration (const QSslConfiguration & configuration )

Sets the default SSL configuration to be used in new SSL connections to be configuration . Existing connections are not affected by this call.

另請參閱 QSslSocket::supportedCiphers () 和 defaultConfiguration ().

[static] void QSslConfiguration:: setDefaultDtlsConfiguration (const QSslConfiguration & configuration )

Sets the default DTLS configuration to be used in new DTLS connections to be configuration . Existing connections are not affected by this call.

另請參閱 defaultDtlsConfiguration ().

void QSslConfiguration:: setDiffieHellmanParameters (const QSslDiffieHellmanParameters & dhparams )

Sets a custom set of Diffie-Hellman parameters to be used by this socket when functioning as a server to dhparams .

If no Diffie-Hellman parameters have been set, the QSslConfiguration object defaults to using the 2048-bit MODP group from RFC 3526.

注意: The default parameters may change in future Qt versions. Please check the documentation of the exact Qt version that you are using in order to know what defaults that version uses.

該函數在 Qt 5.8 引入。

另請參閱 diffieHellmanParameters ().

void QSslConfiguration:: setDtlsCookieVerificationEnabled ( bool enable )

This function enables DTLS cookie verification when enable 為 true。

另請參閱 dtlsCookieVerificationEnabled ().

void QSslConfiguration:: setEllipticCurves (const QVector < QSslEllipticCurve > & curves )

Sets the list of elliptic curves to be used by this socket to curves , which must contain a subset of the curves in the list returned by supportedEllipticCurves ().

Restricting the elliptic curves must be done before the handshake phase, where the session cipher is chosen.

該函數在 Qt 5.5 引入。

另請參閱 ellipticCurves .

void QSslConfiguration:: setLocalCertificate (const QSslCertificate & certificate )

Sets the certificate to be presented to the peer during SSL handshake to be certificate .

Setting the certificate once the connection has been established has no effect.

A certificate is the means of identification used in the SSL process. The local certificate is used by the remote end to verify the local user's identity against its list of Certification Authorities. In most cases, such as in HTTP web browsing, only servers identify to the clients, so the client does not send a certificate.

另請參閱 localCertificate ().

void QSslConfiguration:: setLocalCertificateChain (const QList < QSslCertificate > & localChain )

Sets the certificate chain to be presented to the peer during the SSL handshake to be localChain .

Setting the certificate chain once the connection has been established has no effect.

A certificate is the means of identification used in the SSL process. The local certificate is used by the remote end to verify the local user's identity against its list of Certification Authorities. In most cases, such as in HTTP web browsing, only servers identify to the clients, so the client does not send a certificate.

不像 QSslConfiguration::setLocalCertificate () this method allows you to specify any intermediate certificates required in order to validate your certificate. The first item in the list must be the leaf certificate.

該函數在 Qt 5.1 引入。

另請參閱 localCertificateChain ().

void QSslConfiguration:: setOcspStaplingEnabled ( bool enabled )

enabled is true, client QSslSocket will send a certificate status request to its peer when initiating a handshake. During the handshake QSslSocket will verify the server's response. This value must be set before the handshake starts.

該函數在 Qt 5.13 引入。

另請參閱 ocspStaplingEnabled ().

void QSslConfiguration:: setPeerVerifyDepth ( int depth )

Sets the maximum number of certificates in the peer's certificate chain to be checked during the SSL handshake phase, to depth . Setting a depth of 0 means that no maximum depth is set, indicating that the whole certificate chain should be checked.

The certificates are checked in issuing order, starting with the peer's own certificate, then its issuer's certificate, and so on.

另請參閱 peerVerifyDepth () 和 setPeerVerifyMode ().

void QSslConfiguration:: setPeerVerifyMode ( QSslSocket::PeerVerifyMode mode )

Sets the verify mode to mode . This mode decides whether QSslSocket should request a certificate from the peer (i.e., the client requests a certificate from the server, or a server requesting a certificate from the client), and whether it should require that this certificate is valid.

The default mode is AutoVerifyPeer, which tells QSslSocket to use VerifyPeer for clients, QueryPeer for servers.

另請參閱 peerVerifyMode ().

void QSslConfiguration:: setPreSharedKeyIdentityHint (const QByteArray & hint )

Sets the identity hint for a preshared key authentication to hint . This will affect the next initiated handshake; calling this function on an already-encrypted socket will not affect the socket's identity hint.

The identity hint is used in QSslSocket::SslServerMode only!

該函數在 Qt 5.8 引入。

另請參閱 preSharedKeyIdentityHint ().

void QSslConfiguration:: setPrivateKey (const QSslKey & key )

Sets the connection's private key to key . The private key and the local certificate are used by clients and servers that must prove their identity to SSL peers.

Both the key and the local certificate are required if you are creating an SSL server socket. If you are creating an SSL client socket, the key and local certificate are required if your client must identify itself to an SSL server.

另請參閱 privateKey () 和 setLocalCertificate ().

void QSslConfiguration:: setProtocol ( QSsl::SslProtocol protocol )

Sets the protocol setting for this configuration to be protocol .

Setting the protocol once the connection has already been established has no effect.

另請參閱 protocol ().

void QSslConfiguration:: setSessionTicket (const QByteArray & sessionTicket )

Sets the session ticket to be used in an SSL handshake. QSsl::SslOptionDisableSessionPersistence must be turned off for this to work, and sessionTicket must be in ASN.1 format as returned by sessionTicket ().

該函數在 Qt 5.2 引入。

另請參閱 sessionTicket (), QSsl::SslOptionDisableSessionPersistence , setSslOption (),和 QSslSocket::newSessionTicketReceived ().

void QSslConfiguration:: setSslOption ( QSsl::SslOption option , bool on )

啓用 (或禁用) SSL (安全套接字層) 兼容性 option 。若 on 為 true, option 被啓用。若 on 為 false, option 被禁用。

另請參閱 testSslOption ().

[static] QList < QSslCipher > QSslConfiguration:: supportedCiphers ()

Returns the list of cryptographic ciphers supported by this system. This list is set by the system's SSL libraries and may vary from system to system.

該函數在 Qt 5.5 引入。

另請參閱 ciphers () 和 setCiphers ().

[static] QVector < QSslEllipticCurve > QSslConfiguration:: supportedEllipticCurves ()

Returns the list of elliptic curves supported by this system. This list is set by the system's SSL libraries and may vary from system to system.

該函數在 Qt 5.5 引入。

另請參閱 ellipticCurves () 和 setEllipticCurves ().

void QSslConfiguration:: swap ( QSslConfiguration & other )

交換此 SSL (安全套接字層) 配置實例與 other 。此函數非常快且從不失敗。

該函數在 Qt 5.0 引入。

[static] QList < QSslCertificate > QSslConfiguration:: systemCaCertificates ()

This function provides the CA certificate database provided by the operating system. The CA certificate database returned by this function is used to initialize the database returned by caCertificates () on the default QSslConfiguration .

該函數在 Qt 5.5 引入。

另請參閱 caCertificates (), setCaCertificates (), defaultConfiguration (), addCaCertificate (),和 addCaCertificates ().

bool QSslConfiguration:: testSslOption ( QSsl::SslOption option ) const

返迴 true 若指定的 SSL (安全套接字層) 兼容性 option 被啓用。

該函數在 Qt 4.8 引入。

另請參閱 setSslOption ().

bool QSslConfiguration:: operator!= (const QSslConfiguration & other ) const

返迴 true 若此 QSslConfiguration 不同於 other 。兩 QSslConfiguration objects are considered different if any state or setting is different.

另請參閱 operator== ().

bool QSslConfiguration:: operator== (const QSslConfiguration & other ) const

返迴 true 若此 QSslConfiguration 對象等於 other .

Two QSslConfiguration objects are considered equal if they have the exact same settings and state.

另請參閱 operator!= ().

成員變量文檔編製

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.