- Qt 5.15
- Qt Network
- C++ Classes
- QSslSocket
- Qt 5.15.15 Reference Documentation

# Obsolete Members for QSslSocket

The following members of class QSslSocket are obsolete. They are provided to keep old source code working. We strongly advise against using them in new code.

## Public Functions

`(obsolete)` void | addCaCertificate(const QSslCertificate &certificate)
`(obsolete)` bool | addCaCertificates(const QString &path, QSsl::EncodingFormat format = QSsl::Pem, QRegExp::PatternSyntax syntax = QRegExp::FixedString)
`(obsolete)` void | addCaCertificates(const QList<QSslCertificate> &certificates)
`(obsolete)` QList<QSslCertificate> | caCertificates() const
`(obsolete)` QList<QSslCipher> | ciphers() const
`(obsolete)` void | setCaCertificates(const QList<QSslCertificate> &certificates)
`(obsolete)` void | setCiphers(const QList<QSslCipher> &ciphers)
`(obsolete)` void | setCiphers(const QString &ciphers)
`(obsolete)` QList<QSslError> | sslErrors() const

## Static Public Members

`(obsolete)` void | addDefaultCaCertificate(const QSslCertificate &certificate)
`(obsolete)` bool | addDefaultCaCertificates(const QString &path, QSsl::EncodingFormat encoding = QSsl::Pem, QRegExp::PatternSyntax syntax = QRegExp::FixedString)
`(obsolete)` void | addDefaultCaCertificates(const QList<QSslCertificate> &certificates)
`(obsolete)` QList<QSslCertificate> | defaultCaCertificates()
`(obsolete)` QList<QSslCipher> | defaultCiphers()
`(obsolete)` void | setDefaultCaCertificates(const QList<QSslCertificate> &certificates)
`(obsolete)` void | setDefaultCiphers(const QList<QSslCipher> &ciphers)
`(obsolete)` QList<QSslCipher> | supportedCiphers()
`(obsolete)` QList<QSslCertificate> | systemCaCertificates()

## Member Function Documentation

### void QSslSocket::addCaCertificate(const QSslCertificate &certificate)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use QSslConfiguration::addCaCertificate() instead.

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

To add multiple certificates, use addCaCertificates().

See also QSslConfiguration::caCertificates() and QSslConfiguration::setCaCertificates().

### bool QSslSocket::addCaCertificates(const QString &path, QSsl::EncodingFormat format = QSsl::Pem, QRegExp::PatternSyntax syntax = QRegExp::FixedString)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use QSslConfiguration::addCaCertificates() instead.

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. Returns `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.

For more precise control, use addCaCertificate().

See also addCaCertificate() and QSslCertificate::fromPath().

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

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use QSslConfiguration::addCaCertificates() instead.

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

For more precise control, use addCaCertificate().

See also QSslConfiguration::caCertificates() and addDefaultCaCertificate().

### `[static]` void QSslSocket::addDefaultCaCertificate(const QSslCertificate &certificate)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use QSslConfiguration::addCaCertificate() on the default QSslConfiguration instead.

Adds certificate to the default CA certificate database. Each SSL socket's CA certificate database is initialized to the default CA certificate database.

See also QSslConfiguration::addCaCertificates().

### `[static]` bool QSslSocket::addDefaultCaCertificates(const QString &path, QSsl::EncodingFormat encoding = QSsl::Pem, QRegExp::PatternSyntax syntax = QRegExp::FixedString)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use QSslConfiguration::addCaCertificates() on the default QSslConfiguration instead.

Searches all files in the path for certificates with the specified encoding and adds them to the default CA certificate database. path can be an explicit file, or it can contain wildcards in the format specified by syntax. Returns `true` if any CA certificates are added to the default database.

Each SSL socket's CA certificate database is initialized to the default CA certificate database.

See also QSslConfiguration::caCertificates(), QSslConfiguration::addCaCertificates(), and QSslConfiguration::addCaCertificate().

### `[static]` void QSslSocket::addDefaultCaCertificates(const QList<QSslCertificate> &certificates)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use QSslConfiguration::addCaCertificates() on the default QSslConfiguration instead.

Adds certificates to the default CA certificate database. Each SSL socket's CA certificate database is initialized to the default CA certificate database.

See also QSslConfiguration::caCertificates() and QSslConfiguration::addCaCertificates().

### QList<QSslCertificate> QSslSocket::caCertificates() const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use QSslConfiguration::caCertificates() instead.

Returns this socket'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 moodified prior to the handshake with addCaCertificate(), addCaCertificates(), and setCaCertificates().

Note: On Unix, this method may return an empty list if the root certificates are loaded on demand.

See also addCaCertificate(), addCaCertificates(), and setCaCertificates().

### QList<QSslCipher> QSslSocket::ciphers() const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use QSslConfiguration::ciphers() instead.

Returns this socket's current cryptographic cipher suite. This list is used during the socket's 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 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 supportedCiphers().

You can restrict the list of ciphers used for choosing the session cipher for all sockets by calling setDefaultCiphers() with a subset of the supported ciphers. You can revert to using the entire set by calling setCiphers() with the list returned by supportedCiphers().

See also setCiphers(), defaultCiphers(), setDefaultCiphers(), and supportedCiphers().

### `[static]` QList<QSslCertificate> QSslSocket::defaultCaCertificates()

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use QSslConfiguration::caCertificates() on the default QSslConfiguration instead.

Returns the current default CA certificate database. This database is originally set to your system's default CA certificate database. If no system default database is found, an empty database will be returned. You can override the default CA certificate database with your own CA certificate database using setDefaultCaCertificates().

Each SSL socket's CA certificate database is initialized to the default CA certificate database.

Note: On Unix, this method may return an empty list if the root certificates are loaded on demand.

See also setDefaultCaCertificates() and caCertificates().

### `[static]` QList<QSslCipher> QSslSocket::defaultCiphers()

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use QSslConfiguration::ciphers() on the default QSslConfiguration instead.

Returns the default cryptographic cipher suite for all sockets in this application. This list is used during the socket's handshake phase when negotiating with the peer to choose a session cipher. The list is ordered by preference (i.e., the first cipher in the list is the most preferred cipher).

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 supportedCiphers().

See also setDefaultCiphers() and supportedCiphers().

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

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use QSslConfiguration::setCaCertificates() instead.

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 CA certificate database can be reset to the current default CA certificate database by calling this function with the list of CA certificates returned by defaultCaCertificates().

See also caCertificates() and defaultCaCertificates().

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

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

USe QSslConfiguration::setCiphers() instead.

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.

See also ciphers(), setDefaultCiphers(), and supportedCiphers().

### void QSslSocket::setCiphers(const QString &ciphers)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use QSslConfiguration::setCiphers() instead.

Sets the cryptographic cipher suite for this socket to ciphers, which is a colon-separated list of cipher suite names. The ciphers are listed in order of preference, starting with the most preferred cipher. For example:

     QSslSocket socket;
     socket.setCiphers("DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:AES256-SHA");

Each cipher name in ciphers must be the name of a cipher in the list returned by supportedCiphers(). Restricting the cipher suite must be done before the handshake phase, where the session cipher is chosen.

See also ciphers(), setDefaultCiphers(), and supportedCiphers().

### `[static]` void QSslSocket::setDefaultCaCertificates(const QList<QSslCertificate> &certificates)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use QSslConfiguration::setCaCertificates() on the default QSslConfiguration instead.

Sets the default CA certificate database to certificates. The default CA certificate database is originally set to your system's default CA certificate database. You can override the default CA certificate database with your own CA certificate database using this function.

Each SSL socket's CA certificate database is initialized to the default CA certificate database.

See also defaultCaCertificates() and addDefaultCaCertificate().

### `[static]` void QSslSocket::setDefaultCiphers(const QList<QSslCipher> &ciphers)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use QSslConfiguration::setCiphers() on the default QSslConfiguration instead.

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

Restricting the default cipher suite only affects SSL sockets that perform their handshake phase after the default cipher suite has been changed.

See also setCiphers(), defaultCiphers(), and supportedCiphers().

### QList<QSslError> QSslSocket::sslErrors() const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use sslHandshakeErrors() instead.

Returns a list of the last SSL errors that occurred. This is the same list as QSslSocket passes via the sslErrors() signal. If the connection has been encrypted with no errors, this function will return an empty list.

See also connectToHostEncrypted() and sslHandshakeErrors().

### `[static]` QList<QSslCipher> QSslSocket::supportedCiphers()

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use QSslConfiguration::supportedCiphers() instead.

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.

See also defaultCiphers(), ciphers(), and setCiphers().

### `[static]` QList<QSslCertificate> QSslSocket::systemCaCertificates()

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use QSslConfiguration::systemDefaultCaCertificates instead.

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 defaultCaCertificates(). You can replace that database with your own with setDefaultCaCertificates().

Note: : On OS X, only certificates that are either trusted for all purposes or trusted for the purpose of SSL in the keychain will be returned.

See also caCertificates(), defaultCaCertificates(), and setDefaultCaCertificates().