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
qsslcertificateextension.cpp
Go to the documentation of this file.
1// Copyright (C) 2011 Richard J. Moore <rich@kde.org>
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/*!
6 \class QSslCertificateExtension
7 \brief The QSslCertificateExtension class provides an API for accessing the
8 extensions of an X509 certificate.
9 \since 5.0
10
11 \reentrant
12 \ingroup network
13 \ingroup ssl
14 \ingroup shared
15 \inmodule QtNetwork
16
17 QSslCertificateExtension provides access to an extension stored in
18 an X509 certificate. The information available depends on the type
19 of extension being accessed.
20
21 All X509 certificate extensions have the following properties:
22
23 \table
24 \header
25 \li Property
26 \li Description
27 \row
28 \li name
29 \li The human readable name of the extension, eg. 'basicConstraints'.
30 \row
31 \li criticality
32 \li This is a boolean value indicating if the extension is critical
33 to correctly interpreting the certificate.
34 \row
35 \li oid
36 \li The ASN.1 object identifier that specifies which extension this
37 is.
38 \row
39 \li supported
40 \li If this is true the structure of the extension's value will not
41 change between Qt versions.
42 \row
43 \li value
44 \li A QVariant with a structure dependent on the type of extension.
45 \endtable
46
47 Whilst this class provides access to any type of extension, only
48 some are guaranteed to be returned in a format that will remain
49 unchanged between releases. The isSupported() method returns \c true
50 for extensions where this is the case.
51
52 The extensions currently supported, and the structure of the value
53 returned are as follows:
54
55 \table
56 \header
57 \li Name
58 \li OID
59 \li Details
60 \row
61 \li basicConstraints
62 \li 2.5.29.19
63 \li Returned as a QVariantMap. The key 'ca' contains a boolean value,
64 the optional key 'pathLenConstraint' contains an integer.
65 \row
66 \li authorityInfoAccess
67 \li 1.3.6.1.5.5.7.1.1
68 \li Returned as a QVariantMap. There is a key for each access method,
69 with the value being a URI.
70 \row
71 \li subjectKeyIdentifier
72 \li 2.5.29.14
73 \li Returned as a QVariant containing a QString. The string is the key
74 identifier.
75 \row
76 \li authorityKeyIdentifier
77 \li 2.5.29.35
78 \li Returned as a QVariantMap. The optional key 'keyid' contains the key
79 identifier as a hex string stored in a QByteArray. The optional key
80 'serial' contains the authority key serial number as a qlonglong.
81 Currently there is no support for the general names field of this
82 extension.
83 \endtable
84
85 In addition to the supported extensions above, many other common extensions
86 will be returned in a reasonably structured way. Extensions that the SSL
87 backend has no support for at all will be returned as a QByteArray.
88
89 Further information about the types of extensions certificates can
90 contain can be found in RFC 5280.
91
92 \sa QSslCertificate::extensions()
93 */
94
97
99
100/*!
101 Constructs a QSslCertificateExtension.
102 */
103QSslCertificateExtension::QSslCertificateExtension()
104 : d(new QSslCertificateExtensionPrivate)
105{
106}
107
108/*!
109 Constructs a copy of \a other.
110 */
111QSslCertificateExtension::QSslCertificateExtension(const QSslCertificateExtension &other)
112 : d(other.d)
113{
114}
115
116/*!
117 Destroys the extension.
118 */
119QSslCertificateExtension::~QSslCertificateExtension()
120{
121}
122
123/*!
124 Assigns \a other to this extension and returns a reference to this extension.
125 */
126QSslCertificateExtension &QSslCertificateExtension::operator=(const QSslCertificateExtension &other)
127{
128 d = other.d;
129 return *this;
130}
131
132/*!
133 \fn void QSslCertificateExtension::swap(QSslCertificateExtension &other)
134 \memberswap{certificate extension instance}
135*/
136
137/*!
138 Returns the ASN.1 OID of this extension.
139 */
140QString QSslCertificateExtension::oid() const
141{
142 return d->oid;
143}
144
145/*!
146 Returns the name of the extension. If no name is known for the
147 extension then the OID will be returned.
148 */
149QString QSslCertificateExtension::name() const
150{
151 return d->name;
152}
153
154/*!
155 Returns the value of the extension. The structure of the value
156 returned depends on the extension type.
157 */
158QVariant QSslCertificateExtension::value() const
159{
160 return d->value;
161}
162
163/*!
164 Returns the criticality of the extension.
165 */
166bool QSslCertificateExtension::isCritical() const
167{
168 return d->critical;
169}
170
171/*!
172 Returns the true if this extension is supported. In this case,
173 supported simply means that the structure of the QVariant returned
174 by the value() accessor will remain unchanged between versions.
175 Unsupported extensions can be freely used, however there is no
176 guarantee that the returned data will have the same structure
177 between versions.
178 */
179bool QSslCertificateExtension::isSupported() const
180{
181 return d->supported;
182}
183
184QT_END_NAMESPACE