Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qtls_openssl_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QTLS_OPENSSL_P_H
5#define QTLS_OPENSSL_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtNetwork/private/qtnetworkglobal_p.h>
19
22#include "qopenssl_p.h"
23
24#include <QtNetwork/qsslcertificate.h>
25#include <QtNetwork/qocspresponse.h>
26
27#include <QtCore/qsharedpointer.h>
28#include <QtCore/qbytearray.h>
29#include <QtCore/qglobal.h>
30#include <QtCore/qlist.h>
31
33
34namespace QTlsPrivate {
35
36class TlsCryptographOpenSSL : public TlsCryptograph
37{
38public:
43
45
46 void init(QSslSocket *qObj, QSslSocketPrivate *dObj) override;
47 void checkSettingSslContext(std::shared_ptr<QSslContext> tlsContext) override;
48 std::shared_ptr<QSslContext> sslContext() const override;
49
50 QList<QSslError> tlsErrors() const override;
51
52 void startClientEncryption() override;
53 void startServerEncryption() override;
54 bool startHandshake();
55 void enableHandshakeContinuation() override;
56 void cancelCAFetch() override;
57 void continueHandshake() override;
58 void transmit() override;
59 void disconnectFromHost() override;
60 void disconnected() override;
61 QSslCipher sessionCipher() const override;
62 QSsl::SslProtocol sessionProtocol() const override;
63 QList<QOcspResponse> ocsps() const override;
64
65 bool checkSslErrors();
67
68 void alertMessageSent(int encoded);
70
71 int emitErrorFromCallback(X509_STORE_CTX *ctx);
72 void trySendFatalAlert();
73
74#if QT_CONFIG(ocsp)
75 bool checkOcspStatus();
76#endif
77
78 QSslSocket *q = nullptr;
79 QSslSocketPrivate *d = nullptr;
80
82
83 unsigned pskClientTlsCallback(const char *hint, char *identity, unsigned max_identity_len,
84 unsigned char *psk, unsigned max_psk_len);
85 unsigned pskServerTlsCallback(const char *identity, unsigned char *psk,
86 unsigned max_psk_len);
87
88 bool isInSslRead() const;
89 void setRenegotiated(bool renegotiated);
90
91#ifdef Q_OS_WIN
92 void fetchCaRootForCert(const QSslCertificate &cert);
93 void caRootLoaded(QSslCertificate certificate, QSslCertificate trustedRoot);
94#endif
95
97private:
98 // TLSTODO: names were preserved, to make comparison
99 // easier (see qsslsocket_openssl.cpp, while it exists).
100 bool initSslContext();
101 void destroySslContext();
102
103 std::shared_ptr<QSslContext> sslContextPointer;
104 SSL *ssl = nullptr; // TLSTODO: RAII.
105
106 QList<QSslErrorEntry> errorList;
107 QList<QSslError> sslErrors;
108
109 BIO *readBio = nullptr;
110 BIO *writeBio = nullptr;
111
112 QList<QOcspResponse> ocspResponses;
113
114 // This description will go to setErrorAndEmit(SslHandshakeError, ocspErrorDescription)
115 QString ocspErrorDescription;
116 // These will go to sslErrors()
117 QList<QSslError> ocspErrors;
118
119 bool systemOrSslErrorDetected = false;
120 bool handshakeInterrupted = false;
121
122 bool fetchAuthorityInformation = false;
123 std::optional<QSslCertificate> caToFetch;
124
125 bool inSetAndEmitError = false;
126 bool pendingFatalAlert = false;
127 bool errorsReportedFromCallback = false;
128
129 bool shutdown = false;
130
131 bool inSslRead = false;
132 bool renegotiated = false;
133};
134
135} // namespace QTlsPrivate
136
138
139#endif // QTLS_OPENSSL_P_H
140
\inmodule QtCore
Definition qbytearray.h:57
The QSslCertificate class provides a convenient API for an X509 certificate.
The QSslCipher class represents an SSL cryptographic cipher.
Definition qsslcipher.h:22
The QSslSocket class provides an SSL encrypted socket for both clients and servers.
Definition qsslsocket.h:29
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
void checkSettingSslContext(std::shared_ptr< QSslContext > tlsContext) override
unsigned pskClientTlsCallback(const char *hint, char *identity, unsigned max_identity_len, unsigned char *psk, unsigned max_psk_len)
std::shared_ptr< QSslContext > sslContext() const override
int handleNewSessionTicket(SSL *connection)
QList< QOcspResponse > ocsps() const override
int emitErrorFromCallback(X509_STORE_CTX *ctx)
unsigned pskServerTlsCallback(const char *identity, unsigned char *psk, unsigned max_psk_len)
QSsl::SslProtocol sessionProtocol() const override
void init(QSslSocket *qObj, QSslSocketPrivate *dObj) override
QList< QSslError > tlsErrors() const override
void setRenegotiated(bool renegotiated)
QSslCipher sessionCipher() const override
EGLContext ctx
SslProtocol
Describes the protocol of the cipher.
Definition qssl.h:50
Combined button and popup list for selecting options.
Namespace containing onternal types that TLS backends implement.
DBusConnection * connection
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
QList< QSslCertificate > cert
[0]