1 | // Copyright (C) 2022 The Qt Company Ltd. |
2 | // Copyright (C) 2016 Kurt Pattyn <pattyn.kurt@gmail.com>. |
3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
4 | |
5 | #ifndef QSSLSERVER_H |
6 | #define QSSLSERVER_H |
7 | |
8 | #include <QtNetwork/QTcpServer> |
9 | |
10 | QT_REQUIRE_CONFIG(ssl); |
11 | |
12 | #include <QtNetwork/QSslError> |
13 | #include <QtNetwork/QSslConfiguration> |
14 | #include <QtNetwork/QSslPreSharedKeyAuthenticator> |
15 | #include <QtNetwork/QSslSocket> |
16 | |
17 | #include <QtCore/QList> |
18 | |
19 | QT_BEGIN_NAMESPACE |
20 | |
21 | class QSslSocket; |
22 | class QSslServerPrivate; |
23 | |
24 | class Q_NETWORK_EXPORT QSslServer : public QTcpServer |
25 | { |
26 | Q_OBJECT |
27 | Q_DISABLE_COPY_MOVE(QSslServer) |
28 | |
29 | public: |
30 | explicit QSslServer(QObject *parent = nullptr); |
31 | ~QSslServer() override; |
32 | |
33 | void setSslConfiguration(const QSslConfiguration &sslConfiguration); |
34 | QSslConfiguration sslConfiguration() const; |
35 | |
36 | void setHandshakeTimeout(int timeout); |
37 | int handshakeTimeout() const; |
38 | |
39 | Q_SIGNALS: |
40 | void sslErrors(QSslSocket *socket, const QList<QSslError> &errors); |
41 | void peerVerifyError(QSslSocket *socket, const QSslError &error); |
42 | void errorOccurred(QSslSocket *socket, QAbstractSocket::SocketError error); |
43 | void preSharedKeyAuthenticationRequired(QSslSocket *socket, |
44 | QSslPreSharedKeyAuthenticator *authenticator); |
45 | void alertSent(QSslSocket *socket, QSsl::AlertLevel level, |
46 | QSsl::AlertType type, const QString &description); |
47 | void alertReceived(QSslSocket *socket, QSsl::AlertLevel level, |
48 | QSsl::AlertType type, const QString &description); |
49 | void handshakeInterruptedOnError(QSslSocket *socket, const QSslError &error); |
50 | void startedEncryptionHandshake(QSslSocket *socket); |
51 | |
52 | protected: |
53 | void incomingConnection(qintptr socket) override; |
54 | |
55 | private: |
56 | Q_DECLARE_PRIVATE(QSslServer) |
57 | }; |
58 | |
59 | QT_END_NAMESPACE |
60 | |
61 | #endif // QSSLSERVER_H |
62 | |