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 QQMLSSLKEY_P_H
5#define QQMLSSLKEY_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
20#include <QtCore/QByteArray>
21#include <QtCore/QMetaType>
22#include <QtNetwork/qsslkey.h>
23#include <QtNetwork/qssl.h>
24#include <QtQml/qqml.h>
25
26QT_BEGIN_NAMESPACE
27
28class Q_QMLNETWORK_EXPORT QQmlSslKey
29{
30 Q_GADGET
31 QML_NAMED_ELEMENT(sslKey)
32 QML_ADDED_IN_VERSION(6, 7)
33
34 Q_PROPERTY(QString keyFile READ keyFile
35 WRITE setKeyFile)
36 Q_PROPERTY(QSsl::KeyAlgorithm keyAlgorithm READ keyAlgorithm
37 WRITE setKeyAlgorithm)
38 Q_PROPERTY(QSsl::EncodingFormat keyFormat READ keyFormat
39 WRITE setKeyFormat)
40 Q_PROPERTY(QByteArray keyPassPhrase READ keyPassPhrase
41 WRITE setKeyPassPhrase)
42 Q_PROPERTY(QSsl::KeyType keyType READ keyType WRITE setKeyType)
43
44public:
45 QSslKey getSslKey() const;
46 QString keyFile() const { return m_keyFile; }
47 QSsl::KeyAlgorithm keyAlgorithm() const { return m_keyAlgorithm; }
48 QSsl::EncodingFormat keyFormat() const { return m_keyFormat; }
49 QByteArray keyPassPhrase() const { return m_keyPassPhrase; }
50 QSsl::KeyType keyType() const { return m_keyType; }
51
52 void setKeyFile(const QString &key);
53 void setKeyAlgorithm(QSsl::KeyAlgorithm value);
54 void setKeyFormat(QSsl::EncodingFormat value);
55 void setKeyPassPhrase(const QByteArray &value);
56 void setKeyType(QSsl::KeyType type);
57
58private:
59 inline friend bool operator==(const QQmlSslKey &lvalue, const QQmlSslKey &rvalue)
60 {
61 return (lvalue.m_keyFile == rvalue.m_keyFile
62 && lvalue.m_keyAlgorithm == rvalue.m_keyAlgorithm
63 && lvalue.m_keyFormat == rvalue.m_keyFormat
64 && lvalue.m_keyType == rvalue.m_keyType
65 && lvalue.m_keyPassPhrase == rvalue.m_keyPassPhrase);
66 }
67
68 QString m_keyFile;
69 QByteArray m_keyPassPhrase;
70 QSsl::KeyAlgorithm m_keyAlgorithm = QSsl::Rsa;
71 QSsl::EncodingFormat m_keyFormat = QSsl::Pem;
72 QSsl::KeyType m_keyType = QSsl::PrivateKey;
73};
74
75QT_END_NAMESPACE
76
77#endif // QQMLSSLKEY_P_H
78

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