このページでは

QSslKey Class

QSslKey クラスは、秘密鍵および公開鍵のためのインターフェースを提供します。詳細...

ヘッダー: #include <QSslKey>
CMake: find_package(Qt6 REQUIRED COMPONENTS Network)
target_link_libraries(mytarget PRIVATE Qt6::Network)
qmake: QT += network

注:このクラスのすべての関数は再入可能です。

パブリック関数

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

詳細な説明

QSslKey は、キーを管理するためのシンプルな API を提供します。

関連項目: QSslSocket 、QSslCertificate 、QSslCipher 。

メンバー関数のドキュメント

QSslKey::QSslKey()

nullキーを作成します。

isNull()も参照してください 。

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

有効なネイティブキー `handle` から `QSslKey` を生成します。`type ` は、そのキーが公開鍵か秘密鍵かを指定します。

QSslKeyはこのキーの所有権を取得するため、ネイティブライブラリを使用してキーを解放してはなりません。

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

指定されたalgorithm およびencoding の形式を使用して、device からデータを読み取り、デコードすることで、QSslKeyを構築します。type は、キーが公開鍵か秘密鍵かを指定します。

キーが暗号化されている場合は、passPhrase を使用して復号化されます。

生成後、isNull() を使用して、device が有効なキーを提供したかどうかを確認します。

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

指定されたalgorithm およびencoding 形式を使用して、バイト配列encoded 内の文字列をデコードし、QSslKeyを構築します。type は、キーが公開キーか秘密キーかを指定します。

キーが暗号化されている場合、passPhrase を使用して復号化されます。

生成後、isNull() を使用して、encoded に有効な鍵が含まれているかどうかを確認します。

QSslKey::QSslKey(const QSslKey &other)

other の完全なコピーを作成します。

[noexcept] QSslKey::~QSslKey()

QSslKey オブジェクトを破棄します。

QSsl::KeyAlgorithm QSslKey::algorithm() const

キーアルゴリズムを返します。

void QSslKey::clear()

このキーの内容を消去し、nullキーにします。

isNull()も参照してください 。

Qt::HANDLE QSslKey::handle() const

ネイティブのキーハンドルが存在する場合は、そのポインタを返します。存在しない場合は、nullptr を返します。

このハンドルをネイティブAPIと組み合わせて使用することで、キーに関する詳細情報にアクセスできます。

警告: この関数の使用は 移植性が低い可能性が高く、その戻り値はプラットフォームやQtのマイナーリリースによって異なる場合があります。

bool QSslKey::isNull() const

これがヌルキーの場合は `true ` を返し、そうでない場合は `false` を返します。

clear()も参照してください 。

int QSslKey::length() const

キーの長さをビット単位で返します。キーがnullの場合は-1を返します。

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

このSSLキーをother と交換します。この操作は非常に高速で、失敗することはありません。

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

DERエンコーディング形式のキーを返します。

DERは暗号化できないため、passPhrase 引数は省略する必要があります。これは将来のQtのバージョンで削除される予定です。

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

PEMエンコーディング形式の鍵を返します。鍵が秘密鍵であり、かつpassPhrase が空でない場合、結果はpassPhrase で暗号化されます。

QSsl::KeyType QSslKey::type() const

キーの型(PublicKey または PrivateKey)を返します。

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

このキーが `key` と等しくない場合、true を返します。other ;それ以外の場合は、false を返します。

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

other の内容をこのキーにコピーし、2つのキーを同一のものにします。

この `QSslKey` への参照を返します。

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

このキーが `other` と等しい場合は `true ` を返し、そうでない場合は `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.