QSslPreSharedKeyAuthenticatorclass provides authentication data for pre shared keys (PSK) ciphersuites. 更多 …
def
__ne__
(, rhs)
def
identity
()
def
identityHint
()
def
maximumIdentityLength
()
def
maximumPreSharedKeyLength
()
def
preSharedKey
()
def
setIdentity
(identity)
def
setPreSharedKey
(preSharedKey)
def
swap
(other)
QSslPreSharedKeyAuthenticatorclass 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.
QSslPreSharedKeyAuthenticatorprovides means to client applications for completing the PSK handshake. The client application needs to connect a slot to thepreSharedKeyAuthenticationRequired()signal:connect(socket, &QSslSocket::preSharedKeyAuthenticationRequired, this, &AuthManager::handlePreSharedKeyAuthentication);The signal carries a
QSslPreSharedKeyAuthenticatorobject 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.
另请参阅
QSslPreSharedKeyAuthenticator(authenticator)
- param authenticator
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=()
QByteArray
Returns the PSK client identity.
另请参阅
QByteArray
Returns the PSK identity hint as provided by the server. The interpretation of this hint is left to the application.
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.
另请参阅
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.
另请参阅
bool
QByteArray
Returns the pre shared key.
另请参阅
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.
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.
另请参阅
preSharedKey()
maximumPreSharedKeyLength()
fromHex()
other
–
QSslPreSharedKeyAuthenticator
Swaps the
QSslPreSharedKeyAuthenticator
object
authenticator
with this object. This operation is very fast and never fails.