Skip to content

PythonQt.QtNetwork.QSslPreSharedKeyAuthenticator

QSslPreSharedKeyAuthenticator

PythonQtInstanceWrapper object

Native bases: PythonQtInstanceWrapper

Supplemental documentation: Qt 5 reference:

Detailed Description

The 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.

The QSslPreSharedKeyAuthenticator provides means to client applications for completing the PSK handshake. The client application needs to connect a slot to the QSslSocket::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);
    }

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

Note: PSK is currently only supported in OpenSSL.

Source: https://doc.qt.io/archives/qt-5.15/qsslpresharedkeyauthenticator.html

Complete member index

Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.

Member Kind Signature Summary
__init__ function (self, *args: Any, **kwargs: Any) -> None Native constructor; consult class documentation for supported overloads. (shared captured text)
className function (self, *args: Any, **kwargs: Any) -> Any Return the classname of the object (shared captured text)
delete function (self, *args: Any, **kwargs: Any) -> Any Deletes the C++ object (at your own risk, my friend!) (shared captured text)
help function (self, *args: Any, **kwargs: Any) -> Any Shows the help of available methods for this class (shared captured text)
identity function (self) -> Any X.identity() -> PythonQt.QtCore.QByteArray
identityHint function (self) -> Any X.identityHint() -> PythonQt.QtCore.QByteArray
inherits function (self, *args: Any, **kwargs: Any) -> Any Returns if the class inherits or is of given type name (shared captured text)
maximumIdentityLength function (self) -> int X.maximumIdentityLength() -> int
maximumPreSharedKeyLength function (self) -> int X.maximumPreSharedKeyLength() -> int
operator_assign function (self, authenticator: Any) -> Any X.operator_assign(authenticator) -> PythonQt.QtNetwork.QSslPreSharedKeyAuthenticator
preSharedKey function (self) -> Any X.preSharedKey() -> PythonQt.QtCore.QByteArray
setIdentity function (self, identity: Any) -> None Sets the PSK client identity (to be advised to the server) to identity.
setPreSharedKey function (self, preSharedKey: Any) -> None Sets the pre shared key to preSharedKey.
swap function (self, other: Any) -> None Swaps the [QSslPreSharedKeyAuthenticator](https://doc.qt.io/archives/qt-5.15/qsslpresharedkeyauthenticator.html) object authenticator with this object.