Debian Codegraph @

upstream/debian-unstable/man3/X509_get_extension_flags.3ssl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "X509_GET_EXTENSION_FLAGS 3SSL"
58 .TH X509_GET_EXTENSION_FLAGS 3SSL 2026-04-07 3.6.2 OpenSSL
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 X509_get0_subject_key_id,
65 X509_get0_authority_key_id,
66 X509_get0_authority_issuer,
67 X509_get0_authority_serial,
68 X509_get_pathlen,
69 X509_get_extension_flags,
70 X509_get_key_usage,
71 X509_get_extended_key_usage,
72 X509_set_proxy_flag,
73 X509_set_proxy_pathlen,
74 X509_get_proxy_pathlen \- retrieve certificate extension data
75 .SH SYNOPSIS
76 .IX Header "SYNOPSIS"
77 .Vb 1
78 \& #include <openssl/x509v3.h>
79 \&
80 \& long X509_get_pathlen(X509 *x);
81 \& uint32_t X509_get_extension_flags(X509 *x);
82 \& uint32_t X509_get_key_usage(X509 *x);
83 \& uint32_t X509_get_extended_key_usage(X509 *x);
84 \& const ASN1_OCTET_STRING *X509_get0_subject_key_id(X509 *x);
85 \& const ASN1_OCTET_STRING *X509_get0_authority_key_id(X509 *x);
86 \& const GENERAL_NAMES *X509_get0_authority_issuer(X509 *x);
87 \& const ASN1_INTEGER *X509_get0_authority_serial(X509 *x);
88 \& void X509_set_proxy_flag(X509 *x);
89 \& void X509_set_proxy_pathlen(int l);
90 \& long X509_get_proxy_pathlen(X509 *x);
91 .Ve
92 .SH DESCRIPTION
93 .IX Header "DESCRIPTION"
94 These functions retrieve information related to commonly used certificate extensions.
95 .PP
96 \&\fBX509_get_pathlen()\fR retrieves the path length extension from a certificate.
97 This extension is used to limit the length of a cert chain that may be
98 issued from that CA.
99 .PP
100 \&\fBX509_get_extension_flags()\fR retrieves general information about a certificate,
101 it will return one or more of the following flags ored together.
102 .IP \fBEXFLAG_V1\fR 4
103 .IX Item "EXFLAG_V1"
104 The certificate is an obsolete version 1 certificate.
105 .IP \fBEXFLAG_BCONS\fR 4
106 .IX Item "EXFLAG_BCONS"
107 The certificate contains a basic constraints extension.
108 .IP \fBEXFLAG_CA\fR 4
109 .IX Item "EXFLAG_CA"
110 The certificate contains basic constraints and asserts the CA flag.
111 .IP \fBEXFLAG_PROXY\fR 4
112 .IX Item "EXFLAG_PROXY"
113 The certificate is a valid proxy certificate.
114 .IP \fBEXFLAG_SI\fR 4
115 .IX Item "EXFLAG_SI"
116 The certificate is self issued (that is subject and issuer names match).
117 .IP \fBEXFLAG_SS\fR 4
118 .IX Item "EXFLAG_SS"
119 The subject and issuer names match and extension values imply it is self
120 signed.
121 .IP \fBEXFLAG_FRESHEST\fR 4
122 .IX Item "EXFLAG_FRESHEST"
123 The freshest CRL extension is present in the certificate.
124 .IP \fBEXFLAG_CRITICAL\fR 4
125 .IX Item "EXFLAG_CRITICAL"
126 The certificate contains an unhandled critical extension.
127 .IP \fBEXFLAG_INVALID\fR 4
128 .IX Item "EXFLAG_INVALID"
129 Some certificate extension values are invalid or inconsistent.
130 The certificate should be rejected.
131 This bit may also be raised after an out-of-memory error while
132 processing the X509 object, so it may not be related to the processed
133 ASN1 object itself.
134 .IP \fBEXFLAG_NO_FINGERPRINT\fR 4
135 .IX Item "EXFLAG_NO_FINGERPRINT"
136 Failed to compute the internal SHA1 hash value of the certificate or CRL.
137 This may be due to malloc failure or because no SHA1 implementation was found.
138 .IP \fBEXFLAG_INVALID_POLICY\fR 4
139 .IX Item "EXFLAG_INVALID_POLICY"
140 The NID_certificate_policies certificate extension is invalid or
141 inconsistent. The certificate should be rejected.
142 This bit may also be raised after an out-of-memory error while
143 processing the X509 object, so it may not be related to the processed
144 ASN1 object itself.
145 .IP \fBEXFLAG_KUSAGE\fR 4
146 .IX Item "EXFLAG_KUSAGE"
147 The certificate contains a key usage extension. The value can be retrieved
148 using \fBX509_get_key_usage()\fR.
149 .IP \fBEXFLAG_XKUSAGE\fR 4
150 .IX Item "EXFLAG_XKUSAGE"
151 The certificate contains an extended key usage extension. The value can be
152 retrieved using \fBX509_get_extended_key_usage()\fR.
153 .PP
154 \&\fBX509_get_key_usage()\fR returns the value of the key usage extension. If key
155 usage is present will return zero or more of the flags:
156 \&\fBKU_DIGITAL_SIGNATURE\fR, \fBKU_NON_REPUDIATION\fR, \fBKU_KEY_ENCIPHERMENT\fR,
157 \&\fBKU_DATA_ENCIPHERMENT\fR, \fBKU_KEY_AGREEMENT\fR, \fBKU_KEY_CERT_SIGN\fR,
158 \&\fBKU_CRL_SIGN\fR, \fBKU_ENCIPHER_ONLY\fR or \fBKU_DECIPHER_ONLY\fR corresponding to
159 individual key usage bits. If key usage is absent then \fBUINT32_MAX\fR is
160 returned.
161 .PP
162 \&\fBX509_get_extended_key_usage()\fR returns the value of the extended key usage
163 extension. If extended key usage is present it will return zero or more of the
164 flags: \fBXKU_SSL_SERVER\fR, \fBXKU_SSL_CLIENT\fR, \fBXKU_SMIME\fR, \fBXKU_CODE_SIGN\fR
165 \&\fBXKU_OCSP_SIGN\fR, \fBXKU_TIMESTAMP\fR, \fBXKU_DVCS\fR or \fBXKU_ANYEKU\fR. These
166 correspond to the OIDs \fBid-kp-serverAuth\fR, \fBid-kp-clientAuth\fR,
167 \&\fBid-kp-emailProtection\fR, \fBid-kp-codeSigning\fR, \fBid-kp-OCSPSigning\fR,
168 \&\fBid-kp-timeStamping\fR, \fBid-kp-dvcs\fR and \fBanyExtendedKeyUsage\fR respectively.
169 Additionally \fBXKU_SGC\fR is set if either Netscape or Microsoft SGC OIDs are
170 present.
171 .PP
172 \&\fBX509_get0_subject_key_id()\fR returns an internal pointer to the subject key
173 identifier of \fBx\fR as an \fBASN1_OCTET_STRING\fR or \fBNULL\fR if the extension
174 is not present or cannot be parsed.
175 .PP
176 \&\fBX509_get0_authority_key_id()\fR returns an internal pointer to the authority key
177 identifier of \fBx\fR as an \fBASN1_OCTET_STRING\fR or \fBNULL\fR if the extension
178 is not present or cannot be parsed.
179 .PP
180 \&\fBX509_get0_authority_issuer()\fR returns an internal pointer to the authority
181 certificate issuer of \fBx\fR as a stack of \fBGENERAL_NAME\fR structures or
182 \&\fBNULL\fR if the extension is not present or cannot be parsed.
183 .PP
184 \&\fBX509_get0_authority_serial()\fR returns an internal pointer to the authority
185 certificate serial number of \fBx\fR as an \fBASN1_INTEGER\fR or \fBNULL\fR if the
186 extension is not present or cannot be parsed.
187 .PP
188 \&\fBX509_set_proxy_flag()\fR marks the certificate with the \fBEXFLAG_PROXY\fR flag.
189 This is for the users who need to mark non\-RFC3820 proxy certificates as
190 such, as OpenSSL only detects RFC3820 compliant ones.
191 .PP
192 \&\fBX509_set_proxy_pathlen()\fR sets the proxy certificate path length for the given
193 certificate \fBx\fR. This is for the users who need to mark non\-RFC3820 proxy
194 certificates as such, as OpenSSL only detects RFC3820 compliant ones.
195 .PP
196 \&\fBX509_get_proxy_pathlen()\fR returns the proxy certificate path length for the
197 given certificate \fBx\fR if it is a proxy certificate.
198 .SH NOTES
199 .IX Header "NOTES"
200 The value of the flags correspond to extension values which are cached
201 in the \fBX509\fR structure. If the flags returned do not provide sufficient
202 information an application should examine extension values directly
203 for example using \fBX509_get_ext_d2i()\fR.
204 .PP
205 If the key usage or extended key usage extension is absent then typically usage
206 is unrestricted. For this reason \fBX509_get_key_usage()\fR and
207 \&\fBX509_get_extended_key_usage()\fR return \fBUINT32_MAX\fR when the corresponding
208 extension is absent. Applications can additionally check the return value of
209 \&\fBX509_get_extension_flags()\fR and take appropriate action is an extension is
210 absent.
211 .PP
212 If \fBX509_get0_subject_key_id()\fR returns \fBNULL\fR then the extension may be
213 absent or malformed. Applications can determine the precise reason using
214 \&\fBX509_get_ext_d2i()\fR.
215 .SH "RETURN VALUES"
216 .IX Header "RETURN VALUES"
217 \&\fBX509_get_pathlen()\fR returns the path length value, or \-1 if the extension
218 is not present.
219 .PP
220 \&\fBX509_get_extension_flags()\fR, \fBX509_get_key_usage()\fR and
221 \&\fBX509_get_extended_key_usage()\fR return sets of flags corresponding to the
222 certificate extension values.
223 .PP
224 \&\fBX509_get0_subject_key_id()\fR returns the subject key identifier as a
225 pointer to an \fBASN1_OCTET_STRING\fR structure or \fBNULL\fR if the extension
226 is absent or an error occurred during parsing.
227 .PP
228 \&\fBX509_get_proxy_pathlen()\fR returns the path length value if the given
229 certificate is a proxy one and has a path length set, and \-1 otherwise.
230 .SH "SEE ALSO"
231 .IX Header "SEE ALSO"
232 \&\fBX509_check_purpose\fR\|(3)
233 .SH HISTORY
234 .IX Header "HISTORY"
235 \&\fBX509_get_pathlen()\fR, \fBX509_set_proxy_flag()\fR, \fBX509_set_proxy_pathlen()\fR and
236 \&\fBX509_get_proxy_pathlen()\fR were added in OpenSSL 1.1.0.
237 .SH COPYRIGHT
238 .IX Header "COPYRIGHT"
239 Copyright 2015\-2021 The OpenSSL Project Authors. All Rights Reserved.
240 .PP
241 Licensed under the Apache License 2.0 (the "License"). You may not use
242 this file except in compliance with the License. You can obtain a copy
243 in the file LICENSE in the source distribution or at
244 <https://www.openssl.org/source/license.html>.