内容表

上一话题

QSslKey

下一话题

QSslSocket

QSslPreSharedKeyAuthenticator

QSslPreSharedKeyAuthenticator class provides authentication data for pre shared keys (PSK) ciphersuites. 更多

Inheritance diagram of PySide2.QtNetwork.QSslPreSharedKeyAuthenticator

概要

函数

详细描述

QSslPreSharedKeyAuthenticator class is used by an SSL socket to provide the required authentication data in a pre shared key (PSK) ciphersuite.

In a PSK handshake, the client must derive a key, which must match the key set on the server. The exact algorithm of deriving the key depends on the application; however, for this purpose, the server may send an identity hint to the client. This hint, combined with other information (for instance a passphrase), is then used by the client to construct the shared key.

QSslPreSharedKeyAuthenticator provides means to client applications for completing the PSK handshake. The client application needs to connect a slot to the preSharedKeyAuthenticationRequired() signal:

connect(socket, &QSslSocket::preSharedKeyAuthenticationRequired,
        this, &AuthManager::handlePreSharedKeyAuthentication);
											

The signal carries a QSslPreSharedKeyAuthenticator object containing the identity hint the server sent to the client, and which must be filled with the corresponding client identity and the derived key:

void AuthManager::handlePreSharedKeyAuthentication(QSslPreSharedKeyAuthenticator *authenticator)
{
    authenticator->setIdentity("My Qt App");
    const QByteArray key = deriveKey(authenticator->identityHint(), passphrase);
    authenticator->setPreSharedKey(key);
}
											

注意

PSK ciphersuites are supported only when using OpenSSL 1.0.1 (or greater) as the SSL backend.

注意

PSK is currently only supported in OpenSSL.

另请参阅

QSslSocket

class QSslPreSharedKeyAuthenticator

QSslPreSharedKeyAuthenticator(authenticator)

param authenticator

QSslPreSharedKeyAuthenticator

Constructs a default QSslPreSharedKeyAuthenticator 对象。

The identity hint, the identity and the key will be initialized to empty byte arrays; the maximum length for both the identity and the key will be initialized to 0.

构造 QSslPreSharedKeyAuthenticator object as a copy of authenticator .

另请参阅

operator=()

PySide2.QtNetwork.QSslPreSharedKeyAuthenticator. identity ( )
返回类型

QByteArray

Returns the PSK client identity.

另请参阅

setIdentity()

PySide2.QtNetwork.QSslPreSharedKeyAuthenticator. identityHint ( )
返回类型

QByteArray

Returns the PSK identity hint as provided by the server. The interpretation of this hint is left to the application.

PySide2.QtNetwork.QSslPreSharedKeyAuthenticator. maximumIdentityLength ( )
返回类型

int

Returns the maximum length, in bytes, of the PSK client identity.

注意

it is possible to set an identity whose length is greater than ; in this case, only the first bytes will be actually sent to the server.

另请参阅

setIdentity()

PySide2.QtNetwork.QSslPreSharedKeyAuthenticator. maximumPreSharedKeyLength ( )
返回类型

int

Returns the maximum length, in bytes, of the pre shared key.

注意

it is possible to set a key whose length is greater than the ; in this case, only the first bytes will be actually sent to the server.

另请参阅

setPreSharedKey()

PySide2.QtNetwork.QSslPreSharedKeyAuthenticator. __ne__ ( rhs )
参数

rhs QSslPreSharedKeyAuthenticator

返回类型

bool

PySide2.QtNetwork.QSslPreSharedKeyAuthenticator. preSharedKey ( )
返回类型

QByteArray

Returns the pre shared key.

另请参阅

setPreSharedKey()

PySide2.QtNetwork.QSslPreSharedKeyAuthenticator. setIdentity ( identity )
参数

identity QByteArray

Sets the PSK client identity (to be advised to the server) to identity .

注意

it is possible to set an identity whose length is greater than maximumIdentityLength() ; in this case, only the first maximumIdentityLength() bytes will be actually sent to the server.

PySide2.QtNetwork.QSslPreSharedKeyAuthenticator. setPreSharedKey ( preSharedKey )
参数

preSharedKey QByteArray

Sets the pre shared key to preSharedKey .

注意

it is possible to set a key whose length is greater than the maximumPreSharedKeyLength() ; in this case, only the first maximumPreSharedKeyLength() bytes will be actually sent to the server.

PySide2.QtNetwork.QSslPreSharedKeyAuthenticator. swap ( other )
参数

other QSslPreSharedKeyAuthenticator

Swaps the QSslPreSharedKeyAuthenticator object authenticator with this object. This operation is very fast and never fails.