diff options
Diffstat (limited to 'src/lib/libssl/man/SSL_CTX_use_certificate.3')
-rw-r--r-- | src/lib/libssl/man/SSL_CTX_use_certificate.3 | 451 |
1 files changed, 0 insertions, 451 deletions
diff --git a/src/lib/libssl/man/SSL_CTX_use_certificate.3 b/src/lib/libssl/man/SSL_CTX_use_certificate.3 deleted file mode 100644 index c88a6971b2..0000000000 --- a/src/lib/libssl/man/SSL_CTX_use_certificate.3 +++ /dev/null | |||
@@ -1,451 +0,0 @@ | |||
1 | .\" $OpenBSD: SSL_CTX_use_certificate.3,v 1.17 2025/01/18 10:45:12 tb Exp $ | ||
2 | .\" full merge up to: OpenSSL 3aaa1bd0 Mar 28 16:35:25 2017 +1000 | ||
3 | .\" selective merge up to: OpenSSL d1f7a1e6 Apr 26 14:05:40 2018 +0100 | ||
4 | .\" | ||
5 | .\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. | ||
6 | .\" Copyright (c) 2000, 2001, 2002, 2003, 2005 The OpenSSL Project. | ||
7 | .\" All rights reserved. | ||
8 | .\" | ||
9 | .\" Redistribution and use in source and binary forms, with or without | ||
10 | .\" modification, are permitted provided that the following conditions | ||
11 | .\" are met: | ||
12 | .\" | ||
13 | .\" 1. Redistributions of source code must retain the above copyright | ||
14 | .\" notice, this list of conditions and the following disclaimer. | ||
15 | .\" | ||
16 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
17 | .\" notice, this list of conditions and the following disclaimer in | ||
18 | .\" the documentation and/or other materials provided with the | ||
19 | .\" distribution. | ||
20 | .\" | ||
21 | .\" 3. All advertising materials mentioning features or use of this | ||
22 | .\" software must display the following acknowledgment: | ||
23 | .\" "This product includes software developed by the OpenSSL Project | ||
24 | .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" | ||
25 | .\" | ||
26 | .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
27 | .\" endorse or promote products derived from this software without | ||
28 | .\" prior written permission. For written permission, please contact | ||
29 | .\" openssl-core@openssl.org. | ||
30 | .\" | ||
31 | .\" 5. Products derived from this software may not be called "OpenSSL" | ||
32 | .\" nor may "OpenSSL" appear in their names without prior written | ||
33 | .\" permission of the OpenSSL Project. | ||
34 | .\" | ||
35 | .\" 6. Redistributions of any form whatsoever must retain the following | ||
36 | .\" acknowledgment: | ||
37 | .\" "This product includes software developed by the OpenSSL Project | ||
38 | .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
39 | .\" | ||
40 | .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
41 | .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
42 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
43 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
44 | .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
45 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
46 | .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
47 | .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
49 | .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
50 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
51 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. | ||
52 | .\" | ||
53 | .Dd $Mdocdate: January 18 2025 $ | ||
54 | .Dt SSL_CTX_USE_CERTIFICATE 3 | ||
55 | .Os | ||
56 | .Sh NAME | ||
57 | .Nm SSL_CTX_use_certificate , | ||
58 | .Nm SSL_CTX_use_certificate_ASN1 , | ||
59 | .Nm SSL_CTX_use_certificate_file , | ||
60 | .Nm SSL_use_certificate , | ||
61 | .Nm SSL_use_certificate_ASN1 , | ||
62 | .Nm SSL_use_certificate_chain_file , | ||
63 | .Nm SSL_use_certificate_file , | ||
64 | .Nm SSL_CTX_use_certificate_chain_file , | ||
65 | .Nm SSL_CTX_use_certificate_chain_mem , | ||
66 | .Nm SSL_CTX_use_PrivateKey , | ||
67 | .Nm SSL_CTX_use_PrivateKey_ASN1 , | ||
68 | .Nm SSL_CTX_use_PrivateKey_file , | ||
69 | .Nm SSL_CTX_use_RSAPrivateKey , | ||
70 | .Nm SSL_CTX_use_RSAPrivateKey_ASN1 , | ||
71 | .Nm SSL_CTX_use_RSAPrivateKey_file , | ||
72 | .Nm SSL_use_PrivateKey_file , | ||
73 | .Nm SSL_use_PrivateKey_ASN1 , | ||
74 | .Nm SSL_use_PrivateKey , | ||
75 | .Nm SSL_use_RSAPrivateKey , | ||
76 | .Nm SSL_use_RSAPrivateKey_ASN1 , | ||
77 | .Nm SSL_use_RSAPrivateKey_file , | ||
78 | .Nm SSL_CTX_check_private_key , | ||
79 | .Nm SSL_check_private_key | ||
80 | .Nd load certificate and key data | ||
81 | .Sh SYNOPSIS | ||
82 | .In openssl/ssl.h | ||
83 | .Ft int | ||
84 | .Fn SSL_CTX_use_certificate "SSL_CTX *ctx" "X509 *x" | ||
85 | .Ft int | ||
86 | .Fn SSL_CTX_use_certificate_ASN1 "SSL_CTX *ctx" "int len" "unsigned char *d" | ||
87 | .Ft int | ||
88 | .Fn SSL_CTX_use_certificate_file "SSL_CTX *ctx" "const char *file" "int type" | ||
89 | .Ft int | ||
90 | .Fn SSL_use_certificate "SSL *ssl" "X509 *x" | ||
91 | .Ft int | ||
92 | .Fn SSL_use_certificate_ASN1 "SSL *ssl" "unsigned char *d" "int len" | ||
93 | .Ft int | ||
94 | .Fn SSL_use_certificate_chain_file "SSL *ssl" "const char *file" | ||
95 | .Ft int | ||
96 | .Fn SSL_use_certificate_file "SSL *ssl" "const char *file" "int type" | ||
97 | .Ft int | ||
98 | .Fn SSL_CTX_use_certificate_chain_file "SSL_CTX *ctx" "const char *file" | ||
99 | .Ft int | ||
100 | .Fn SSL_CTX_use_certificate_chain_mem "SSL_CTX *ctx" "void *buf" "int len" | ||
101 | .Ft int | ||
102 | .Fn SSL_CTX_use_PrivateKey "SSL_CTX *ctx" "EVP_PKEY *pkey" | ||
103 | .Ft int | ||
104 | .Fo SSL_CTX_use_PrivateKey_ASN1 | ||
105 | .Fa "int pk" "SSL_CTX *ctx" "unsigned char *d" "long len" | ||
106 | .Fc | ||
107 | .Ft int | ||
108 | .Fn SSL_CTX_use_PrivateKey_file "SSL_CTX *ctx" "const char *file" "int type" | ||
109 | .Ft int | ||
110 | .Fn SSL_CTX_use_RSAPrivateKey "SSL_CTX *ctx" "RSA *rsa" | ||
111 | .Ft int | ||
112 | .Fn SSL_CTX_use_RSAPrivateKey_ASN1 "SSL_CTX *ctx" "unsigned char *d" "long len" | ||
113 | .Ft int | ||
114 | .Fn SSL_CTX_use_RSAPrivateKey_file "SSL_CTX *ctx" "const char *file" "int type" | ||
115 | .Ft int | ||
116 | .Fn SSL_use_PrivateKey "SSL *ssl" "EVP_PKEY *pkey" | ||
117 | .Ft int | ||
118 | .Fn SSL_use_PrivateKey_ASN1 "int pk" "SSL *ssl" "unsigned char *d" "long len" | ||
119 | .Ft int | ||
120 | .Fn SSL_use_PrivateKey_file "SSL *ssl" "const char *file" "int type" | ||
121 | .Ft int | ||
122 | .Fn SSL_use_RSAPrivateKey "SSL *ssl" "RSA *rsa" | ||
123 | .Ft int | ||
124 | .Fn SSL_use_RSAPrivateKey_ASN1 "SSL *ssl" "const unsigned char *d" "long len" | ||
125 | .Ft int | ||
126 | .Fn SSL_use_RSAPrivateKey_file "SSL *ssl" "const char *file" "int type" | ||
127 | .Ft int | ||
128 | .Fn SSL_CTX_check_private_key "const SSL_CTX *ctx" | ||
129 | .Ft int | ||
130 | .Fn SSL_check_private_key "const SSL *ssl" | ||
131 | .Sh DESCRIPTION | ||
132 | These functions load the certificates and private keys into the | ||
133 | .Vt SSL_CTX | ||
134 | or | ||
135 | .Vt SSL | ||
136 | object, respectively. | ||
137 | .Pp | ||
138 | The | ||
139 | .Fn SSL_CTX_* | ||
140 | class of functions loads the certificates and keys into the | ||
141 | .Vt SSL_CTX | ||
142 | object | ||
143 | .Fa ctx . | ||
144 | The information is passed to | ||
145 | .Vt SSL | ||
146 | objects | ||
147 | .Fa ssl | ||
148 | created from | ||
149 | .Fa ctx | ||
150 | with | ||
151 | .Xr SSL_new 3 | ||
152 | by copying, so that changes applied to | ||
153 | .Fa ctx | ||
154 | do not propagate to already existing | ||
155 | .Vt SSL | ||
156 | objects. | ||
157 | .Pp | ||
158 | The | ||
159 | .Fn SSL_* | ||
160 | class of functions only loads certificates and keys into a specific | ||
161 | .Vt SSL | ||
162 | object. | ||
163 | The specific information is kept when | ||
164 | .Xr SSL_clear 3 | ||
165 | is called for this | ||
166 | .Vt SSL | ||
167 | object. | ||
168 | .Pp | ||
169 | .Fn SSL_CTX_use_certificate | ||
170 | loads the certificate | ||
171 | .Fa x | ||
172 | into | ||
173 | .Fa ctx ; | ||
174 | .Fn SSL_use_certificate | ||
175 | loads | ||
176 | .Fa x | ||
177 | into | ||
178 | .Fa ssl . | ||
179 | The rest of the certificates needed to form the complete certificate chain can | ||
180 | be specified using the | ||
181 | .Xr SSL_CTX_add_extra_chain_cert 3 | ||
182 | function. | ||
183 | .Pp | ||
184 | .Fn SSL_CTX_use_certificate_ASN1 | ||
185 | loads the ASN1 encoded certificate from the memory location | ||
186 | .Fa d | ||
187 | (with length | ||
188 | .Fa len ) | ||
189 | into | ||
190 | .Fa ctx ; | ||
191 | .Fn SSL_use_certificate_ASN1 | ||
192 | loads the ASN1 encoded certificate into | ||
193 | .Fa ssl . | ||
194 | .Pp | ||
195 | .Fn SSL_CTX_use_certificate_file | ||
196 | loads the first certificate stored in | ||
197 | .Fa file | ||
198 | into | ||
199 | .Fa ctx . | ||
200 | The formatting | ||
201 | .Fa type | ||
202 | of the certificate must be specified from the known types | ||
203 | .Dv SSL_FILETYPE_PEM | ||
204 | and | ||
205 | .Dv SSL_FILETYPE_ASN1 . | ||
206 | .Fn SSL_use_certificate_file | ||
207 | loads the certificate from | ||
208 | .Fa file | ||
209 | into | ||
210 | .Fa ssl . | ||
211 | See the | ||
212 | .Sx NOTES | ||
213 | section on why | ||
214 | .Fn SSL_CTX_use_certificate_chain_file | ||
215 | should be preferred. | ||
216 | .Pp | ||
217 | The | ||
218 | .Fn SSL_CTX_use_certificate_chain* | ||
219 | functions load a certificate chain into | ||
220 | .Fa ctx . | ||
221 | The certificates must be in PEM format and must be sorted starting with the | ||
222 | subject's certificate (actual client or server certificate), | ||
223 | followed by intermediate CA certificates if applicable, | ||
224 | and ending at the highest level (root) CA. | ||
225 | With the exception of | ||
226 | .Fn SSL_use_certificate_chain_file , | ||
227 | there is no corresponding function working on a single | ||
228 | .Vt SSL | ||
229 | object. | ||
230 | .Pp | ||
231 | .Fn SSL_CTX_use_PrivateKey | ||
232 | adds | ||
233 | .Fa pkey | ||
234 | as private key to | ||
235 | .Fa ctx . | ||
236 | .Fn SSL_CTX_use_RSAPrivateKey | ||
237 | adds the private key | ||
238 | .Fa rsa | ||
239 | of type RSA to | ||
240 | .Fa ctx . | ||
241 | .Fn SSL_use_PrivateKey | ||
242 | adds | ||
243 | .Fa pkey | ||
244 | as private key to | ||
245 | .Fa ssl ; | ||
246 | .Fn SSL_use_RSAPrivateKey | ||
247 | adds | ||
248 | .Fa rsa | ||
249 | as private key of type RSA to | ||
250 | .Fa ssl . | ||
251 | If a certificate has already been set and the private does not belong to the | ||
252 | certificate, an error is returned. | ||
253 | To change a certificate private key pair, | ||
254 | the new certificate needs to be set with | ||
255 | .Fn SSL_use_certificate | ||
256 | or | ||
257 | .Fn SSL_CTX_use_certificate | ||
258 | before setting the private key with | ||
259 | .Fn SSL_CTX_use_PrivateKey | ||
260 | or | ||
261 | .Fn SSL_use_PrivateKey . | ||
262 | .Pp | ||
263 | .Fn SSL_CTX_use_PrivateKey_ASN1 | ||
264 | adds the private key of type | ||
265 | .Fa pk | ||
266 | stored at memory location | ||
267 | .Fa d | ||
268 | (length | ||
269 | .Fa len ) | ||
270 | to | ||
271 | .Fa ctx . | ||
272 | .Fn SSL_CTX_use_RSAPrivateKey_ASN1 | ||
273 | adds the private key of type RSA stored at memory location | ||
274 | .Fa d | ||
275 | (length | ||
276 | .Fa len ) | ||
277 | to | ||
278 | .Fa ctx . | ||
279 | .Fn SSL_use_PrivateKey_ASN1 | ||
280 | and | ||
281 | .Fn SSL_use_RSAPrivateKey_ASN1 | ||
282 | add the private key to | ||
283 | .Fa ssl . | ||
284 | .Pp | ||
285 | .Fn SSL_CTX_use_PrivateKey_file | ||
286 | adds the first private key found in | ||
287 | .Fa file | ||
288 | to | ||
289 | .Fa ctx . | ||
290 | The formatting | ||
291 | .Fa type | ||
292 | of the private key must be specified from the known types | ||
293 | .Dv SSL_FILETYPE_PEM | ||
294 | and | ||
295 | .Dv SSL_FILETYPE_ASN1 . | ||
296 | .Fn SSL_CTX_use_RSAPrivateKey_file | ||
297 | adds the first private RSA key found in | ||
298 | .Fa file | ||
299 | to | ||
300 | .Fa ctx . | ||
301 | .Fn SSL_use_PrivateKey_file | ||
302 | adds the first private key found in | ||
303 | .Fa file | ||
304 | to | ||
305 | .Fa ssl ; | ||
306 | .Fn SSL_use_RSAPrivateKey_file | ||
307 | adds the first private RSA key found to | ||
308 | .Fa ssl . | ||
309 | .Pp | ||
310 | The | ||
311 | .Fn SSL_CTX_check_private_key | ||
312 | function is seriously misnamed. | ||
313 | It compares the | ||
314 | .Em public | ||
315 | key components and parameters of an OpenSSL private key with the | ||
316 | corresponding certificate loaded into | ||
317 | .Fa ctx . | ||
318 | If more than one key/certificate pair (RSA/ECDSA) is installed, | ||
319 | the last item installed will be compared. | ||
320 | If, e.g., the last item was an RSA certificate or key, | ||
321 | the RSA key/certificate pair will be checked. | ||
322 | .Fn SSL_check_private_key | ||
323 | performs the same | ||
324 | .Em public | ||
325 | key comparison for | ||
326 | .Fa ssl . | ||
327 | If no key/certificate was explicitly added for this | ||
328 | .Fa ssl , | ||
329 | the last item added into | ||
330 | .Fa ctx | ||
331 | will be checked. | ||
332 | .Pp | ||
333 | Despite the name, neither | ||
334 | .Fn SSL_CTX_check_private_key | ||
335 | nor | ||
336 | .Fn SSL_check_private_key | ||
337 | checks whether the private key component is indeed a private key, | ||
338 | nor whether it matches the public key component. | ||
339 | They merely compare the public materials (e.g. exponent and modulus of | ||
340 | an RSA key) and/or key parameters (e.g. EC params of an EC key) of a | ||
341 | key pair. | ||
342 | .Sh NOTES | ||
343 | The internal certificate store of OpenSSL can hold several private | ||
344 | key/certificate pairs at a time. | ||
345 | The certificate used depends on the cipher selected. | ||
346 | See also | ||
347 | .Xr SSL_CTX_set_cipher_list 3 . | ||
348 | .Pp | ||
349 | When reading certificates and private keys from file, files of type | ||
350 | .Dv SSL_FILETYPE_ASN1 | ||
351 | (also known as | ||
352 | .Em DER , | ||
353 | binary encoding) can only contain one certificate or private key; consequently, | ||
354 | .Fn SSL_CTX_use_certificate_chain_file | ||
355 | is only applicable to PEM formatting. | ||
356 | Files of type | ||
357 | .Dv SSL_FILETYPE_PEM | ||
358 | can contain more than one item. | ||
359 | .Pp | ||
360 | .Fn SSL_CTX_use_certificate_chain_file | ||
361 | adds the first certificate found in the file to the certificate store. | ||
362 | The other certificates are added to the store of chain certificates using | ||
363 | .Xr SSL_CTX_add1_chain_cert 3 . | ||
364 | It is recommended to use the | ||
365 | .Fn SSL_CTX_use_certificate_chain_file | ||
366 | instead of the | ||
367 | .Fn SSL_CTX_use_certificate_file | ||
368 | function in order to allow the use of complete certificate chains even when no | ||
369 | trusted CA storage is used or when the CA issuing the certificate shall not be | ||
370 | added to the trusted CA storage. | ||
371 | .Pp | ||
372 | If additional certificates are needed to complete the chain during the TLS | ||
373 | negotiation, CA certificates are additionally looked up in the locations of | ||
374 | trusted CA certificates (see | ||
375 | .Xr SSL_CTX_load_verify_locations 3 ) . | ||
376 | .Pp | ||
377 | The private keys loaded from file can be encrypted. | ||
378 | In order to successfully load encrypted keys, | ||
379 | a function returning the passphrase must have been supplied (see | ||
380 | .Xr SSL_CTX_set_default_passwd_cb 3 ) . | ||
381 | (Certificate files might be encrypted as well from the technical point of view, | ||
382 | it however does not make sense as the data in the certificate is considered | ||
383 | public anyway.) | ||
384 | .Sh RETURN VALUES | ||
385 | On success, the functions return 1. | ||
386 | Otherwise check out the error stack to find out the reason. | ||
387 | .Sh SEE ALSO | ||
388 | .Xr ssl 3 , | ||
389 | .Xr SSL_clear 3 , | ||
390 | .Xr SSL_CTX_add1_chain_cert 3 , | ||
391 | .Xr SSL_CTX_add_extra_chain_cert 3 , | ||
392 | .Xr SSL_CTX_load_verify_locations 3 , | ||
393 | .Xr SSL_CTX_set_cipher_list 3 , | ||
394 | .Xr SSL_CTX_set_client_CA_list 3 , | ||
395 | .Xr SSL_CTX_set_client_cert_cb 3 , | ||
396 | .Xr SSL_CTX_set_default_passwd_cb 3 , | ||
397 | .Xr SSL_new 3 , | ||
398 | .Xr X509_check_private_key 3 | ||
399 | .Sh HISTORY | ||
400 | .Fn SSL_use_certificate , | ||
401 | .Fn SSL_use_certificate_file , | ||
402 | .Fn SSL_use_RSAPrivateKey , | ||
403 | and | ||
404 | .Fn SSL_use_RSAPrivateKey_file | ||
405 | appeared in SSLeay 0.4 or earlier. | ||
406 | .Fn SSL_use_certificate_ASN1 | ||
407 | and | ||
408 | .Fn SSL_use_RSAPrivateKey_ASN1 | ||
409 | first appeared in SSLeay 0.5.1. | ||
410 | .Fn SSL_use_PrivateKey_file , | ||
411 | .Fn SSL_use_PrivateKey_ASN1 , | ||
412 | and | ||
413 | .Fn SSL_use_PrivateKey | ||
414 | first appeared in SSLeay 0.6.0. | ||
415 | .Fn SSL_CTX_use_certificate , | ||
416 | .Fn SSL_CTX_use_certificate_ASN1 , | ||
417 | .Fn SSL_CTX_use_certificate_file , | ||
418 | .Fn SSL_CTX_use_PrivateKey , | ||
419 | .Fn SSL_CTX_use_PrivateKey_ASN1 , | ||
420 | .Fn SSL_CTX_use_PrivateKey_file , | ||
421 | .Fn SSL_CTX_use_RSAPrivateKey , | ||
422 | .Fn SSL_CTX_use_RSAPrivateKey_ASN1 , | ||
423 | and | ||
424 | .Fn SSL_CTX_use_RSAPrivateKey_file | ||
425 | first appeared in SSLeay 0.6.1. | ||
426 | .Fn SSL_CTX_check_private_key | ||
427 | and | ||
428 | .Fn SSL_check_private_key | ||
429 | first appeared in SSLeay 0.6.5. | ||
430 | All these functions have been available since | ||
431 | .Ox 2.4 . | ||
432 | .Pp | ||
433 | .Fn SSL_CTX_use_certificate_chain_file | ||
434 | first appeared in OpenSSL 0.9.4 and has been available since | ||
435 | .Ox 2.6 . | ||
436 | .Pp | ||
437 | .Fn SSL_use_certificate_chain_file | ||
438 | first appeared in OpenSSL 1.1.0 and has been available since | ||
439 | .Ox 6.9 . | ||
440 | .Pp | ||
441 | Support for DER encoded private keys | ||
442 | .Pq Dv SSL_FILETYPE_ASN1 | ||
443 | in | ||
444 | .Fn SSL_CTX_use_PrivateKey_file | ||
445 | and | ||
446 | .Fn SSL_use_PrivateKey_file | ||
447 | was added in 0.9.8. | ||
448 | .Pp | ||
449 | .Fn SSL_CTX_use_certificate_chain_mem | ||
450 | first appeared in | ||
451 | .Ox 5.7 . | ||