PySide6.QtNetwork.QSslPreSharedKeyAuthenticator¶
- class QSslPreSharedKeyAuthenticator¶
The
QSslPreSharedKeyAuthenticatorclass provides authentication data for pre shared keys (PSK) ciphersuites.Details
Warning
This section contains snippets that were automatically translated from C++ to Python and may contain errors.
The
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.
The
QSslPreSharedKeyAuthenticatorprovides means to client applications for completing the PSK handshake. The client application needs to connect a slot to thepreSharedKeyAuthenticationRequired()signal:socket.preSharedKeyAuthenticationRequired.connect( self.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:def handlePreSharedKeyAuthentication(self, authenticator): authenticator.setIdentity("My Qt App") key = deriveKey(authenticator.identityHint(), passphrase) authenticator.setPreSharedKey(key)
Note
PSK ciphersuites are supported only when using OpenSSL 1.0.1 (or greater) as the SSL backend.
Synopsis¶
Methods¶
def
__init__()def
identity()def
identityHint()def
__ne__()def
__eq__()def
preSharedKey()def
setIdentity()def
swap()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
- __init__()¶
Constructs a default
QSslPreSharedKeyAuthenticatorobject.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.
- __init__(authenticator)
- Parameters:
authenticator –
QSslPreSharedKeyAuthenticator
Constructs a
QSslPreSharedKeyAuthenticatorobject as a copy ofauthenticator.See also
operator=()- identity()¶
- Return type:
Returns the PSK client identity.
See also
- identityHint()¶
- Return type:
Returns the PSK identity hint as provided by the server. The interpretation of this hint is left to the application.
- maximumIdentityLength()¶
- Return type:
int
Returns the maximum length, in bytes, of the PSK client identity.
Note
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.
See also
- maximumPreSharedKeyLength()¶
- Return type:
int
Returns the maximum length, in bytes, of the pre shared key.
Note
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.
See also
- __ne__(rhs)¶
- Parameters:
- Return type:
bool
- __eq__(rhs)¶
- Parameters:
- Return type:
bool
- preSharedKey()¶
- Return type:
Returns the pre shared key.
See also
- setIdentity(identity)¶
- Parameters:
identity –
QByteArray
Sets the PSK client identity (to be advised to the server) to
identity.Note
it is possible to set an identity whose length is greater than
maximumIdentityLength(); in this case, only the firstmaximumIdentityLength()bytes will be actually sent to the server.See also
- setPreSharedKey(preSharedKey)¶
- Parameters:
preSharedKey –
QByteArray
Sets the pre shared key to
preSharedKey.Note
it is possible to set a key whose length is greater than the
maximumPreSharedKeyLength(); in this case, only the firstmaximumPreSharedKeyLength()bytes will be actually sent to the server.- swap(other)¶
- Parameters:
other –
QSslPreSharedKeyAuthenticator
Swaps this authenticator with
other. This operation is very fast and never fails.