diff options
author | schwarze <> | 2020-07-23 17:34:53 +0000 |
---|---|---|
committer | schwarze <> | 2020-07-23 17:34:53 +0000 |
commit | 7df61e79b329ba8e55819ef265e5777895818e4b (patch) | |
tree | 83f13dff95bedcb0a38d8cee8e603a9eefa0743c /src/lib/libcrypto/man/PEM_X509_INFO_read.3 | |
parent | 006d896f4376dbbbff0a958d5fe8639ab0c070d5 (diff) | |
download | openbsd-7df61e79b329ba8e55819ef265e5777895818e4b.tar.gz openbsd-7df61e79b329ba8e55819ef265e5777895818e4b.tar.bz2 openbsd-7df61e79b329ba8e55819ef265e5777895818e4b.zip |
document PEM_X509_INFO_read(3) and PEM_X509_INFO_read_bio(3)
OK tb@
Diffstat (limited to 'src/lib/libcrypto/man/PEM_X509_INFO_read.3')
-rw-r--r-- | src/lib/libcrypto/man/PEM_X509_INFO_read.3 | 187 |
1 files changed, 187 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/PEM_X509_INFO_read.3 b/src/lib/libcrypto/man/PEM_X509_INFO_read.3 new file mode 100644 index 0000000000..72658e2b61 --- /dev/null +++ b/src/lib/libcrypto/man/PEM_X509_INFO_read.3 | |||
@@ -0,0 +1,187 @@ | |||
1 | .\" $OpenBSD: PEM_X509_INFO_read.3,v 1.1 2020/07/23 17:34:53 schwarze Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org> | ||
4 | .\" | ||
5 | .\" Permission to use, copy, modify, and distribute this software for any | ||
6 | .\" purpose with or without fee is hereby granted, provided that the above | ||
7 | .\" copyright notice and this permission notice appear in all copies. | ||
8 | .\" | ||
9 | .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
10 | .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
11 | .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
12 | .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
13 | .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
14 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
15 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
16 | .\" | ||
17 | .Dd $Mdocdate: July 23 2020 $ | ||
18 | .Dt PEM_X509_INFO_READ 3 | ||
19 | .Os | ||
20 | .Sh NAME | ||
21 | .Nm PEM_X509_INFO_read , | ||
22 | .Nm PEM_X509_INFO_read_bio | ||
23 | .Nd PEM and DER decode X.509 certificates, private keys, and revocation lists | ||
24 | .Sh SYNOPSIS | ||
25 | .In openssl/pem.h | ||
26 | .Ft STACK_OF(X509_INFO) * | ||
27 | .Fo PEM_X509_INFO_read | ||
28 | .Fa "FILE *in_fp" | ||
29 | .Fa "STACK_OF(X509_INFO) *sk" | ||
30 | .Fa "pem_password_cb *cb" | ||
31 | .Fa "void *u" | ||
32 | .Fc | ||
33 | .Ft STACK_OF(X509_INFO) * | ||
34 | .Fo PEM_X509_INFO_read_bio | ||
35 | .Fa "BIO *in_bp" | ||
36 | .Fa "STACK_OF(X509_INFO) *sk" | ||
37 | .Fa "pem_password_cb *cb" | ||
38 | .Fa "void *u" | ||
39 | .Fc | ||
40 | .Sh DESCRIPTION | ||
41 | These functions read zero or more objects | ||
42 | releated to X.509 certificates from | ||
43 | .Fa in_fp | ||
44 | or | ||
45 | .Fa in_bp , | ||
46 | perform both PEM and DER decoding, | ||
47 | and wrap the resulting objects in newly allocated | ||
48 | .Vt X509_INFO | ||
49 | containers. | ||
50 | .Pp | ||
51 | Setting | ||
52 | .Fa sk | ||
53 | to | ||
54 | .Dv NULL | ||
55 | is recommended, in which case | ||
56 | a new stack is allocated, populated, and returned. | ||
57 | If an existing | ||
58 | .Fa sk | ||
59 | is passed in, the created | ||
60 | .Vt X509_INFO | ||
61 | objects are pushed onto that stack. | ||
62 | .Pp | ||
63 | For PEM decoding, | ||
64 | .Xr PEM_read_bio 3 | ||
65 | is used internally, implying that any non-PEM data | ||
66 | before, between, and after the objects is silently discarded. | ||
67 | .Pp | ||
68 | For subsequent DER decoding, | ||
69 | the decoding function and the field of the | ||
70 | .Vt X509_INFO | ||
71 | structure to store the new object in | ||
72 | are selected according to the PEM type name: | ||
73 | .Bl -column "TRUSTED CERTIFICATE" "d2i_PrivateKey()" "revocation list" | ||
74 | .It PEM type name Ta decoder Ta Vt X509_INFO No field | ||
75 | .It CERTIFICATE Ta Xr d2i_X509 3 Ta certificate | ||
76 | .It X509 CERTIFICATE Ta Xr d2i_X509 3 Ta certificate | ||
77 | .It TRUSTED CERTIFICATE Ta Xr d2i_X509_AUX 3 Ta certificate | ||
78 | .It X509 CRL Ta Xr d2i_X509_CRL 3 Ta revocation list | ||
79 | .It RSA PRIVATE KEY Ta Xr d2i_PrivateKey 3 Ta private key | ||
80 | .It DSA PRIVATE KEY Ta Xr d2i_PrivateKey 3 Ta private key | ||
81 | .It EC PRIVATE KEY Ta Xr d2i_PrivateKey 3 Ta private key | ||
82 | .El | ||
83 | .Pp | ||
84 | Whenever the selected field is already occupied, another new | ||
85 | .Vt X509_INFO | ||
86 | container is allocated and pushed onto the stack. | ||
87 | Depending on the sequence of objects in the input, this can result | ||
88 | in several partially populated | ||
89 | .Vt X509_INFO | ||
90 | containers being pushed onto the stack. | ||
91 | .Pp | ||
92 | PEM objects of types not listed in the above table are silently skipped. | ||
93 | .Pp | ||
94 | Encrypted certificates and revocation lists are decrypted by calling | ||
95 | .Xr PEM_do_header 3 | ||
96 | internally, passing through the optional arguments | ||
97 | .Fa cb | ||
98 | and | ||
99 | .Fa u . | ||
100 | Encrypted private keys are not decrypted. | ||
101 | Instead, the encrypted form is stored as read. | ||
102 | All the same, | ||
103 | .Xr PEM_get_EVP_CIPHER_INFO 3 | ||
104 | is called internally to check that PEM headers, if there are any, | ||
105 | are valid and specify an encryption the library is prepared to handle. | ||
106 | .Pp | ||
107 | If any error occurs, objects that had already been read | ||
108 | during the same call are deleted again and | ||
109 | .Fa sk | ||
110 | is left unchanged. | ||
111 | .Sh RETURN VALUES | ||
112 | These functions return a pointer to the stack | ||
113 | the objects read were pushed onto or | ||
114 | .Dv NULL | ||
115 | if an error occurs. | ||
116 | They fail if | ||
117 | .Xr PEM_read_bio 3 , | ||
118 | .Xr PEM_get_EVP_CIPHER_INFO 3 , | ||
119 | .Xr PEM_do_header 3 , | ||
120 | or DER decoding fails or if memory is exhausted. | ||
121 | .Sh ERRORS | ||
122 | Diagnostics that can be retrieved with | ||
123 | .Xr ERR_get_error 3 , | ||
124 | .Xr ERR_GET_REASON 3 , | ||
125 | and | ||
126 | .Xr ERR_reason_error_string 3 | ||
127 | include: | ||
128 | .Bl -tag -width Ds | ||
129 | .It Dv ERR_R_ASN1_LIB Qq "ASN1 lib" | ||
130 | DER decoding of a PEM object failed. | ||
131 | .It Dv ERR_R_BUF_LIB Qq BUF lib | ||
132 | .Fn PEM_X509_INFO_read | ||
133 | failed to set up a temporary BIO, for example because memory was exhausted. | ||
134 | .It Dv ERR_R_MALLOC_FAILURE Qq "malloc failure" | ||
135 | .Fn PEM_X509_INFO_read_bio | ||
136 | failed to allocate a new | ||
137 | .Vt X509_INFO , | ||
138 | .Vt STACK_OF(X509_INFO) , | ||
139 | or | ||
140 | .Vt X509_PKEY | ||
141 | object. | ||
142 | .El | ||
143 | .Pp | ||
144 | Additional types of errors can result from | ||
145 | .Xr PEM_read_bio 3 , | ||
146 | .Xr PEM_get_EVP_CIPHER_INFO 3 , | ||
147 | and | ||
148 | .Xr PEM_do_header 3 . | ||
149 | .Pp | ||
150 | After these functions failed due to memory exhaustion, | ||
151 | .Xr ERR_get_error 3 | ||
152 | may sometimes return 0 anyway. | ||
153 | .Sh SEE ALSO | ||
154 | .Xr BIO_new 3 , | ||
155 | .Xr d2i_PrivateKey 3 , | ||
156 | .Xr d2i_X509 3 , | ||
157 | .Xr d2i_X509_CRL 3 , | ||
158 | .Xr EVP_PKEY_new 3 , | ||
159 | .Xr PEM_read 3 , | ||
160 | .Xr PEM_read_bio_PrivateKey 3 , | ||
161 | .Xr STACK_OF 3 , | ||
162 | .Xr X509_CRL_new 3 , | ||
163 | .Xr X509_INFO_new 3 , | ||
164 | .Xr X509_new 3 | ||
165 | .Sh HISTORY | ||
166 | .Fn PEM_X509_INFO_read | ||
167 | first appeared in SSLeay 0.5.1 and | ||
168 | .Fn PEM_X509_INFO_read_bio | ||
169 | in SSLeay 0.6.0. | ||
170 | Both functions have been available since | ||
171 | .Ox 2.4 . | ||
172 | .Sh CAVEATS | ||
173 | It is not an error | ||
174 | if the input does not contain any objects of the desired types. | ||
175 | In that case, nothing is added to | ||
176 | .Fa sk , | ||
177 | or if | ||
178 | .Fa sk | ||
179 | is | ||
180 | .Dv NULL , | ||
181 | a newly allocated, empty stack is returned. | ||
182 | The only way to detect this situation is by comparing | ||
183 | the number of objects on the stack before and after the call. | ||
184 | .Sh BUGS | ||
185 | When reaching the end of the input, these functions call | ||
186 | .Xr ERR_clear_error 3 , | ||
187 | which may hide errors that occurred before calling these functions. | ||