Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qtlsbackend.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 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 "qtlsbackend_p.h"
5
6#if QT_CONFIG(ssl)
9#include "qsslsocket_p.h"
10#include "qsslcipher_p.h"
11#include "qsslkey_p.h"
12#include "qsslkey.h"
13#endif
14
15#include "qssl_p.h"
16
17#include <QtCore/private/qfactoryloader_p.h>
18
19#include "QtCore/qapplicationstatic.h"
20#include <QtCore/qbytearray.h>
21#include <QtCore/qmutex.h>
22
23#include <algorithm>
24#include <vector>
25
27
28using namespace Qt::StringLiterals;
29
31 QStringLiteral("/tls"))
32
33namespace {
34
35class BackendCollection
36{
37public:
38 void addBackend(QTlsBackend *backend)
39 {
40 Q_ASSERT(backend);
41 Q_ASSERT(std::find(backends.begin(), backends.end(), backend) == backends.end());
42 const QMutexLocker locker(&collectionMutex);
43 backends.push_back(backend);
44 }
45
46 void removeBackend(QTlsBackend *backend)
47 {
48 Q_ASSERT(backend);
49 const QMutexLocker locker(&collectionMutex);
50 const auto it = std::find(backends.begin(), backends.end(), backend);
51 Q_ASSERT(it != backends.end());
52 backends.erase(it);
53 }
54
55 bool tryPopulateCollection()
56 {
57 if (!qtlsbLoader())
58 return false;
59
60 Q_CONSTINIT static QBasicMutex mutex;
61 const QMutexLocker locker(&mutex);
62 if (backends.size())
63 return true;
64
65#if QT_CONFIG(library)
66 qtlsbLoader->update();
67#endif
68 int index = 0;
69 while (qtlsbLoader->instance(index))
70 ++index;
71
72 return true;
73 }
74
75 QList<QString> backendNames()
76 {
77 QList<QString> names;
78 if (!tryPopulateCollection())
79 return names;
80
81 const QMutexLocker locker(&collectionMutex);
82 if (!backends.size())
83 return names;
84
85 names.reserve(backends.size());
86 for (const auto *backend : backends) {
87 if (backend->isValid())
88 names.append(backend->backendName());
89 }
90
91 return names;
92 }
93
94 QTlsBackend *backend(const QString &name)
95 {
96 if (!tryPopulateCollection())
97 return nullptr;
98
99 const QMutexLocker locker(&collectionMutex);
100 const auto it = std::find_if(backends.begin(), backends.end(),
101 [&name](const auto *fct) {return fct->backendName() == name;});
102
103 return it == backends.end() ? nullptr : *it;
104 }
105
106private:
107 std::vector<QTlsBackend *> backends;
108 QMutex collectionMutex;
109};
110
111} // Unnamed namespace
112
113Q_GLOBAL_STATIC(BackendCollection, backends);
114
155 QStringLiteral("schannel"),
156 QStringLiteral("securetransport"),
157 QStringLiteral("openssl"),
158 QStringLiteral("cert-only")
159};
160
168{
169 if (backends())
170 backends->addBackend(this);
171
174 delete this;
175 });
176 }
177}
178
186{
187 if (backends())
188 backends->removeBackend(this);
189}
190
204{
205 return true;
206}
207
217{
218 return 0;
219}
220
231{
232 return {};
233}
234
245{
246 return 0;
247}
248
258{
259 return {};
260}
261
268{
269}
270
271#define REPORT_MISSING_SUPPORT(message) \
272 qCWarning(lcSsl) << "The backend" << backendName() << message
273
284{
285 REPORT_MISSING_SUPPORT("does not support QSslKey");
286 return nullptr;
287}
288
299{
300 REPORT_MISSING_SUPPORT("does not support QSslCertificate");
301 return nullptr;
302}
303
312QList<QSslCertificate> QTlsBackend::systemCaCertificates() const
313{
314 REPORT_MISSING_SUPPORT("does not provide system CA certificates");
315 return {};
316}
317
327QTlsPrivate::TlsCryptograph *QTlsBackend::createTlsCryptograph() const
328{
329 REPORT_MISSING_SUPPORT("does not support QSslSocket");
330 return nullptr;
331}
332
342QTlsPrivate::DtlsCryptograph *QTlsBackend::createDtlsCryptograph(QDtls *qObject, int mode) const
343{
344 Q_UNUSED(qObject);
345 Q_UNUSED(mode);
346 REPORT_MISSING_SUPPORT("does not support QDtls");
347 return nullptr;
348}
349
359QTlsPrivate::DtlsCookieVerifier *QTlsBackend::createDtlsCookieVerifier() const
360{
361 REPORT_MISSING_SUPPORT("does not support DTLS cookies");
362 return nullptr;
363}
364
376{
377 REPORT_MISSING_SUPPORT("does not support (manual) certificate verification");
378 return nullptr;
379}
380
389{
390 REPORT_MISSING_SUPPORT("cannot read PEM format");
391 return nullptr;
392}
393
402{
403 REPORT_MISSING_SUPPORT("cannot read DER format");
404 return nullptr;
405}
406
415{
416 REPORT_MISSING_SUPPORT("cannot read PKCS12 format");
417 return nullptr;
418}
419
432{
433 REPORT_MISSING_SUPPORT("does not support QSslEllipticCurve");
434 return {};
435}
436
449{
450 Q_UNUSED(name);
451 REPORT_MISSING_SUPPORT("does not support QSslEllipticCurve");
452 return 0;
453}
454
467{
468 Q_UNUSED(name);
469 REPORT_MISSING_SUPPORT("does not support QSslEllipticCurve");
470 return 0;
471}
472
484{
485 Q_UNUSED(cid);
486 REPORT_MISSING_SUPPORT("does not support QSslEllipticCurve");
487 return {};
488}
489
501{
502 Q_UNUSED(cid);
503 REPORT_MISSING_SUPPORT("does not support QSslEllipticCurve");
504 return {};
505}
506
516{
517 Q_UNUSED(cid);
518 REPORT_MISSING_SUPPORT("does not support QSslEllipticCurve");
519 return false;
520}
521
533{
534 Q_UNUSED(derData);
535 Q_UNUSED(data);
536 REPORT_MISSING_SUPPORT("does not support QSslDiffieHellmanParameters in DER format");
537 return {};
538}
539
551{
552 Q_UNUSED(pemData);
553 Q_UNUSED(data);
554 REPORT_MISSING_SUPPORT("does not support QSslDiffieHellmanParameters in PEM format");
555 return {};
556}
557
567{
568 if (!backends())
569 return {};
570
571 return backends->backendNames();
572}
573
580{
581 // We prefer OpenSSL as default:
582 const auto names = availableBackendNames();
584 if (names.contains(name))
585 return name;
587 if (names.contains(name))
588 return name;
590 if (names.contains(name))
591 return name;
592
593 const auto pos = std::find_if(names.begin(), names.end(), [](const auto &name) {
594 return name != builtinBackendNames[nameIndexCertOnly];
595 });
596
597 if (pos != names.end())
598 return *pos;
599
600 if (names.size())
601 return names[0];
602
603 return {};
604}
605
614{
615 if (!backends())
616 return {};
617
618 if (auto *fct = backends->backend(backendName))
619 return fct;
620
621 qCWarning(lcSsl) << "Cannot create unknown backend named" << backendName;
622 return nullptr;
623}
624
633{
634#if QT_CONFIG(ssl)
636#else
638#endif // QT_CONFIG(ssl)
639}
640
653{
654 if (!backends())
655 return {};
656
657 if (const auto *fct = backends->backend(backendName))
658 return fct->supportedProtocols();
659
660 return {};
661}
662
672QList<QSsl::SupportedFeature> QTlsBackend::supportedFeatures(const QString &backendName)
673{
674 if (!backends())
675 return {};
676
677 if (const auto *fct = backends->backend(backendName))
678 return fct->supportedFeatures();
679
680 return {};
681}
682
691QList<QSsl::ImplementedClass> QTlsBackend::implementedClasses(const QString &backendName)
692{
693 if (!backends())
694 return {};
695
696 if (const auto *fct = backends->backend(backendName))
697 return fct->implementedClasses();
698
699 return {};
700}
701
707{
708#if QT_CONFIG(ssl)
709 key.d->backend.reset(keyBackend);
710#else
711 Q_UNUSED(key);
712 Q_UNUSED(keyBackend);
713#endif // QT_CONFIG(ssl)
714}
715
722 int hintLength, unsigned maxIdentityLen, unsigned maxPskLen)
723{
724 Q_ASSERT(auth);
725#if QT_CONFIG(ssl)
726 if (hint)
727 auth->d->identityHint = QByteArray::fromRawData(hint, hintLength); // it's NUL terminated, but do not include the NUL
728
729 auth->d->maximumIdentityLength = int(maxIdentityLen) - 1; // needs to be NUL terminated
730 auth->d->maximumPreSharedKeyLength = int(maxPskLen);
731#else
732 Q_UNUSED(auth);
733 Q_UNUSED(hint);
734 Q_UNUSED(hintLength);
735 Q_UNUSED(maxIdentityLen);
736 Q_UNUSED(maxPskLen);
737#endif
738}
739
746 const QByteArray &identityHint, unsigned int maxPskLen)
747{
748#if QT_CONFIG(ssl)
749 Q_ASSERT(auth);
750 auth->d->identityHint = identityHint;
751 auth->d->identity = identity;
752 auth->d->maximumIdentityLength = 0; // user cannot set an identity
753 auth->d->maximumPreSharedKeyLength = int(maxPskLen);
754#else
755 Q_UNUSED(auth);
756 Q_UNUSED(identity);
757 Q_UNUSED(identityHint);
758 Q_UNUSED(maxPskLen);
759#endif
760}
761
762#if QT_CONFIG(ssl)
771QSslCipher QTlsBackend::createCiphersuite(const QString &descriptionOneLine, int bits, int supportedBits)
772{
773 QSslCipher ciph;
774
775 const auto descriptionList = QStringView{descriptionOneLine}.split(u' ', Qt::SkipEmptyParts);
776 if (descriptionList.size() > 5) {
777 ciph.d->isNull = false;
778 ciph.d->name = descriptionList.at(0).toString();
779
780 QStringView protoString = descriptionList.at(1);
781 ciph.d->protocolString = protoString.toString();
782 ciph.d->protocol = QSsl::UnknownProtocol;
785 if (protoString.startsWith(u"TLSv1")) {
786 QStringView tail = protoString.sliced(5);
787 if (tail.startsWith(u'.')) {
788 tail = tail.sliced(1);
789 if (tail == u"3")
790 ciph.d->protocol = QSsl::TlsV1_3;
791 else if (tail == u"2")
792 ciph.d->protocol = QSsl::TlsV1_2;
793 else if (tail == u"1")
794 ciph.d->protocol = QSsl::TlsV1_1;
795 } else if (tail.isEmpty()) {
796 ciph.d->protocol = QSsl::TlsV1_0;
797 }
798 }
800
801 if (descriptionList.at(2).startsWith("Kx="_L1))
802 ciph.d->keyExchangeMethod = descriptionList.at(2).mid(3).toString();
803 if (descriptionList.at(3).startsWith("Au="_L1))
804 ciph.d->authenticationMethod = descriptionList.at(3).mid(3).toString();
805 if (descriptionList.at(4).startsWith("Enc="_L1))
806 ciph.d->encryptionMethod = descriptionList.at(4).mid(4).toString();
807 ciph.d->exportable = (descriptionList.size() > 6 && descriptionList.at(6) == "export"_L1);
808
809 ciph.d->bits = bits;
810 ciph.d->supportedBits = supportedBits;
811 }
812
813 return ciph;
814}
815
824QSslCipher QTlsBackend::createCiphersuite(const QString &suiteName, QSsl::SslProtocol protocol,
825 const QString &protocolString)
826{
827 QSslCipher ciph;
828
829 if (!suiteName.size())
830 return ciph;
831
832 ciph.d->isNull = false;
833 ciph.d->name = suiteName;
834 ciph.d->protocol = protocol;
835 ciph.d->protocolString = protocolString;
836
837 const auto bits = QStringView{ciph.d->name}.split(u'-');
838 if (bits.size() >= 2) {
839 if (bits.size() == 2 || bits.size() == 3)
840 ciph.d->keyExchangeMethod = "RSA"_L1;
841 else if (bits.front() == "DH"_L1 || bits.front() == "DHE"_L1)
842 ciph.d->keyExchangeMethod = "DH"_L1;
843 else if (bits.front() == "ECDH"_L1 || bits.front() == "ECDHE"_L1)
844 ciph.d->keyExchangeMethod = "ECDH"_L1;
845 else
846 qCWarning(lcSsl) << "Unknown Kx" << ciph.d->name;
847
848 if (bits.size() == 2 || bits.size() == 3)
849 ciph.d->authenticationMethod = "RSA"_L1;
850 else if (ciph.d->name.contains("-ECDSA-"_L1))
851 ciph.d->authenticationMethod = "ECDSA"_L1;
852 else if (ciph.d->name.contains("-RSA-"_L1))
853 ciph.d->authenticationMethod = "RSA"_L1;
854 else
855 qCWarning(lcSsl) << "Unknown Au" << ciph.d->name;
856
857 if (ciph.d->name.contains("RC4-"_L1)) {
858 ciph.d->encryptionMethod = "RC4(128)"_L1;
859 ciph.d->bits = 128;
860 ciph.d->supportedBits = 128;
861 } else if (ciph.d->name.contains("DES-CBC3-"_L1)) {
862 ciph.d->encryptionMethod = "3DES(168)"_L1;
863 ciph.d->bits = 168;
864 ciph.d->supportedBits = 168;
865 } else if (ciph.d->name.contains("AES128-"_L1)) {
866 ciph.d->encryptionMethod = "AES(128)"_L1;
867 ciph.d->bits = 128;
868 ciph.d->supportedBits = 128;
869 } else if (ciph.d->name.contains("AES256-GCM"_L1)) {
870 ciph.d->encryptionMethod = "AESGCM(256)"_L1;
871 ciph.d->bits = 256;
872 ciph.d->supportedBits = 256;
873 } else if (ciph.d->name.contains("AES256-"_L1)) {
874 ciph.d->encryptionMethod = "AES(256)"_L1;
875 ciph.d->bits = 256;
876 ciph.d->supportedBits = 256;
877 } else if (ciph.d->name.contains("CHACHA20-"_L1)) {
878 ciph.d->encryptionMethod = "CHACHA20"_L1;
879 ciph.d->bits = 256;
880 ciph.d->supportedBits = 256;
881 } else if (ciph.d->name.contains("NULL-"_L1)) {
882 ciph.d->encryptionMethod = "NULL"_L1;
883 } else {
884 qCWarning(lcSsl) << "Unknown Enc" << ciph.d->name;
885 }
886 }
887 return ciph;
888}
889
900QSslCipher QTlsBackend::createCiphersuite(const QString &name, const QString &keyExchangeMethod,
901 const QString &encryptionMethod,
902 const QString &authenticationMethod,
903 int bits, QSsl::SslProtocol protocol,
904 const QString &protocolString)
905{
906 QSslCipher cipher;
907 cipher.d->isNull = false;
908 cipher.d->name = name;
909 cipher.d->bits = bits;
910 cipher.d->supportedBits = bits;
911 cipher.d->keyExchangeMethod = keyExchangeMethod;
912 cipher.d->encryptionMethod = encryptionMethod;
913 cipher.d->authenticationMethod = authenticationMethod;
914 cipher.d->protocol = protocol;
915 cipher.d->protocolString = protocolString;
916 return cipher;
917}
918
925QList<QSslCipher> QTlsBackend::defaultCiphers()
926{
928}
929
934QList<QSslCipher> QTlsBackend::defaultDtlsCiphers()
935{
937}
938
945void QTlsBackend::setDefaultCiphers(const QList<QSslCipher> &ciphers)
946{
948}
949
956void QTlsBackend::setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers)
957{
959}
960
967void QTlsBackend::setDefaultSupportedCiphers(const QList<QSslCipher> &ciphers)
968{
970}
971
977void QTlsBackend::resetDefaultEllipticCurves()
978{
980}
981
988void QTlsBackend::setDefaultCaCertificates(const QList<QSslCertificate> &certs)
989{
991}
992
997bool QTlsBackend::rootLoadingOnDemandAllowed(const QSslConfiguration &configuration)
998{
999 return configuration.d->allowRootCertOnDemandLoading;
1000}
1001
1006void QTlsBackend::storePeerCertificate(QSslConfiguration &configuration,
1007 const QSslCertificate &peerCert)
1008{
1009 configuration.d->peerCertificate = peerCert;
1010}
1011
1016void QTlsBackend::storePeerCertificateChain(QSslConfiguration &configuration,
1017 const QList<QSslCertificate> &peerChain)
1018{
1019 configuration.d->peerCertificateChain = peerChain;
1020}
1021
1026void QTlsBackend::clearPeerCertificates(QSslConfiguration &configuration)
1027{
1028 configuration.d->peerCertificate.clear();
1029 configuration.d->peerCertificateChain.clear();
1030}
1031
1036void QTlsBackend::clearPeerCertificates(QSslSocketPrivate *d)
1037{
1038 Q_ASSERT(d);
1039 d->configuration.peerCertificate.clear();
1040 d->configuration.peerCertificateChain.clear();
1041}
1042
1047void QTlsBackend::setPeerSessionShared(QSslSocketPrivate *d, bool shared)
1048{
1049 Q_ASSERT(d);
1050 d->configuration.peerSessionShared = shared;
1051}
1052
1057void QTlsBackend::setSessionAsn1(QSslSocketPrivate *d, const QByteArray &asn1)
1058{
1059 Q_ASSERT(d);
1060 d->configuration.sslSession = asn1;
1061}
1062
1067void QTlsBackend::setSessionLifetimeHint(QSslSocketPrivate *d, int hint)
1068{
1069 Q_ASSERT(d);
1070 d->configuration.sslSessionTicketLifeTimeHint = hint;
1071}
1072
1077void QTlsBackend::setAlpnStatus(QSslSocketPrivate *d, AlpnNegotiationStatus st)
1078{
1079 Q_ASSERT(d);
1080 d->configuration.nextProtocolNegotiationStatus = st;
1081}
1082
1087void QTlsBackend::setNegotiatedProtocol(QSslSocketPrivate *d, const QByteArray &protocol)
1088{
1089 Q_ASSERT(d);
1090 d->configuration.nextNegotiatedProtocol = protocol;
1091}
1092
1097void QTlsBackend::storePeerCertificate(QSslSocketPrivate *d, const QSslCertificate &peerCert)
1098{
1099 Q_ASSERT(d);
1100 d->configuration.peerCertificate = peerCert;
1101}
1102
1111void QTlsBackend::storePeerCertificateChain(QSslSocketPrivate *d,
1112 const QList<QSslCertificate> &peerChain)
1113{
1114 Q_ASSERT(d);
1115 d->configuration.peerCertificateChain = peerChain;
1116}
1117
1125void QTlsBackend::addTustedRoot(QSslSocketPrivate *d, const QSslCertificate &rootCert)
1126{
1127 Q_ASSERT(d);
1128 if (!d->configuration.caCertificates.contains(rootCert))
1129 d->configuration.caCertificates += rootCert;
1130}
1131
1139void QTlsBackend::setEphemeralKey(QSslSocketPrivate *d, const QSslKey &key)
1140{
1141 Q_ASSERT(d);
1142 d->configuration.ephemeralServerKey = key;
1143}
1144
1151void QTlsBackend::forceAutotestSecurityLevel()
1152{
1153}
1154
1155#endif // QT_CONFIG(ssl)
1156
1157namespace QTlsPrivate {
1158
1372TlsKey::~TlsKey() = default;
1373
1381{
1382 if (type() == QSsl::PublicKey)
1383 return QByteArrayLiteral("-----BEGIN PUBLIC KEY-----");
1384 else if (algorithm() == QSsl::Rsa)
1385 return QByteArrayLiteral("-----BEGIN RSA PRIVATE KEY-----");
1386 else if (algorithm() == QSsl::Dsa)
1387 return QByteArrayLiteral("-----BEGIN DSA PRIVATE KEY-----");
1388 else if (algorithm() == QSsl::Ec)
1389 return QByteArrayLiteral("-----BEGIN EC PRIVATE KEY-----");
1390 else if (algorithm() == QSsl::Dh)
1391 return QByteArrayLiteral("-----BEGIN PRIVATE KEY-----");
1392
1393 Q_UNREACHABLE_RETURN({});
1394}
1395
1402{
1403 if (type() == QSsl::PublicKey)
1404 return QByteArrayLiteral("-----END PUBLIC KEY-----");
1405 else if (algorithm() == QSsl::Rsa)
1406 return QByteArrayLiteral("-----END RSA PRIVATE KEY-----");
1407 else if (algorithm() == QSsl::Dsa)
1408 return QByteArrayLiteral("-----END DSA PRIVATE KEY-----");
1409 else if (algorithm() == QSsl::Ec)
1410 return QByteArrayLiteral("-----END EC PRIVATE KEY-----");
1411 else if (algorithm() == QSsl::Dh)
1412 return QByteArrayLiteral("-----END PRIVATE KEY-----");
1413
1414 Q_UNREACHABLE_RETURN({});
1415}
1416
1689
1696{
1697 return nullptr;
1698}
1699
1700#if QT_CONFIG(ssl)
1701
1838TlsCryptograph::~TlsCryptograph() = default;
1839
1850void TlsCryptograph::checkSettingSslContext(std::shared_ptr<QSslContext> tlsContext)
1851{
1852 Q_UNUSED(tlsContext);
1853}
1854
1863std::shared_ptr<QSslContext> TlsCryptograph::sslContext() const
1864{
1865 return {};
1866}
1867
1878void TlsCryptograph::enableHandshakeContinuation()
1879{
1880}
1881
1889void TlsCryptograph::cancelCAFetch()
1890{
1891}
1892
1902bool TlsCryptograph::hasUndecryptedData() const
1903{
1904 return false;
1905}
1906
1914QList<QOcspResponse> TlsCryptograph::ocsps() const
1915{
1916 return {};
1917}
1918
1925bool TlsCryptograph::isMatchingHostname(const QSslCertificate &certificate, const QString &peerName)
1926{
1927 return QSslSocketPrivate::isMatchingHostname(certificate, peerName);
1928}
1929
1935void TlsCryptograph::setErrorAndEmit(QSslSocketPrivate *d, QAbstractSocket::SocketError errorCode,
1936 const QString &errorDescription) const
1937{
1938 Q_ASSERT(d);
1939 d->setErrorAndEmit(errorCode, errorDescription);
1940}
1941
1942#if QT_CONFIG(dtls)
2046DtlsBase::~DtlsBase() = default;
2047
2338#endif // QT_CONFIG(dtls)
2339#endif // QT_CONFIG(ssl)
2340
2341} // namespace QTlsPrivate
2342
2343#if QT_CONFIG(ssl)
2347Q_NETWORK_EXPORT void qt_ForceTlsSecurityLevel()
2348{
2349 if (auto *backend = QSslSocketPrivate::tlsBackendInUse())
2350 backend->forceAutotestSecurityLevel();
2351}
2352
2353#endif // QT_CONFIG(ssl)
2354
2356
2357#include "moc_qtlsbackend_p.cpp"
SocketError
This enum describes the socket errors that can occur.
\inmodule QtCore
Definition qbytearray.h:57
static QByteArray fromRawData(const char *data, qsizetype size)
Constructs a QByteArray that uses the first size bytes of the data array.
Definition qbytearray.h:409
static QCoreApplication * instance() noexcept
Returns a pointer to the application's QCoreApplication (or QGuiApplication/QApplication) instance.
This class provides encryption for UDP sockets.
Definition qdtls.h:83
void clear()
Definition qlist.h:434
\inmodule QtCore
Definition qmutex.h:313
\inmodule QtCore
Definition qmutex.h:281
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
iterator end()
Definition qset.h:140
The QSslCertificate class provides a convenient API for an X509 certificate.
void clear()
Clears the contents of this certificate, making it a null certificate.
The QSslCipher class represents an SSL cryptographic cipher.
Definition qsslcipher.h:22
QList< QSslCertificate > peerCertificateChain
The QSslConfiguration class holds the configuration and state of an SSL connection.
The QSslKey class provides an interface for private and public keys.
Definition qsslkey.h:23
The QSslPreSharedKeyAuthenticator class provides authentication data for pre shared keys (PSK) cipher...
static void setDefaultCaCertificates(const QList< QSslCertificate > &certs)
static void setDefaultDtlsCiphers(const QList< QSslCipher > &ciphers)
static QTlsBackend * tlsBackendInUse()
static void setDefaultCiphers(const QList< QSslCipher > &ciphers)
static QList< QSslCipher > defaultDtlsCiphers()
static void resetDefaultEllipticCurves()
static bool isMatchingHostname(const QSslCertificate &cert, const QString &peerName)
static QList< QSslCipher > defaultCiphers()
static void setDefaultSupportedCiphers(const QList< QSslCipher > &ciphers)
\inmodule QtCore
Definition qstringview.h:78
bool startsWith(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
constexpr bool isEmpty() const noexcept
Returns whether this string view is empty - that is, whether {size() == 0}.
Q_CORE_EXPORT QList< QStringView > split(QStringView sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Splits the view into substring views wherever sep occurs, and returns the list of those string views.
Definition qstring.cpp:8249
constexpr QChar at(qsizetype n) const noexcept
Returns the character at position n in this string view.
constexpr QStringView sliced(qsizetype pos) const noexcept
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QTlsBackend is a factory class, providing implementations for the QSsl classes.
virtual QList< QSslCertificate > systemCaCertificates() const
virtual QTlsPrivate::X509PemReaderPtr X509PemReader() const
virtual long tlsLibraryVersionNumber() const
virtual QList< QSsl::SupportedFeature > supportedFeatures() const =0
virtual int curveIdFromLongName(const QString &name) const
static void resetBackend(QSslKey &key, QTlsPrivate::TlsKey *keyBackend)
virtual QTlsPrivate::DtlsCryptograph * createDtlsCryptograph(class QDtls *qObject, int mode) const
~QTlsBackend() override
static constexpr const int nameIndexSchannel
virtual QTlsPrivate::DtlsCookieVerifier * createDtlsCookieVerifier() const
static constexpr const int nameIndexSecureTransport
virtual QString shortNameForId(int cid) const
virtual QString backendName() const =0
static void setupClientPskAuth(QSslPreSharedKeyAuthenticator *auth, const char *hint, int hintLength, unsigned maxIdentityLen, unsigned maxPskLen)
virtual int dhParametersFromPem(const QByteArray &pemData, QByteArray *data) const
virtual QList< QSsl::SslProtocol > supportedProtocols() const =0
static QList< QString > availableBackendNames()
virtual QTlsPrivate::TlsCryptograph * createTlsCryptograph() const
virtual QTlsPrivate::TlsKey * createKey() const
virtual QList< QSsl::ImplementedClass > implementedClasses() const =0
virtual long tlsLibraryBuildVersionNumber() const
virtual QString longNameForId(int cid) const
virtual void ensureInitialized() const
virtual bool isTlsNamedCurve(int cid) const
static constexpr const int nameIndexOpenSSL
virtual QList< int > ellipticCurvesIds() const
virtual QTlsPrivate::X509Pkcs12ReaderPtr X509Pkcs12Reader() const
virtual QString tlsLibraryBuildVersionString() const
virtual bool isValid() const
static QString defaultBackendName()
virtual QString tlsLibraryVersionString() const
virtual int curveIdFromShortName(const QString &name) const
virtual QTlsPrivate::X509Certificate * createCertificate() const
static const QString builtinBackendNames[]
virtual QTlsPrivate::X509DerReaderPtr X509DerReader() const
static QTlsBackend * activeOrAnyBackend()
static QTlsBackend * findBackend(const QString &backendName)
virtual QTlsPrivate::X509ChainVerifyPtr X509Verifier() const
virtual int dhParametersFromDer(const QByteArray &derData, QByteArray *data) const
static void setupServerPskAuth(QSslPreSharedKeyAuthenticator *auth, const char *identity, const QByteArray &identityHint, unsigned maxPskLen)
TlsKey is an abstract class, that allows a TLS plugin to provide an underlying implementation for the...
virtual KeyType type() const =0
QByteArray pemHeader() const
QByteArray pemFooter() const
virtual KeyAlgorithm algorithm() const =0
X509Certificate is an abstract class that allows a TLS backend to provide an implementation of the QS...
virtual TlsKey * publicKey() const
QSet< QString >::iterator it
@ PublicKey
Definition qssl.h:24
@ Rsa
Definition qssl.h:36
@ Ec
Definition qssl.h:38
@ Dsa
Definition qssl.h:37
@ Dh
Definition qssl.h:39
SslProtocol
Describes the protocol of the cipher.
Definition qssl.h:50
@ TlsV1_3
Definition qssl.h:66
@ TlsV1_2
Definition qssl.h:53
@ UnknownProtocol
Definition qssl.h:69
Combined button and popup list for selecting options.
Namespace containing onternal types that TLS backends implement.
QList< QSslCertificate >(*)(const QByteArray &pem, int count) X509PemReaderPtr
bool(*)(QIODevice *device, QSslKey *key, QSslCertificate *cert, QList< QSslCertificate > *caCertificates, const QByteArray &passPhrase) X509Pkcs12ReaderPtr
QList< QSslError >(*)(const QList< QSslCertificate > &chain, const QString &hostName) X509ChainVerifyPtr
X509PemReaderPtr X509DerReaderPtr
@ SkipEmptyParts
Definition qnamespace.h:128
#define Q_APPLICATION_STATIC(TYPE, NAME,...)
#define QByteArrayLiteral(str)
Definition qbytearray.h:52
#define QT_WARNING_POP
#define QT_WARNING_DISABLE_DEPRECATED
#define QT_WARNING_PUSH
static QString backendName
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
#define qCWarning(category,...)
GLenum mode
GLuint64 key
GLuint index
[2]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint name
GLuint GLuint * names
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const void * bits
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define QStringLiteral(str)
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
#define REPORT_MISSING_SUPPORT(message)
#define QTlsBackend_iid
#define Q_UNUSED(x)
QObject::connect nullptr
QMutex mutex
[2]
const auto certs
[1]