summaryrefslogtreecommitdiff
path: root/src/lib/libssl/doc/SSL_CTX_use_certificate.3
diff options
context:
space:
mode:
authorbentley <>2014-10-12 09:33:04 +0000
committerbentley <>2014-10-12 09:33:04 +0000
commit82b7f378b6907ab315a6e50322d2a0a8794a0aa9 (patch)
treea5087bf8d016a6041c2b6822fbecfd8f6c5e70b1 /src/lib/libssl/doc/SSL_CTX_use_certificate.3
parent0a63f0cf49369e1926567ab62e04e3355cedf0cd (diff)
downloadopenbsd-82b7f378b6907ab315a6e50322d2a0a8794a0aa9.tar.gz
openbsd-82b7f378b6907ab315a6e50322d2a0a8794a0aa9.tar.bz2
openbsd-82b7f378b6907ab315a6e50322d2a0a8794a0aa9.zip
Convert libssl manpages from pod to mdoc(7).
libcrypto has not been started yet. ok schwarze@ miod@
Diffstat (limited to 'src/lib/libssl/doc/SSL_CTX_use_certificate.3')
-rw-r--r--src/lib/libssl/doc/SSL_CTX_use_certificate.3333
1 files changed, 333 insertions, 0 deletions
diff --git a/src/lib/libssl/doc/SSL_CTX_use_certificate.3 b/src/lib/libssl/doc/SSL_CTX_use_certificate.3
new file mode 100644
index 0000000000..eac4d8e42c
--- /dev/null
+++ b/src/lib/libssl/doc/SSL_CTX_use_certificate.3
@@ -0,0 +1,333 @@
1.Dd $Mdocdate: October 12 2014 $
2.Dt SSL_CTX_USE_CERTIFICATE 3
3.Os
4.Sh NAME
5.Nm SSL_CTX_use_certificate ,
6.Nm SSL_CTX_use_certificate_ASN1 ,
7.Nm SSL_CTX_use_certificate_file ,
8.Nm SSL_use_certificate ,
9.Nm SSL_use_certificate_ASN1 ,
10.Nm SSL_use_certificate_file ,
11.Nm SSL_CTX_use_certificate_chain ,
12.Nm SSL_CTX_use_certificate_chain_file ,
13.Nm SSL_CTX_use_PrivateKey ,
14.Nm SSL_CTX_use_PrivateKey_ASN1 ,
15.Nm SSL_CTX_use_PrivateKey_file ,
16.Nm SSL_CTX_use_RSAPrivateKey ,
17.Nm SSL_CTX_use_RSAPrivateKey_ASN1 ,
18.Nm SSL_CTX_use_RSAPrivateKey_file ,
19.Nm SSL_use_PrivateKey_file ,
20.Nm SSL_use_PrivateKey_ASN1 ,
21.Nm SSL_use_PrivateKey ,
22.Nm SSL_use_RSAPrivateKey ,
23.Nm SSL_use_RSAPrivateKey_ASN1 ,
24.Nm SSL_use_RSAPrivateKey_file ,
25.Nm SSL_CTX_check_private_key ,
26.Nm SSL_check_private_key
27.Nd load certificate and key data
28.Sh SYNOPSIS
29.In openssl/ssl.h
30.Ft int
31.Fn SSL_CTX_use_certificate "SSL_CTX *ctx" "X509 *x"
32.Ft int
33.Fn SSL_CTX_use_certificate_ASN1 "SSL_CTX *ctx" "int len" "unsigned char *d"
34.Ft int
35.Fn SSL_CTX_use_certificate_file "SSL_CTX *ctx" "const char *file" "int type"
36.Ft int
37.Fn SSL_use_certificate "SSL *ssl" "X509 *x"
38.Ft int
39.Fn SSL_use_certificate_ASN1 "SSL *ssl" "unsigned char *d" "int len"
40.Ft int
41.Fn SSL_use_certificate_file "SSL *ssl" "const char *file" "int type"
42.Ft int
43.Fn SSL_CTX_use_certificate_chain "SSL_CTX *ctx" "void *buf" "int len"
44.Ft int
45.Fn SSL_CTX_use_certificate_chain_file "SSL_CTX *ctx" "const char *file"
46.Ft int
47.Fn SSL_CTX_use_PrivateKey "SSL_CTX *ctx" "EVP_PKEY *pkey"
48.Ft int
49.Fo SSL_CTX_use_PrivateKey_ASN1
50.Fa "int pk" "SSL_CTX *ctx" "unsigned char *d" "long len"
51.Fc
52.Ft int
53.Fn SSL_CTX_use_PrivateKey_file "SSL_CTX *ctx" "const char *file" "int type"
54.Ft int
55.Fn SSL_CTX_use_RSAPrivateKey "SSL_CTX *ctx" "RSA *rsa"
56.Ft int
57.Fn SSL_CTX_use_RSAPrivateKey_ASN1 "SSL_CTX *ctx" "unsigned char *d" "long len"
58.Ft int
59.Fn SSL_CTX_use_RSAPrivateKey_file "SSL_CTX *ctx" "const char *file" "int type"
60.Ft int
61.Fn SSL_use_PrivateKey "SSL *ssl" "EVP_PKEY *pkey"
62.Ft int
63.Fn SSL_use_PrivateKey_ASN1 "int pk" "SSL *ssl" "unsigned char *d" "long len"
64.Ft int
65.Fn SSL_use_PrivateKey_file "SSL *ssl" "const char *file" "int type"
66.Ft int
67.Fn SSL_use_RSAPrivateKey "SSL *ssl" "RSA *rsa"
68.Ft int
69.Fn SSL_use_RSAPrivateKey_ASN1 "SSL *ssl" "unsigned char *d" "long len"
70.Ft int
71.Fn SSL_use_RSAPrivateKey_file "SSL *ssl" "const char *file" "int type"
72.Ft int
73.Fn SSL_CTX_check_private_key "const SSL_CTX *ctx"
74.Ft int
75.Fn SSL_check_private_key "const SSL *ssl"
76.Sh DESCRIPTION
77These functions load the certificates and private keys into the
78.Vt SSL_CTX
79or
80.Vt SSL
81object, respectively.
82.Pp
83The
84.Fn SSL_CTX_*
85class of functions loads the certificates and keys into the
86.Vt SSL_CTX
87object
88.Fa ctx .
89The information is passed to
90.Vt SSL
91objects
92.Fa ssl
93created from
94.Fa ctx
95with
96.Xr SSL_new 3
97by copying, so that changes applied to
98.Fa ctx
99do not propagate to already existing
100.Vt SSL
101objects.
102.Pp
103The
104.Fn SSL_*
105class of functions only loads certificates and keys into a specific
106.Vt SSL
107object.
108The specific information is kept when
109.Xr SSL_clear 3
110is called for this
111.Vt SSL
112object.
113.Pp
114.Fn SSL_CTX_use_certificate
115loads the certificate
116.Fa x
117into
118.Fa ctx ;
119.Fn SSL_use_certificate
120loads
121.Fa x
122into
123.Fa ssl .
124The rest of the certificates needed to form the complete certificate chain can
125be specified using the
126.Xr SSL_CTX_add_extra_chain_cert 3
127function.
128.Pp
129.Fn SSL_CTX_use_certificate_ASN1
130loads the ASN1 encoded certificate from the memory location
131.Fa d
132(with length
133.Fa len )
134into
135.Fa ctx ;
136.Fn SSL_use_certificate_ASN1
137loads the ASN1 encoded certificate into
138.Fa ssl .
139.Pp
140.Fn SSL_CTX_use_certificate_file
141loads the first certificate stored in
142.Fa file
143into
144.Fa ctx .
145The formatting
146.Fa type
147of the certificate must be specified from the known types
148.Dv SSL_FILETYPE_PEM
149and
150.Dv SSL_FILETYPE_ASN1 .
151.Fn SSL_use_certificate_file
152loads the certificate from
153.Fa file
154into
155.Fa ssl .
156See the
157.Sx NOTES
158section on why
159.Fn SSL_CTX_use_certificate_chain_file
160should be preferred.
161.Pp
162The
163.Fn SSL_CTX_use_certificate_chain*
164functions load a certificate chain into
165.Fa ctx .
166The certificates must be in PEM format and must be sorted starting with the
167subject's certificate (actual client or server certificate),
168followed by intermediate CA certificates if applicable,
169and ending at the highest level (root) CA.
170There is no corresponding function working on a single
171.Vt SSL
172object.
173.Pp
174.Fn SSL_CTX_use_PrivateKey
175adds
176.Fa pkey
177as private key to
178.Fa ctx .
179.Fn SSL_CTX_use_RSAPrivateKey
180adds the private key
181.Fa rsa
182of type RSA to
183.Fa ctx .
184.Fn SSL_use_PrivateKey
185adds
186.Fa pkey
187as private key to
188.Fa ssl ;
189.Fn SSL_use_RSAPrivateKey
190adds
191.Fa rsa
192as private key of type RSA to
193.Fa ssl .
194If a certificate has already been set and the private does not belong to the
195certificate, an error is returned.
196To change a certificate private key pair,
197the new certificate needs to be set with
198.Fn SSL_use_certificate
199or
200.Fn SSL_CTX_use_certificate
201before setting the private key with
202.Fn SSL_CTX_use_PrivateKey
203or
204.Fn SSL_use_PrivateKey .
205.Pp
206.Fn SSL_CTX_use_PrivateKey_ASN1
207adds the private key of type
208.Fa pk
209stored at memory location
210.Fa d
211(length
212.Fa len )
213to
214.Fa ctx .
215.Fn SSL_CTX_use_RSAPrivateKey_ASN1
216adds the private key of type RSA stored at memory location
217.Fa d
218(length
219.Fa len )
220to
221.Fa ctx .
222.Fn SSL_use_PrivateKey_ASN1
223and
224.Fn SSL_use_RSAPrivateKey_ASN1
225add the private key to
226.Fa ssl .
227.Pp
228.Fn SSL_CTX_use_PrivateKey_file
229adds the first private key found in
230.Fa file
231to
232.Fa ctx .
233The formatting
234.Fa type
235of the certificate must be specified from the known types
236.Dv SSL_FILETYPE_PEM
237and
238.Dv SSL_FILETYPE_ASN1 .
239.Fn SSL_CTX_use_RSAPrivateKey_file
240adds the first private RSA key found in
241.Fa file
242to
243.Fa ctx .
244.Fn SSL_use_PrivateKey_file
245adds the first private key found in
246.Fa file
247to
248.Fa ssl ;
249.Fn SSL_use_RSAPrivateKey_file
250adds the first private RSA key found to
251.Fa ssl .
252.Pp
253.Fn SSL_CTX_check_private_key
254checks the consistency of a private key with the corresponding certificate
255loaded into
256.Fa ctx .
257If more than one key/certificate pair (RSA/DSA) is installed,
258the last item installed will be checked.
259If, e.g., the last item was a RSA certificate or key,
260the RSA key/certificate pair will be checked.
261.Fn SSL_check_private_key
262performs the same check for
263.Fa ssl .
264If no key/certificate was explicitly added for this
265.Fa ssl ,
266the last item added into
267.Fa ctx
268will be checked.
269.Sh NOTES
270The internal certificate store of OpenSSL can hold two private key/certificate
271pairs at a time:
272one key/certificate of type RSA and one key/certificate of type DSA.
273The certificate used depends on the cipher select, see also
274.Xr SSL_CTX_set_cipher_list 3 .
275.Pp
276When reading certificates and private keys from file, files of type
277.Dv SSL_FILETYPE_ASN1
278(also known as
279.Em DER ,
280binary encoding) can only contain one certificate or private key; consequently,
281.Fn SSL_CTX_use_certificate_chain_file
282is only applicable to PEM formatting.
283Files of type
284.Dv SSL_FILETYPE_PEM
285can contain more than one item.
286.Pp
287.Fn SSL_CTX_use_certificate_chain_file
288adds the first certificate found in the file to the certificate store.
289The other certificates are added to the store of chain certificates using
290.Xr SSL_CTX_add_extra_chain_cert 3 .
291There exists only one extra chain store, so that the same chain is appended
292to both types of certificates, RSA and DSA!
293If it is not intended to use both type of certificate at the same time,
294it is recommended to use the
295.Fn SSL_CTX_use_certificate_chain_file
296instead of the
297.Fn SSL_CTX_use_certificate_file
298function in order to allow the use of complete certificate chains even when no
299trusted CA storage is used or when the CA issuing the certificate shall not be
300added to the trusted CA storage.
301.Pp
302If additional certificates are needed to complete the chain during the TLS
303negotiation, CA certificates are additionally looked up in the locations of
304trusted CA certificates (see
305.Xr SSL_CTX_load_verify_locations 3 ) .
306.Pp
307The private keys loaded from file can be encrypted.
308In order to successfully load encrypted keys,
309a function returning the passphrase must have been supplied (see
310.Xr SSL_CTX_set_default_passwd_cb 3 ) .
311(Certificate files might be encrypted as well from the technical point of view,
312it however does not make sense as the data in the certificate is considered
313public anyway.)
314.Sh RETURN VALUES
315On success, the functions return 1.
316Otherwise check out the error stack to find out the reason.
317.Sh SEE ALSO
318.Xr ssl 3 ,
319.Xr SSL_clear 3 ,
320.Xr SSL_CTX_add_extra_chain_cert 3 ,
321.Xr SSL_CTX_load_verify_locations 3 ,
322.Xr SSL_CTX_set_cipher_list 3 ,
323.Xr SSL_CTX_set_client_cert_cb 3 ,
324.Xr SSL_CTX_set_default_passwd_cb 3 ,
325.Xr SSL_new 3
326.Sh HISTORY
327Support for DER encoded private keys
328.Pq Dv SSL_FILETYPE_ASN1
329in
330.Fn SSL_CTX_use_PrivateKey_file
331and
332.Fn SSL_use_PrivateKey_file
333was added in 0.9.8.