IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

QSslPreSharedKeyAuthenticator Class

The https:// class provides authentication data for pre shared keys (PSK) ciphersuites.

This class was introduced in Qt 5.5.

All functions in this class are https://.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QSslPreSharedKeyAuthenticator Class▲

  • Header: QSslPreSharedKeyAuthenticator

  • Since: Qt 5.5

  • qmake: QT += network

  • Group: QSslPreSharedKeyAuthenticator is part of https://, ssl, shared

Detailed Description▲

The https:// 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 https:// provides means to client applications for completing the PSK handshake. The client application needs to connect a slot to the QSslSocket::preSharedKeyAuthenticationRequired() signal:

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

The signal carries a https:// 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:

 
Sélectionnez
    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.

See Also▲

See also QSslSocket

Member Function Documentation▲

 

QSslPreSharedKeyAuthenticator::~QSslPreSharedKeyAuthenticator()▲

Destroys the https:// object.

Q_DECL_IMPORT QSslPreSharedKeyAuthenticator::maximumIdentityLength() const▲

Returns the maximum length, in bytes, of the PSK client 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.

See Also▲

See also setIdentity()

Q_DECL_IMPORT QSslPreSharedKeyAuthenticator::maximumPreSharedKeyLength() const▲

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

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▲

See also https://()

Q_DECL_IMPORT QSslPreSharedKeyAuthenticator::setPreSharedKey(const class QByteArray &preSharedKey)▲

Sets the pre shared key to preSharedKey.

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

See Also▲

See also https://, maximumPreSharedKeyLength(), QByteArray::fromHex()

QSslPreSharedKeyAuthenticator &QSslPreSharedKeyAuthenticator::operator=(QSslPreSharedKeyAuthenticator &&authenticator)▲

Move-assigns the the https:// object authenticator to this object, and returns a reference to the moved instance.

Related Non-Members▲

 

[since 5.5] bool operator!=(const QSslPreSharedKeyAuthenticator &lhs, const QSslPreSharedKeyAuthenticator &rhs)▲

Returns true if the authenticator object lhs is different than rhs; false otherwise.

This function was introduced in Qt 5.5.

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+   

Ce document est disponible sous la licence https:// telle que publiée par la Free Software Foundation.