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
qsslcertificate.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 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
96#include <QtNetwork/qtnetworkglobal.h>
97
98#if QT_CONFIG(regularexpression)
99#include "qregularexpression.h"
100#endif
101
103#include "qsslcertificate_p.h"
104#include "qsslcertificate.h"
105#include "qssl_p.h"
106
107#ifndef QT_NO_SSL
108#include "qsslsocket_p.h"
109#include "qsslkey_p.h"
110#endif
111
112#include <QtCore/qdir.h>
113#include <QtCore/qdirlisting.h>
114#include <QtCore/qfile.h>
115
117
118using namespace Qt::StringLiterals;
119
121
123{
124#ifndef QT_NO_SSL
126#endif
127
128 const QTlsBackend *tlsBackend = QTlsBackend::activeOrAnyBackend();
129 if (tlsBackend)
130 backend.reset(tlsBackend->createCertificate());
131 else
132 qCWarning(lcSsl, "No TLS backend is available");
133}
134
136
145{
146 if (device) {
147 const auto data = device->readAll();
148 if (data.isEmpty())
149 return;
150
151 const auto *tlsBackend = QTlsBackend::activeOrAnyBackend();
152 if (!tlsBackend)
153 return;
154
155 auto *X509Reader = format == QSsl::Pem ? tlsBackend->X509PemReader() : tlsBackend->X509DerReader();
156 if (!X509Reader) {
157 qCWarning(lcSsl, "Current TLS plugin does not support reading from PEM/DER");
158 return;
159 }
160
161 QList<QSslCertificate> certs = X509Reader(data, 1);
162 if (!certs.isEmpty())
163 d = certs.first().d;
164 }
165}
166
175{
176 if (data.isEmpty())
177 return;
178
179 const auto *tlsBackend = QTlsBackend::activeOrAnyBackend();
180 if (!tlsBackend)
181 return;
182
183 auto *X509Reader = format == QSsl::Pem ? tlsBackend->X509PemReader() : tlsBackend->X509DerReader();
184 if (!X509Reader) {
185 qCWarning(lcSsl, "Current TLS plugin does not support reading from PEM/DER");
186 return;
187 }
188
189 const QList<QSslCertificate> certs = X509Reader(data, 1);
190 if (!certs.isEmpty())
191 d = certs.first().d;
192}
193
200
207
213{
214 d = other.d;
215 return *this;
216}
217
234{
235 if (d == other.d)
236 return true;
237
238 if (isNull() && other.isNull())
239 return true;
240
241 if (d->backend.get() && other.d->backend.get())
242 return d->backend->isEqual(*other.d->backend.get());
243
244 return false;
245}
246
265{
266 if (const auto *backend = d->backend.get())
267 return backend->isNull();
268
269 return true;
270}
271
282
294{
295 if (const auto *backend = d->backend.get())
296 return backend->isSelfSigned();
297
298 return false;
299}
300
308{
309 if (isNull())
310 return;
312}
313
319{
320 if (const auto *backend = d->backend.get())
321 return backend->version();
322
323 return {};
324}
325
332{
333 if (const auto *backend = d->backend.get())
334 return backend->serialNumber();
335
336 return {};
337}
338
348
360{
361 if (const auto *backend = d->backend.get())
362 return backend->issuerInfo(info);
363
364 return {};
365}
366
377{
378 if (const auto *backend = d->backend.get())
379 return backend->issuerInfo(attribute);
380
381 return {};
382}
383
394{
395 if (const auto *backend = d->backend.get())
396 return backend->subjectInfo(info);
397
398 return {};
399}
400
411{
412 if (const auto *backend = d->backend.get())
413 return backend->subjectInfo(attribute);
414
415 return {};
416}
417
431{
432 if (const auto *backend = d->backend.get())
433 return backend->subjectInfoAttributes();
434
435 return {};
436}
437
451{
452 if (const auto *backend = d->backend.get())
453 return backend->issuerInfoAttributes();
454
455 return {};
456}
457
473QMultiMap<QSsl::AlternativeNameEntryType, QString> QSslCertificate::subjectAlternativeNames() const
474{
475 if (const auto *backend = d->backend.get())
476 return backend->subjectAlternativeNames();
477
478 return {};
479}
480
490{
491 if (const auto *backend = d->backend.get())
492 return backend->effectiveDate();
493
494 return {};
495}
496
506{
507 if (const auto *backend = d->backend.get())
508 return backend->expiryDate();
509
510 return {};
511}
512
526{
527 if (const auto *backend = d->backend.get())
528 return backend->handle();
529
530 return {};
531}
532
533#ifndef QT_NO_SSL
539{
540 QSslKey key;
541 if (const auto *backend = d->backend.get())
542 QTlsBackend::resetBackend(key, backend->publicKey());
543
544 return key;
545}
546#endif // QT_NO_SSL
547
548
555QList<QSslCertificateExtension> QSslCertificate::extensions() const
556{
557 return d->extensions();
558}
559
567{
568 if (const auto *backend = d->backend.get())
569 return backend->toPem();
570
571 return {};
572}
573
581{
582 if (const auto *backend = d->backend.get())
583 return backend->toDer();
584
585 return {};
586}
587
597{
598 if (const auto *backend = d->backend.get())
599 return backend->toText();
600
601 return {};
602}
603
617QList<QSslCertificate> QSslCertificate::fromPath(const QString &path,
619 PatternSyntax syntax)
620{
621 // $, (,), *, +, ., ?, [, ,], ^, {, | and }.
622
623 // make sure to use the same path separators on Windows and Unix like systems.
625
626 // Find the path without the filename
627 QStringView pathPrefix = QStringView(sourcePath).left(sourcePath.lastIndexOf(u'/'));
628
629 // Check if the path contains any special chars
630 int pos = -1;
631
632#if QT_CONFIG(regularexpression)
633 if (syntax == PatternSyntax::Wildcard)
634 pos = pathPrefix.indexOf(QRegularExpression("[*?[]"_L1));
635 else if (syntax == PatternSyntax::RegularExpression)
636 pos = sourcePath.indexOf(QRegularExpression("[\\$\\(\\)\\*\\+\\.\\?\\[\\]\\^\\{\\}\\|]"_L1));
637#else
638 if (syntax == PatternSyntax::Wildcard || syntax == PatternSyntax::RegExp)
639 qWarning("Regular expression support is disabled in this build. Only fixed string can be searched");
640 return QList<QSslCertificate>();
641#endif
642
643 if (pos != -1) {
644 // there was a special char in the path so cut of the part containing that char.
645 pathPrefix = pathPrefix.left(pos);
646 const qsizetype lastIndexOfSlash = pathPrefix.lastIndexOf(u'/');
647 if (lastIndexOfSlash != -1)
648 pathPrefix = pathPrefix.left(lastIndexOfSlash);
649 else
650 pathPrefix = {};
651 } else {
652 // Check if the path is a file.
653 if (QFileInfo(sourcePath).isFile()) {
654 QFile file(sourcePath);
655 QIODevice::OpenMode openMode = QIODevice::ReadOnly;
656 if (format == QSsl::Pem)
657 openMode |= QIODevice::Text;
658 if (file.open(openMode))
660 return QList<QSslCertificate>();
661 }
662 }
663
664 // Special case - if the prefix ends up being nothing, use "." instead.
665 int startIndex = 0;
666 if (pathPrefix.isEmpty()) {
667 pathPrefix = u".";
668 startIndex = 2;
669 }
670
671 const QString pathPrefixString = pathPrefix.toString();
672
673 // The path can be a file or directory.
674 QList<QSslCertificate> certs;
675
676#if QT_CONFIG(regularexpression)
677 if (syntax == PatternSyntax::Wildcard)
679
681#endif
682
684 constexpr auto iterFlags = F::FollowSymlinks | F::Recursive;
685 for (const auto &dirEntry : QDirListing(pathPrefixString, QDir::Files, iterFlags)) {
686 QString filePath = dirEntry.filePath();
687 if (startIndex > 0)
688 filePath.remove(0, startIndex);
689
690#if QT_CONFIG(regularexpression)
691 if (!pattern.match(filePath).hasMatch())
692 continue;
693#else
694 if (sourcePath != filePath)
695 continue;
696#endif
697
698 QFile file(filePath);
699 QIODevice::OpenMode openMode = QIODevice::ReadOnly;
700 if (format == QSsl::Pem)
701 openMode |= QIODevice::Text;
702 if (file.open(openMode))
704 }
705 return certs;
706}
707
716{
717 if (!device) {
718 qCWarning(lcSsl, "QSslCertificate::fromDevice: cannot read from a null device");
719 return QList<QSslCertificate>();
720 }
721 return fromData(device->readAll(), format);
722}
723
732{
733 const auto *tlsBackend = QTlsBackend::activeOrAnyBackend();
734 if (!tlsBackend) {
735 qCWarning(lcSsl, "No TLS backend is available");
736 return {};
737 }
738
739 auto reader = format == QSsl::Pem ? tlsBackend->X509PemReader() : tlsBackend->X509DerReader();
740 if (!reader) {
741 qCWarning(lcSsl, "The available TLS backend does not support reading PEM/DER");
742 return {};
743 }
744
745 return reader(data, -1);
746}
747
748#ifndef QT_NO_SSL
763QList<QSslError> QSslCertificate::verify(const QList<QSslCertificate> &certificateChain, const QString &hostName)
764{
765 const auto *tlsBackend = QTlsBackend::activeOrAnyBackend();
766 if (!tlsBackend) {
767 qCWarning(lcSsl, "No TLS backend is available");
768 return {};
769 }
770 auto verifyPtr = tlsBackend->X509Verifier();
771 if (!verifyPtr) {
772 qCWarning(lcSsl, "Available TLS backend does not support manual certificate verification");
773 return {};
774 }
775 return verifyPtr(certificateChain, hostName);
776}
777
791 QSslKey *key, QSslCertificate *certificate,
792 QList<QSslCertificate> *caCertificates,
793 const QByteArray &passPhrase)
794{
795 if (!device || !key || !certificate)
796 return false;
797
798 const auto *tlsBackend = QTlsBackend::activeOrAnyBackend();
799 if (!tlsBackend) {
800 qCWarning(lcSsl, "No TLS backend is available");
801 return false;
802 }
803
804 if (auto reader = tlsBackend->X509Pkcs12Reader())
805 return reader(device, key, certificate, caCertificates, passPhrase);
806
807 qCWarning(lcSsl, "Available TLS backend does not support PKCS12");
808
809 return false;
810}
811#endif // QT_NO_SSL
812
813QList<QSslCertificateExtension> QSslCertificatePrivate::extensions() const
814{
815 QList<QSslCertificateExtension> result;
816
817 if (backend.get()) {
818 auto nExt = backend->numberOfExtensions();
819 for (decltype (nExt) i = 0; i < nExt; ++i) {
821 ext.d->oid = backend->oidForExtension(i);
822 ext.d->name = backend->nameForExtension(i);
823 ext.d->value = backend->valueForExtension(i);
824 ext.d->critical = backend->isExtensionCritical(i);
825 ext.d->supported = backend->isExtensionSupported(i);
826 result << ext;
827 }
828 }
829
830 return result;
831}
832
833// These certificates are known to be fraudulent and were created during the comodo
834// compromise. See http://www.comodo.com/Comodo-Fraud-Incident-2011-03-23.html
835static const char *const certificate_blacklist[] = {
836 "04:7e:cb:e9:fc:a5:5f:7b:d0:9e:ae:36:e1:0c:ae:1e", "mail.google.com", // Comodo
837 "f5:c8:6a:f3:61:62:f1:3a:64:f5:4f:6d:c9:58:7c:06", "www.google.com", // Comodo
838 "d7:55:8f:da:f5:f1:10:5b:b2:13:28:2b:70:77:29:a3", "login.yahoo.com", // Comodo
839 "39:2a:43:4f:0e:07:df:1f:8a:a3:05:de:34:e0:c2:29", "login.yahoo.com", // Comodo
840 "3e:75:ce:d4:6b:69:30:21:21:88:30:ae:86:a8:2a:71", "login.yahoo.com", // Comodo
841 "e9:02:8b:95:78:e4:15:dc:1a:71:0a:2b:88:15:44:47", "login.skype.com", // Comodo
842 "92:39:d5:34:8f:40:d1:69:5a:74:54:70:e1:f2:3f:43", "addons.mozilla.org", // Comodo
843 "b0:b7:13:3e:d0:96:f9:b5:6f:ae:91:c8:74:bd:3a:c0", "login.live.com", // Comodo
844 "d8:f3:5f:4e:b7:87:2b:2d:ab:06:92:e3:15:38:2f:b0", "global trustee", // Comodo
845
846 "05:e2:e6:a4:cd:09:ea:54:d6:65:b0:75:fe:22:a2:56", "*.google.com", // leaf certificate issued by DigiNotar
847 "0c:76:da:9c:91:0c:4e:2c:9e:fe:15:d0:58:93:3c:4c", "DigiNotar Root CA", // DigiNotar root
848 "f1:4a:13:f4:87:2b:56:dc:39:df:84:ca:7a:a1:06:49", "DigiNotar Services CA", // DigiNotar intermediate signed by DigiNotar Root
849 "36:16:71:55:43:42:1b:9d:e6:cb:a3:64:41:df:24:38", "DigiNotar Services 1024 CA", // DigiNotar intermediate signed by DigiNotar Root
850 "0a:82:bd:1e:14:4e:88:14:d7:5b:1a:55:27:be:bf:3e", "DigiNotar Root CA G2", // other DigiNotar Root CA
851 "a4:b6:ce:e3:2e:d3:35:46:26:3c:b3:55:3a:a8:92:21", "CertiID Enterprise Certificate Authority", // DigiNotar intermediate signed by "DigiNotar Root CA G2"
852 "5b:d5:60:9c:64:17:68:cf:21:0e:35:fd:fb:05:ad:41", "DigiNotar Qualified CA", // DigiNotar intermediate signed by DigiNotar Root
853
854 "46:9c:2c:b0", "DigiNotar Services 1024 CA", // DigiNotar intermediate cross-signed by Entrust
855 "07:27:10:0d", "DigiNotar Cyber CA", // DigiNotar intermediate cross-signed by CyberTrust
856 "07:27:0f:f9", "DigiNotar Cyber CA", // DigiNotar intermediate cross-signed by CyberTrust
857 "07:27:10:03", "DigiNotar Cyber CA", // DigiNotar intermediate cross-signed by CyberTrust
858 "01:31:69:b0", "DigiNotar PKIoverheid CA Overheid en Bedrijven", // DigiNotar intermediate cross-signed by the Dutch government
859 "01:31:34:bf", "DigiNotar PKIoverheid CA Organisatie - G2", // DigiNotar intermediate cross-signed by the Dutch government
860 "d6:d0:29:77:f1:49:fd:1a:83:f2:b9:ea:94:8c:5c:b4", "DigiNotar Extended Validation CA", // DigiNotar intermediate signed by DigiNotar EV Root
861 "1e:7d:7a:53:3d:45:30:41:96:40:0f:71:48:1f:45:04", "DigiNotar Public CA 2025", // DigiNotar intermediate
862// "(has not been seen in the wild so far)", "DigiNotar Public CA - G2", // DigiNotar intermediate
863// "(has not been seen in the wild so far)", "Koninklijke Notariele Beroepsorganisatie CA", // compromised during DigiNotar breach
864// "(has not been seen in the wild so far)", "Stichting TTP Infos CA," // compromised during DigiNotar breach
865 "46:9c:2c:af", "DigiNotar Root CA", // DigiNotar intermediate cross-signed by Entrust
866 "46:9c:3c:c9", "DigiNotar Root CA", // DigiNotar intermediate cross-signed by Entrust
867
868 "07:27:14:a9", "Digisign Server ID (Enrich)", // (Malaysian) Digicert Sdn. Bhd. cross-signed by Verizon CyberTrust
869 "4c:0e:63:6a", "Digisign Server ID - (Enrich)", // (Malaysian) Digicert Sdn. Bhd. cross-signed by Entrust
870 "72:03:21:05:c5:0c:08:57:3d:8e:a5:30:4e:fe:e8:b0", "UTN-USERFirst-Hardware", // comodogate test certificate
871 "41", "MD5 Collisions Inc. (http://www.phreedom.org/md5)", // http://www.phreedom.org/research/rogue-ca/
872
873 "08:27", "*.EGO.GOV.TR", // Turktrust mis-issued intermediate certificate
874 "08:64", "e-islem.kktcmerkezbankasi.org", // Turktrust mis-issued intermediate certificate
875
876 "03:1d:a7", "AC DG Tr\xC3\xA9sor SSL", // intermediate certificate linking back to ANSSI French National Security Agency
877 "27:83", "NIC Certifying Authority", // intermediate certificate from NIC India (2007)
878 "27:92", "NIC CA 2011", // intermediate certificate from NIC India (2011)
879 "27:b1", "NIC CA 2014", // intermediate certificate from NIC India (2014)
880 nullptr
881};
882
884{
885 for (int a = 0; certificate_blacklist[a] != nullptr; a++) {
886 auto blacklistedCommonName = QAnyStringView(QUtf8StringView(certificate_blacklist[(a+1)]));
887 if (certificate.serialNumber() == certificate_blacklist[a++] &&
888 (certificate.subjectInfo(QSslCertificate::CommonName).contains(blacklistedCommonName) ||
889 certificate.issuerInfo(QSslCertificate::CommonName).contains(blacklistedCommonName)))
890 return true;
891 }
892 return false;
893}
894
896{
897 switch (info) {
898 case QSslCertificate::Organization: return "O"_ba;
899 case QSslCertificate::CommonName: return "CN"_ba;
900 case QSslCertificate::LocalityName: return"L"_ba;
901 case QSslCertificate::OrganizationalUnitName: return "OU"_ba;
902 case QSslCertificate::CountryName: return "C"_ba;
903 case QSslCertificate::StateOrProvinceName: return "ST"_ba;
904 case QSslCertificate::DistinguishedNameQualifier: return "dnQualifier"_ba;
905 case QSslCertificate::SerialNumber: return "serialNumber"_ba;
906 case QSslCertificate::EmailAddress: return "emailAddress"_ba;
907 }
908 return QByteArray();
909}
910
921{
924 if (!names.isEmpty())
925 return names.constFirst();
927 if (!names.isEmpty())
928 return names.constFirst();
930 if (!names.isEmpty())
931 return names.constFirst();
932
933 return QString();
934}
935
946{
949 if (!names.isEmpty())
950 return names.constFirst();
952 if (!names.isEmpty())
953 return names.constFirst();
955 if (!names.isEmpty())
956 return names.constFirst();
957
958 return QString();
959}
960
966size_t qHash(const QSslCertificate &key, size_t seed) noexcept
967{
968 if (const auto *backend = key.d->backend.get())
969 return backend->hash(seed);
970
971 return seed;
972
973}
974
975#ifndef QT_NO_DEBUG_STREAM
977{
978 QDebugStateSaver saver(debug);
979 debug.resetFormat().nospace();
980 debug << "QSslCertificate("
981 << "Version=" << certificate.version()
982 << ", SerialNumber=" << certificate.serialNumber()
983 << ", Digest=" << certificate.digest().toBase64()
984 << ", Issuer=" << certificate.issuerDisplayName()
985 << ", Subject=" << certificate.subjectDisplayName()
986 << ", AlternativeSubjectNames=" << certificate.subjectAlternativeNames()
987#if QT_CONFIG(datestring)
988 << ", EffectiveDate=" << certificate.effectiveDate()
989 << ", ExpiryDate=" << certificate.expiryDate()
990#endif
991 << ')';
992 return debug;
993}
995{
996 switch (info) {
997 case QSslCertificate::Organization: debug << "Organization"; break;
998 case QSslCertificate::CommonName: debug << "CommonName"; break;
999 case QSslCertificate::CountryName: debug << "CountryName"; break;
1000 case QSslCertificate::LocalityName: debug << "LocalityName"; break;
1001 case QSslCertificate::OrganizationalUnitName: debug << "OrganizationalUnitName"; break;
1002 case QSslCertificate::StateOrProvinceName: debug << "StateOrProvinceName"; break;
1003 case QSslCertificate::DistinguishedNameQualifier: debug << "DistinguishedNameQualifier"; break;
1004 case QSslCertificate::SerialNumber: debug << "SerialNumber"; break;
1005 case QSslCertificate::EmailAddress: debug << "EmailAddress"; break;
1006 }
1007 return debug;
1008}
1009#endif
1010
IOBluetoothDevice * device
\inmodule QtCore
\inmodule QtCore
Definition qbytearray.h:57
QByteArray toBase64(Base64Options options=Base64Encoding) const
static QByteArray hash(QByteArrayView data, Algorithm method)
Returns the hash of data using method.
\inmodule QtCore\reentrant
Definition qdatetime.h:283
\inmodule QtCore
\inmodule QtCore
The QDirListing class provides an STL-style iterator for directory entries.
Definition qdirlisting.h:18
IteratorFlag
This enum class describes flags can be used to configure the behavior of QDirListing.
Definition qdirlisting.h:20
static QString fromNativeSeparators(const QString &pathName)
Definition qdir.cpp:962
@ Files
Definition qdir.h:23
\inmodule QtCore
Definition qfile.h:93
QFILE_MAYBE_NODISCARD bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
Definition qfile.cpp:904
size_t qHash(const QSslCertificate &key, size_t seed) noexcept
Returns the hash value for the key, using seed to seed the calculation.
\inmodule QtCore \reentrant
Definition qiodevice.h:34
QByteArray readAll()
Reads all remaining data from the device, and returns it as a byte array.
\inmodule QtCore \reentrant
static QString anchoredPattern(const QString &expression)
static QString wildcardToRegularExpression(const QString &str, WildcardConversionOptions options=DefaultWildcardConversion)
The QSslCertificateExtension class provides an API for accessing the extensions of an X509 certificat...
static Q_NETWORK_EXPORT QByteArray subjectInfoToString(QSslCertificate::SubjectInfo info)
std::unique_ptr< QTlsPrivate::X509Certificate > backend
QList< QSslCertificateExtension > extensions() const
static Q_NETWORK_EXPORT bool isBlacklisted(const QSslCertificate &certificate)
The QSslCertificate class provides a convenient API for an X509 certificate.
QSslCertificate(QIODevice *device, QSsl::EncodingFormat format=QSsl::Pem)
Constructs a QSslCertificate by reading format encoded data from device and using the first certifica...
~QSslCertificate()
Destroys the QSslCertificate.
QList< QByteArray > issuerInfoAttributes() const
QStringList subjectInfo(SubjectInfo info) const
Returns the information for the subject, or an empty list if there is no information for subject in t...
static QList< QSslCertificate > fromDevice(QIODevice *device, QSsl::EncodingFormat format=QSsl::Pem)
Searches for and parses all certificates in device that are encoded in the specified format and retur...
bool isSelfSigned() const
QMultiMap< QSsl::AlternativeNameEntryType, QString > subjectAlternativeNames() const
Returns the list of alternative subject names for this certificate.
static QList< QSslCertificate > fromData(const QByteArray &data, QSsl::EncodingFormat format=QSsl::Pem)
Searches for and parses all certificates in data that are encoded in the specified format and returns...
QString issuerDisplayName() const
QSslCertificate & operator=(QSslCertificate &&other) noexcept
QByteArray digest(QCryptographicHash::Algorithm algorithm=QCryptographicHash::Md5) const
Returns a cryptographic digest of this certificate.
bool operator==(const QSslCertificate &other) const
Returns true if this certificate is the same as other; otherwise returns false.
QDateTime expiryDate() const
Returns the date-time that the certificate expires, or an empty QDateTime if this is a null certifica...
static QList< QSslError > verify(const QList< QSslCertificate > &certificateChain, const QString &hostName=QString())
Verifies a certificate chain.
QSslKey publicKey() const
Returns the certificate subject's public key.
QByteArray version() const
Returns the certificate's version string.
static QList< QSslCertificate > fromPath(const QString &path, QSsl::EncodingFormat format=QSsl::Pem, PatternSyntax syntax=PatternSyntax::FixedString)
QDateTime effectiveDate() const
Returns the date-time that the certificate becomes valid, or an empty QDateTime if this is a null cer...
QStringList issuerInfo(SubjectInfo info) const
Returns the issuer information for the subject from the certificate, or an empty list if there is no ...
QString subjectDisplayName() const
SubjectInfo
Describes keys that you can pass to QSslCertificate::issuerInfo() or QSslCertificate::subjectInfo() t...
QByteArray toDer() const
Returns this certificate converted to a DER (binary) encoded representation.
Qt::HANDLE handle() const
Returns a pointer to the native certificate handle, if there is one, else \nullptr.
QList< QSslCertificateExtension > extensions() const
Returns a list containing the X509 extensions of this certificate.
QList< QByteArray > subjectInfoAttributes() const
bool isNull() const
Returns true if this is a null certificate (i.e., a certificate with no contents); otherwise returns ...
bool isBlacklisted() const
Returns true if this certificate is blacklisted; otherwise returns false.
QByteArray serialNumber() const
Returns the certificate's serial number string in hexadecimal format.
void clear()
Clears the contents of this certificate, making it a null certificate.
QString toText() const
Returns this certificate converted to a human-readable text representation.
QByteArray toPem() const
Returns this certificate converted to a PEM (Base64) encoded representation.
static bool importPkcs12(QIODevice *device, QSslKey *key, QSslCertificate *cert, QList< QSslCertificate > *caCertificates=nullptr, const QByteArray &passPhrase=QByteArray())
The QSslKey class provides an interface for private and public keys.
Definition qsslkey.h:23
static void ensureInitialized()
\inmodule QtCore
\inmodule QtCore
Definition qstringview.h:78
constexpr QStringView left(qsizetype n) const noexcept
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
qsizetype indexOf(QLatin1StringView s, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition qstring.cpp:4517
qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
Definition qstring.h:296
QString & remove(qsizetype i, qsizetype len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
Definition qstring.cpp:3466
QTlsBackend is a factory class, providing implementations for the QSsl classes.
static void resetBackend(QSslKey &key, QTlsPrivate::TlsKey *keyBackend)
virtual QTlsPrivate::X509Certificate * createCertificate() const
static QTlsBackend * activeOrAnyBackend()
EncodingFormat
Describes supported encoding formats for certificates and keys.
Definition qssl.h:28
@ Pem
Definition qssl.h:29
Combined button and popup list for selecting options.
void * HANDLE
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
EGLOutputLayerEXT EGLint attribute
#define qWarning
Definition qlogging.h:166
#define qCWarning(category,...)
#define QT_IMPL_METATYPE_EXTERN(TYPE)
Definition qmetatype.h:1390
GLuint64 key
GLboolean GLboolean GLboolean GLboolean a
[7]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLsizei GLsizei GLenum format
GLuint GLuint * names
GLsizei const GLchar *const * path
GLuint64EXT * result
[6]
GLubyte * pattern
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
Definition qrandom.cpp:196
QDebug operator<<(QDebug debug, const QSslCertificate &certificate)
static const char *const certificate_blacklist[]
QBasicUtf8StringView< false > QUtf8StringView
Definition qstringfwd.h:46
ptrdiff_t qsizetype
Definition qtypes.h:165
QFile file
[0]
QSharedPointer< T > other(t)
[5]
QHostInfo info
[0]
const auto certs
[1]