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#include <QtCore/qfile.h>
5#include "qqmlsslkey_p.h"
6
7QT_BEGIN_NAMESPACE
8
9QSslKey QQmlSslKey::getSslKey() const
10{
11 if (m_keyFile.isEmpty()) {
12 qWarning() << "SslConfiguration::getSslKey: No key paths set";
13 return QSslKey();
14 }
15
16 QFile file(m_keyFile);
17 if (!file.open(flags: QIODevice::ReadOnly)) {
18 qWarning() << "SslConfiguration::getSslKey: Couldn't open file:" << m_keyFile;
19 return QSslKey();
20 }
21
22 return QSslKey(file.readAll(),
23 m_keyAlgorithm,
24 m_keyFormat,
25 m_keyType,
26 m_keyPassPhrase);
27}
28
29void QQmlSslKey::setKeyFile(const QString &key)
30{
31 if (m_keyFile == key)
32 return;
33
34 m_keyFile = key;
35}
36
37void QQmlSslKey::setKeyAlgorithm(QSsl::KeyAlgorithm value)
38{
39 if (m_keyAlgorithm == value)
40 return;
41
42 m_keyAlgorithm = value;
43}
44
45void QQmlSslKey::setKeyFormat(QSsl::EncodingFormat value)
46{
47 if (m_keyFormat == value)
48 return;
49
50 m_keyFormat = value;
51}
52
53void QQmlSslKey::setKeyPassPhrase(const QByteArray &value)
54{
55 if (m_keyPassPhrase == value)
56 return;
57
58 m_keyPassPhrase = value;
59}
60
61void QQmlSslKey::setKeyType(QSsl::KeyType type)
62{
63 if (m_keyType == type)
64 return;
65 m_keyType = type;
66}
67
68QT_END_NAMESPACE
69

Provided by KDAB

Privacy Policy
Start learning QML with our Intro Training
Find out more

source code of qtdeclarative/src/qmlnetwork/ssl/qqmlsslkey.cpp