1// Copyright (C) 2023 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// Qt-Security score:significant reason:default
4
5#ifndef QQMLSSLCONFIGURATION_P_H
6#define QQMLSSLCONFIGURATION_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <qtqmlnetworkexports.h>
20#include "qqmlsslkey_p.h"
21
22#include <QtCore/QByteArray>
23#include <QtCore/QMetaType>
24#include <QtQml/qqml.h>
25#include <QtNetwork/qsslconfiguration.h>
26#include <QtNetwork/qsslsocket.h>
27#include <QtNetwork/qssl.h>
28
29QT_BEGIN_NAMESPACE
30
31class Q_QMLNETWORK_EXPORT QQmlSslConfiguration
32{
33 Q_GADGET
34
35 Q_PROPERTY(QString ciphers READ ciphers WRITE setCiphers)
36 Q_PROPERTY(QList<QSsl::SslOption> sslOptions READ sslOptions WRITE setSslOptions)
37 Q_PROPERTY(QSsl::SslProtocol protocol READ protocol WRITE setProtocol)
38 Q_PROPERTY(QSslSocket::PeerVerifyMode peerVerifyMode READ peerVerifyMode
39 WRITE setPeerVerifyMode)
40 Q_PROPERTY(int peerVerifyDepth READ peerVerifyDepth WRITE setPeerVerifyDepth)
41 Q_PROPERTY(QByteArray sessionTicket READ sessionTicket WRITE setSessionTicket)
42
43public:
44 Q_INVOKABLE void setCertificateFiles(const QStringList &certificateFiles);
45 Q_INVOKABLE void setPrivateKey(const QQmlSslKey &privateKey);
46
47 QString ciphers() const;
48 QList<QSsl::SslOption> sslOptions() const;
49 QSsl::SslProtocol protocol() const;
50 QSslSocket::PeerVerifyMode peerVerifyMode() const;
51 int peerVerifyDepth() const;
52 QByteArray sessionTicket() const;
53 QSslConfiguration const configuration();
54
55 void setProtocol(QSsl::SslProtocol protocol);
56 void setPeerVerifyMode(QSslSocket::PeerVerifyMode mode);
57 void setPeerVerifyDepth(int depth);
58 void setCiphers(const QString &ciphers);
59 void setSslOptions(const QList<QSsl::SslOption> &options);
60 void setSessionTicket(const QByteArray &sessionTicket);
61
62private:
63 inline friend bool operator==(const QQmlSslConfiguration &lval,
64 const QQmlSslConfiguration &rval)
65 {
66 return lval.m_certificateFiles == rval.m_certificateFiles
67 && lval.m_ciphers == rval.m_ciphers
68 && lval.m_sslOptions == rval.m_sslOptions
69 && lval.m_configuration == rval.m_configuration;
70 }
71
72 inline friend bool operator!=(const QQmlSslConfiguration &lval,
73 const QQmlSslConfiguration &rval)
74 {
75 return !(lval == rval);
76 }
77
78protected:
79 void setSslOptionsList(const QSslConfiguration &configuration);
80 void setCiphersList(const QSslConfiguration &configuration);
81
82 QStringList m_certificateFiles;
83 QString m_ciphers;
84 QList<QSsl::SslOption> m_sslOptions;
85 QSslConfiguration m_configuration;
86};
87
88class Q_QMLNETWORK_EXPORT QQmlSslDefaultConfiguration : public QQmlSslConfiguration
89{
90 Q_GADGET
91 QML_NAMED_ELEMENT(sslConfiguration)
92 QML_ADDED_IN_VERSION(6, 7)
93
94public:
95 QQmlSslDefaultConfiguration();
96};
97
98class Q_QMLNETWORK_EXPORT QQmlSslDefaultDtlsConfiguration : public QQmlSslConfiguration
99{
100 Q_GADGET
101 QML_NAMED_ELEMENT(sslDtlsConfiguration)
102 QML_ADDED_IN_VERSION(6, 7)
103
104public:
105 QQmlSslDefaultDtlsConfiguration();
106};
107
108QT_END_NAMESPACE
109
110#endif // QQMLSSLCONFIGURATION_P_H
111

source code of qtdeclarative/src/qmlnetwork/ssl/qqmlsslconfiguration_p.h