Nesta página

QSslKey Class

A classe QSslKey oferece uma interface para chaves privadas e públicas. Mais...

Cabeçalho: #include <QSslKey>
CMake: find_package(Qt6 REQUIRED COMPONENTS Network)
target_link_libraries(mytarget PRIVATE Qt6::Network)
qmake: QT += network

Observação: Todas as funções desta classe são reentrantes.

Funções públicas

QSslKey()
QSslKey(Qt::HANDLE handle, QSsl::KeyType type = QSsl::PrivateKey)
QSslKey(QIODevice *device, QSsl::KeyAlgorithm algorithm, QSsl::EncodingFormat encoding = QSsl::Pem, QSsl::KeyType type = QSsl::PrivateKey, const QByteArray &passPhrase = QByteArray())
QSslKey(const QByteArray &encoded, QSsl::KeyAlgorithm algorithm, QSsl::EncodingFormat encoding = QSsl::Pem, QSsl::KeyType type = QSsl::PrivateKey, const QByteArray &passPhrase = QByteArray())
QSslKey(const QSslKey &other)
~QSslKey()
QSsl::KeyAlgorithm algorithm() const
void clear()
Qt::HANDLE handle() const
bool isNull() const
int length() const
void swap(QSslKey &other)
QByteArray toDer(const QByteArray &passPhrase = QByteArray()) const
QByteArray toPem(const QByteArray &passPhrase = QByteArray()) const
QSsl::KeyType type() const
bool operator!=(const QSslKey &other) const
QSslKey &operator=(const QSslKey &other)
bool operator==(const QSslKey &other) const

Descrição detalhada

O QSslKey fornece uma API simples para gerenciar chaves.

Veja também QSslSocket, QSslCertificate e QSslCipher.

Documentação das funções de membro

QSslKey::QSslKey()

Cria uma chave nula.

Veja também isNull().

[explicit] QSslKey::QSslKey(Qt::HANDLE handle, QSsl::KeyType type = QSsl::PrivateKey)

Cria um objeto QSslKey a partir de uma chave nativa válida handle. type especifica se a chave é pública ou privada.

O `QSslKey` assumirá a propriedade dessa chave e você não deve liberá-la usando a biblioteca nativa.

QSslKey::QSslKey(QIODevice *device, QSsl::KeyAlgorithm algorithm, QSsl::EncodingFormat encoding = QSsl::Pem, QSsl::KeyType type = QSsl::PrivateKey, const QByteArray &passPhrase = QByteArray())

Cria um objeto QSslKey lendo e decodificando dados de um objeto ` device `, utilizando um formato ` algorithm ` e ` encoding ` especificados. O parâmetro ` type ` especifica se a chave é pública ou privada.

Se a chave estiver criptografada, o método ` passPhrase ` é usado para descriptografá-la.

Após a construção, use ` isNull()` para verificar se ` device ` forneceu uma chave válida.

QSslKey::QSslKey(const QByteArray &encoded, QSsl::KeyAlgorithm algorithm, QSsl::EncodingFormat encoding = QSsl::Pem, QSsl::KeyType type = QSsl::PrivateKey, const QByteArray &passPhrase = QByteArray())

Cria um QSslKey decodificando a string contida na matriz de bytes encoded, utilizando um formato especificado algorithm e encoding. type especifica se a chave é pública ou privada.

Se a chave estiver criptografada, passPhrase será usado para descriptografá-la.

Após a construção, use isNull() para verificar se encoded contém uma chave válida.

QSslKey::QSslKey(const QSslKey &other)

Cria uma cópia idêntica de other.

[noexcept] QSslKey::~QSslKey()

Destrói o objeto ` QSslKey `.

QSsl::KeyAlgorithm QSslKey::algorithm() const

Retorna o algoritmo da chave.

void QSslKey::clear()

Limpa o conteúdo dessa chave, transformando-a em uma chave nula.

Veja também isNull().

Qt::HANDLE QSslKey::handle() const

Retorna um ponteiro para o identificador nativo da chave, se houver um; caso contrário, retorna ` nullptr`.

É possível usar esse identificador junto com a API nativa para acessar informações adicionais sobre a chave.

Aviso: O uso desta função tem alta probabilidade de não ser portável, e seu valor de retorno pode variar entre plataformas e entre versões secundárias do Qt.

bool QSslKey::isNull() const

Retorna ` true ` se esta for uma chave nula; caso contrário, retorna `false`.

Veja também clear().

int QSslKey::length() const

Retorna o comprimento da chave em bits ou -1 se a chave for nula.

[noexcept] void QSslKey::swap(QSslKey &other)

Troca esta chave SSL por other. Essa operação é muito rápida e nunca falha.

QByteArray QSslKey::toDer(const QByteArray &passPhrase = QByteArray()) const

Retorna a chave na codificação DER.

O argumento ` passPhrase ` deve ser omitido, pois DER não pode ser criptografado. Ele será removido em uma versão futura do Qt.

QByteArray QSslKey::toPem(const QByteArray &passPhrase = QByteArray()) const

Retorna a chave na codificação PEM. O resultado é criptografado com ` passPhrase ` se a chave for uma chave privada e ` passPhrase ` não estiver vazio.

QSsl::KeyType QSslKey::type() const

Retorna o tipo da chave (ou seja, PublicKey ou PrivateKey).

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

Retorna ` true ` se esta chave não for igual a ` other`; caso contrário, retorna ` false`.

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

Copia o conteúdo de other para esta chave, tornando as duas chaves idênticas.

Retorna uma referência a este ` QSslKey`.

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

Retorna ` true ` se essa chave for igual a ` other`; caso contrário, retorna ` false`.

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.