Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqmlsslkey.cpp
Go to the documentation of this file.
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#include <QtCore/qfile.h>
6#include "qqmlsslkey_p.h"
7
9
10QSslKey QQmlSslKey::getSslKey() const
11{
12 if (m_keyFile.isEmpty()) {
13 qWarning() << "SslConfiguration::getSslKey: No key paths set";
14 return QSslKey();
15 }
16
17 QFile file(m_keyFile);
18 if (!file.open(QIODevice::ReadOnly)) {
19 qWarning() << "SslConfiguration::getSslKey: Couldn't open file:" << m_keyFile;
20 return QSslKey();
21 }
22
23 return QSslKey(file.readAll(),
24 m_keyAlgorithm,
25 m_keyFormat,
26 m_keyType,
27 m_keyPassPhrase);
28}
29
30void QQmlSslKey::setKeyFile(const QString &key)
31{
32 if (m_keyFile == key)
33 return;
34
35 m_keyFile = key;
36}
37
38void QQmlSslKey::setKeyAlgorithm(QSsl::KeyAlgorithm value)
39{
40 if (m_keyAlgorithm == value)
41 return;
42
43 m_keyAlgorithm = value;
44}
45
46void QQmlSslKey::setKeyFormat(QSsl::EncodingFormat value)
47{
48 if (m_keyFormat == value)
49 return;
50
51 m_keyFormat = value;
52}
53
54void QQmlSslKey::setKeyPassPhrase(const QByteArray &value)
55{
56 if (m_keyPassPhrase == value)
57 return;
58
59 m_keyPassPhrase = value;
60}
61
62void QQmlSslKey::setKeyType(QSsl::KeyType type)
63{
64 if (m_keyType == type)
65 return;
66 m_keyType = type;
67}
68
69QT_END_NAMESPACE