QSslKey Class▲
-
Header: QSslKey
-
CMake:
find_package(Qt6 REQUIRED COMPONENTS Network)
target_link_libraries(mytarget PRIVATE Qt6::Network)
-
qmake: QT += network
-
Group: QSslKey is part of Network Programming API, ssl, shared
Detailed Description▲
QSslKey provides a simple API for managing keys.
See Also▲
See also QSslSocket, QSslCertificate, QSslCipher
Member Function Documentation▲
QSslKey::QSslKey()▲
QSslKey::QSslKey(const QByteArray &encoded, QSsl::KeyAlgorithm algorithm, QSsl::EncodingFormat encoding = QSsl::Pem, QSsl::KeyType type = QSsl::PrivateKey, const QByteArray &passPhrase = QByteArray())▲
Constructs a QSslKey by decoding the string in the byte array encoded using a specified algorithm and encoding format. type specifies whether the key is public or private.
If the key is encrypted then passPhrase is used to decrypt it.
After construction, use isNull() to check if encoded contained a valid key.
QSslKey::QSslKey(QIODevice *device, QSsl::KeyAlgorithm algorithm, QSsl::EncodingFormat encoding = QSsl::Pem, QSsl::KeyType type = QSsl::PrivateKey, const QByteArray &passPhrase = QByteArray())▲
Constructs a QSslKey by reading and decoding data from a device using a specified algorithm and encoding format. type specifies whether the key is public or private.
If the key is encrypted then passPhrase is used to decrypt it.
After construction, use isNull() to check if device provided a valid key.
[explicit, since 5.0] QSslKey::QSslKey(Qt::HANDLE handle, QSsl::KeyType type = QSsl::PrivateKey)▲
Constructs a QSslKey from a valid native key handle. type specifies whether the key is public or private.
QSslKey will take ownership for this key and you must not free the key using the native library.
This function was introduced in Qt 5.0.
QSslKey::QSslKey(const QSslKey &other)▲
Constructs an identical copy of other.
QSslKey::~QSslKey()▲
Destroys the QSslKey object.
QSsl::KeyAlgorithm QSslKey::algorithm() const▲
Returns the key algorithm.
void QSslKey::clear()▲
Qt::HANDLE QSslKey::handle() const▲
Returns a pointer to the native key handle, if there is one, else nullptr.
You can use this handle together with the native API to access extended information about the key.
Use of this function has a high probability of being non-portable, and its return value may vary across platforms, and between minor Qt releases.
bool QSslKey::isNull() const▲
int QSslKey::length() const▲
Returns the length of the key in bits, or -1 if the key is null.
[since 5.0] void QSslKey::swap(QSslKey &other)▲
Swaps this ssl key with other. This function is very fast and never fails.
This function was introduced in Qt 5.0.
QByteArray QSslKey::toDer(const QByteArray &passPhrase = QByteArray()) const▲
Returns the key in DER encoding.
The passPhrase argument should be omitted as DER cannot be encrypted. It will be removed in a future version of Qt.
QByteArray QSslKey::toPem(const QByteArray &passPhrase = QByteArray()) const▲
Returns the key in PEM encoding. The result is encrypted with passPhrase if the key is a private key and passPhrase is non-empty.
QSsl::KeyType QSslKey::type() const▲
Returns the type of the key (i.e., PublicKey or PrivateKey).
bool QSslKey::operator!=(const QSslKey &other) const▲
Returns true if this key is not equal to key other; otherwise returns false.
QSslKey &QSslKey::operator=(const QSslKey &other)▲
Copies the contents of other into this key, making the two keys identical.
Returns a reference to this QSslKey.
bool QSslKey::operator==(const QSslKey &other) const▲
Returns true if this key is equal to other; otherwise returns false.