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

Provided by KDAB

Privacy Policy
Start learning QML with our Intro Training
Find out more

source code of qtbase/src/network/ssl/qsslcertificateextension.cpp