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.h
Go to the documentation of this file.
1// Copyright (C) 2020 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
5#ifndef QSSLCERTIFICATE_H
6#define QSSLCERTIFICATE_H
7
8#ifdef verify
9#undef verify
10#endif
11
12#include <QtNetwork/qtnetworkglobal.h>
13#include <QtCore/qnamespace.h>
14#include <QtCore/qbytearray.h>
15#include <QtCore/qcryptographichash.h>
16#include <QtCore/qdatetime.h>
17#include <QtCore/qmap.h>
18#include <QtCore/qshareddata.h>
19#include <QtNetwork/qssl.h>
20
22
23class QDateTime;
24class QIODevice;
25class QSslError;
26class QSslKey;
28
29class QSslCertificate;
30// qHash is a friend, but we can't use default arguments for friends (ยง8.3.6.4)
31Q_NETWORK_EXPORT size_t qHash(const QSslCertificate &key, size_t seed = 0) noexcept;
32
34class Q_NETWORK_EXPORT QSslCertificate
35{
36public:
48
49 enum class PatternSyntax {
53 };
54
55
60 QSslCertificate &operator=(QSslCertificate &&other) noexcept { swap(other); return *this; }
62
63 void swap(QSslCertificate &other) noexcept
64 { d.swap(other.d); }
65
66 bool operator==(const QSslCertificate &other) const;
67 inline bool operator!=(const QSslCertificate &other) const { return !operator==(other); }
68
69 bool isNull() const;
70 bool isBlacklisted() const;
71 bool isSelfSigned() const;
72 void clear();
73
74 // Certificate info
75 QByteArray version() const;
84
85 QList<QByteArray> subjectInfoAttributes() const;
86 QList<QByteArray> issuerInfoAttributes() const;
87 QMultiMap<QSsl::AlternativeNameEntryType, QString> subjectAlternativeNames() const;
89 QDateTime expiryDate() const;
90#ifndef QT_NO_SSL
91 QSslKey publicKey() const;
92#endif
93 QList<QSslCertificateExtension> extensions() const;
94
95 QByteArray toPem() const;
96 QByteArray toDer() const;
97 QString toText() const;
98
99 static QList<QSslCertificate> fromPath(const QString &path,
102
103 static QList<QSslCertificate> fromDevice(
105 static QList<QSslCertificate> fromData(
107
108#ifndef QT_NO_SSL
109 static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName = QString());
110 static bool importPkcs12(QIODevice *device,
112 QList<QSslCertificate> *caCertificates = nullptr,
113 const QByteArray &passPhrase=QByteArray());
114#endif
115
116 Qt::HANDLE handle() const;
117
118private:
119 QExplicitlySharedDataPointer<QSslCertificatePrivate> d;
120 friend class QTlsBackend;
121
122 friend Q_NETWORK_EXPORT size_t qHash(const QSslCertificate &key, size_t seed) noexcept;
123};
124Q_DECLARE_SHARED(QSslCertificate)
125
126#ifndef QT_NO_DEBUG_STREAM
127class QDebug;
128Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QSslCertificate &certificate);
130#endif
131
133
135
136#endif
IOBluetoothDevice * device
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore\reentrant
Definition qdatetime.h:283
\inmodule QtCore
\inmodule QtCore \reentrant
Definition qiodevice.h:34
The QSslCertificateExtension class provides an API for accessing the extensions of an X509 certificat...
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
void swap(QSslCertificate &other) noexcept
QSslCertificate & operator=(QSslCertificate &&other) noexcept
QByteArray digest(QCryptographicHash::Algorithm algorithm=QCryptographicHash::Md5) const
Returns a cryptographic digest of this certificate.
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)
friend Q_NETWORK_EXPORT size_t qHash(const QSslCertificate &key, size_t seed) noexcept
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...
bool operator!=(const QSslCertificate &other) const
Returns true if this certificate is not the same as other; otherwise returns false.
QByteArray toDer() const
Returns this certificate converted to a DER (binary) encoded representation.
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.
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 QSslError class provides an SSL error.
Definition qsslerror.h:21
The QSslKey class provides an interface for private and public keys.
Definition qsslkey.h:23
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QTlsBackend is a factory class, providing implementations for the QSsl classes.
b clear()
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 QT_DECL_METATYPE_EXTERN(TYPE, EXPORT)
Definition qmetatype.h:1388
GLuint64 GLenum void * handle
GLuint64 key
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLsizei GLsizei GLenum format
GLsizei const GLchar *const * path
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
Definition qrandom.cpp:196
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1220
Q_NETWORK_EXPORT size_t qHash(const QSslCertificate &key, size_t seed=0) noexcept
Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QSslCertificate &certificate)
QSharedPointer< T > other(t)
[5]
this swap(other)
QList< QSslCertificate > cert
[0]
QHostInfo info
[0]