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
4#ifndef QQMLSSLCONFIGURATION_P_H
5#define QQMLSSLCONFIGURATION_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 <qtqmlnetworkexports.h>
19#include "qqmlsslkey_p.h"
20
21#include <QtCore/QByteArray>
22#include <QtCore/QMetaType>
23#include <QtQml/qqml.h>
24#include <QtNetwork/qsslconfiguration.h>
25#include <QtNetwork/qsslsocket.h>
26#include <QtNetwork/qssl.h>
27
28QT_BEGIN_NAMESPACE
29
30class Q_QMLNETWORK_EXPORT QQmlSslConfiguration
31{
32 Q_GADGET
33
34 Q_PROPERTY(QString ciphers READ ciphers WRITE setCiphers)
35 Q_PROPERTY(QList<QSsl::SslOption> sslOptions READ sslOptions WRITE setSslOptions)
36 Q_PROPERTY(QSsl::SslProtocol protocol READ protocol WRITE setProtocol)
37 Q_PROPERTY(QSslSocket::PeerVerifyMode peerVerifyMode READ peerVerifyMode
38 WRITE setPeerVerifyMode)
39 Q_PROPERTY(int peerVerifyDepth READ peerVerifyDepth WRITE setPeerVerifyDepth)
40 Q_PROPERTY(QByteArray sessionTicket READ sessionTicket WRITE setSessionTicket)
41
42public:
43 Q_INVOKABLE void setCertificateFiles(const QStringList &certificateFiles);
44 Q_INVOKABLE void setPrivateKey(const QQmlSslKey &privateKey);
45
46 QString ciphers() const;
47 QList<QSsl::SslOption> sslOptions() const;
48 QSsl::SslProtocol protocol() const;
49 QSslSocket::PeerVerifyMode peerVerifyMode() const;
50 int peerVerifyDepth() const;
51 QByteArray sessionTicket() const;
52 QSslConfiguration const configuration();
53
54 void setProtocol(QSsl::SslProtocol protocol);
55 void setPeerVerifyMode(QSslSocket::PeerVerifyMode mode);
56 void setPeerVerifyDepth(int depth);
57 void setCiphers(const QString &ciphers);
58 void setSslOptions(const QList<QSsl::SslOption> &options);
59 void setSessionTicket(const QByteArray &sessionTicket);
60
61private:
62 inline friend bool operator==(const QQmlSslConfiguration &lval,
63 const QQmlSslConfiguration &rval)
64 {
65 return lval.m_certificateFiles == rval.m_certificateFiles
66 && lval.m_ciphers == rval.m_ciphers
67 && lval.m_sslOptions == rval.m_sslOptions
68 && lval.m_configuration == rval.m_configuration;
69 }
70
71 inline friend bool operator!=(const QQmlSslConfiguration &lval,
72 const QQmlSslConfiguration &rval)
73 {
74 return !(lval == rval);
75 }
76
77protected:
78 void setSslOptionsList(const QSslConfiguration &configuration);
79 void setCiphersList(const QSslConfiguration &configuration);
80
81 QStringList m_certificateFiles;
82 QString m_ciphers;
83 QList<QSsl::SslOption> m_sslOptions;
84 QSslConfiguration m_configuration;
85};
86
87class Q_QMLNETWORK_EXPORT QQmlSslDefaultConfiguration : public QQmlSslConfiguration
88{
89 Q_GADGET
90 QML_NAMED_ELEMENT(sslConfiguration)
91 QML_ADDED_IN_VERSION(6, 7)
92
93public:
94 QQmlSslDefaultConfiguration();
95};
96
97class Q_QMLNETWORK_EXPORT QQmlSslDefaultDtlsConfiguration : public QQmlSslConfiguration
98{
99 Q_GADGET
100 QML_NAMED_ELEMENT(sslDtlsConfiguration)
101 QML_ADDED_IN_VERSION(6, 7)
102
103public:
104 QQmlSslDefaultDtlsConfiguration();
105};
106
107QT_END_NAMESPACE
108
109#endif // QQMLSSLCONFIGURATION_P_H
110

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