QSslServer#

Implements an encrypted, secure TCP server over TLS. More

Inheritance diagram of PySide6.QtNetwork.QSslServer

New in version 6.4.

Synopsis#

Functions#

Signals#

Detailed Description#

Class to use in place of QTcpServer to implement TCP server using Transport Layer Security (TLS).

To configure the secure handshake settings, use the applicable setter functions on a QSslConfiguration object, and then use it as a argument to the setSslConfiguration() function. All following incoming connections handled will use these settings.

To start listening to incoming connections use the listen() function inherited from QTcpServer . Other settings can be configured by using the setter functions inherited from the QTcpServer class.

Connect to the signals of this class to respond to the incoming connection attempts. They are the same as the signals on QSslSocket , but also passes a pointer to the socket in question.

When responding to the pendingConnectionAvailable() signal, use the nextPendingConnection() function to fetch the next incoming connection and take it out of the pending connection queue. The QSslSocket is a child of the QSslServer and will be deleted when the QSslServer is deleted. It is still a good a good idea to destroy the object explicitly when you are done with it, to avoid wasting memory.

class PySide6.QtNetwork.QSslServer([parent=None])#
Parameters

parentPySide6.QtCore.QObject

Constructs a new QSslServer with the given parent.

PySide6.QtNetwork.QSslServer.alertReceived(socket, level, type, description)#
Parameters
PySide6.QtNetwork.QSslServer.alertSent(socket, level, type, description)#
Parameters
PySide6.QtNetwork.QSslServer.errorOccurred(socket, error)#
Parameters
PySide6.QtNetwork.QSslServer.handshakeInterruptedOnError(socket, error)#
Parameters
PySide6.QtNetwork.QSslServer.handshakeTimeout()#
Return type

int

Returns the currently configured handshake timeout.

PySide6.QtNetwork.QSslServer.peerVerifyError(socket, error)#
Parameters
PySide6.QtNetwork.QSslServer.preSharedKeyAuthenticationRequired(socket, authenticator)#
Parameters
PySide6.QtNetwork.QSslServer.setHandshakeTimeout(timeout)#
Parameters

timeout – int

Sets the timeout to use for all incoming handshakes, in milliseconds.

This is relevant in the scenario where a client, whether malicious or accidental, connects to the server but makes no attempt at communicating or initiating a handshake. QSslServer will then automatically end the connection after timeout milliseconds have elapsed.

By default the timeout is 5000 milliseconds (5 seconds).

Note

The underlying TLS framework may have their own timeout logic now or in the future, this function does not affect that.

Note

The timeout passed to this function will only apply to new connections. If a client is already connected it will use the timeout which was set when it connected.

PySide6.QtNetwork.QSslServer.setSslConfiguration(sslConfiguration)#
Parameters

sslConfigurationPySide6.QtNetwork.QSslConfiguration

Sets the sslConfiguration to use for all following incoming connections.

This must be called before listen() to ensure that the desired configuration was in use during all handshakes.

PySide6.QtNetwork.QSslServer.sslConfiguration()#
Return type

PySide6.QtNetwork.QSslConfiguration

Returns the current ssl configuration.

PySide6.QtNetwork.QSslServer.sslErrors(socket, errors)#
Parameters
PySide6.QtNetwork.QSslServer.startedEncryptionHandshake(socket)#
Parameters

socketPySide6.QtNetwork.QSslSocket