1 .\" $OpenBSD: tls_load_file.3,v 1.5 2017/01/31 20:53:50 jmc Exp $
3 .\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
4 .\" Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
5 .\" Copyright (c) 2015 Bob Beck <beck@openbsd.org>
6 .\" Copyright (c) 2016, 2017 Joel Sing <jsing@openbsd.org>
8 .\" Permission to use, copy, modify, and distribute this software for any
9 .\" purpose with or without fee is hereby granted, provided that the above
10 .\" copyright notice and this permission notice appear in all copies.
12 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 .Dd $Mdocdate: January 31 2017 $
25 .Nm tls_config_set_ca_file ,
26 .Nm tls_config_set_ca_path ,
27 .Nm tls_config_set_ca_mem ,
28 .Nm tls_config_set_cert_file ,
29 .Nm tls_config_set_cert_mem ,
30 .Nm tls_config_set_key_file ,
31 .Nm tls_config_set_key_mem ,
32 .Nm tls_config_set_ocsp_staple_mem ,
33 .Nm tls_config_set_ocsp_staple_file ,
34 .Nm tls_config_set_keypair_file ,
35 .Nm tls_config_set_keypair_mem ,
36 .Nm tls_config_set_keypair_ocsp_file ,
37 .Nm tls_config_set_keypair_ocsp_mem ,
38 .Nm tls_config_add_keypair_file ,
39 .Nm tls_config_add_keypair_ocsp_mem ,
40 .Nm tls_config_add_keypair_ocsp_file ,
41 .Nm tls_config_add_keypair_mem ,
42 .Nm tls_config_clear_keys ,
43 .Nm tls_config_set_verify_depth ,
44 .Nm tls_config_verify_client ,
45 .Nm tls_config_verify_client_optional
46 .Nd TLS certificate and key configuration
51 .Fa "const char *file"
56 .Fo tls_config_set_ca_file
57 .Fa "struct tls_config *config"
58 .Fa "const char *ca_file"
61 .Fo tls_config_set_ca_path
62 .Fa "struct tls_config *config"
63 .Fa "const char *ca_path"
66 .Fo tls_config_set_ca_mem
67 .Fa "struct tls_config *config"
68 .Fa "const uint8_t *cert"
72 .Fo tls_config_set_cert_file
73 .Fa "struct tls_config *config"
74 .Fa "const char *cert_file"
77 .Fo tls_config_set_cert_mem
78 .Fa "struct tls_config *config"
79 .Fa "const uint8_t *cert"
83 .Fo tls_config_set_key_file
84 .Fa "struct tls_config *config"
85 .Fa "const char *key_file"
88 .Fo tls_config_set_key_mem
89 .Fa "struct tls_config *config"
90 .Fa "const uint8_t *key"
94 .Fo tls_config_set_ocsp_staple_mem
95 .Fa "struct tls_config *config"
96 .Fa "const uint8_t *staple"
100 .Fo tls_config_set_ocsp_staple_file
101 .Fa "struct tls_config *config"
102 .Fa "const uint8_t *staple_file"
105 .Fo tls_config_set_keypair_file
106 .Fa "struct tls_config *config"
107 .Fa "const char *cert_file"
108 .Fa "const char *key_file"
111 .Fo tls_config_set_keypair_mem
112 .Fa "struct tls_config *config"
113 .Fa "const uint8_t *cert"
114 .Fa "size_t cert_len"
115 .Fa "const uint8_t *key"
119 .Fo tls_config_set_keypair_ocsp_file
120 .Fa "struct tls_config *config"
121 .Fa "const char *cert_file"
122 .Fa "const char *key_file"
123 .Fa "const char *staple_file"
126 .Fo tls_config_set_keypair_ocsp_mem
127 .Fa "struct tls_config *config"
128 .Fa "const uint8_t *cert"
129 .Fa "size_t cert_len"
130 .Fa "const uint8_t *key"
132 .Fa "const uint8_t *staple"
133 .Fa "size_t staple_len"
136 .Fo tls_config_add_keypair_file
137 .Fa "struct tls_config *config"
138 .Fa "const char *cert_file"
139 .Fa "const char *key_file"
142 .Fo tls_config_add_keypair_mem
143 .Fa "struct tls_config *config"
144 .Fa "const uint8_t *cert"
145 .Fa "size_t cert_len"
146 .Fa "const uint8_t *key"
150 .Fo tls_config_add_keypair_ocsp_file
151 .Fa "struct tls_config *config"
152 .Fa "const char *cert_file"
153 .Fa "const char *key_file"
154 .Fa "const char *staple_file"
157 .Fo tls_config_add_keypair_ocsp_mem
158 .Fa "struct tls_config *config"
159 .Fa "const uint8_t *cert"
160 .Fa "size_t cert_len"
161 .Fa "const uint8_t *key"
163 .Fa "const uint8_t *staple"
164 .Fa "size_t staple_len"
167 .Fn tls_config_clear_keys "struct tls_config *config"
169 .Fo tls_config_set_verify_depth
170 .Fa "struct tls_config *config"
171 .Fa "int verify_depth"
174 .Fn tls_config_verify_client "struct tls_config *config"
176 .Fn tls_config_verify_client_optional "struct tls_config *config"
179 loads a certificate or key from disk into memory to be loaded with
180 .Fn tls_config_set_ca_mem ,
181 .Fn tls_config_set_cert_mem
183 .Fn tls_config_set_key_mem .
184 A private key will be decrypted if the optional
186 argument is specified.
188 .Fn tls_config_set_ca_file
189 sets the filename used to load a file
190 containing the root certificates.
192 .Fn tls_config_set_ca_path
193 sets the path (directory) which should be searched for root
196 .Fn tls_config_set_ca_mem
197 sets the root certificates directly from memory.
199 .Fn tls_config_set_cert_file
200 sets file from which the public certificate will be read.
202 .Fn tls_config_set_cert_mem
203 sets the public certificate directly from memory.
205 .Fn tls_config_set_key_file
206 sets the file from which the private key will be read.
208 .Fn tls_config_set_key_mem
209 directly sets the private key from memory.
211 .Fn tls_config_set_ocsp_staple_file
212 sets a DER-encoded OCSP response to be stapled during the TLS handshake from
215 .Fn tls_config_set_ocsp_staple_mem
216 sets a DER-encoded OCSP response to be stapled during the TLS handshake from
219 .Fn tls_config_set_keypair_file
220 sets the files from which the public certificate, and private key will be read.
222 .Fn tls_config_set_keypair_mem
223 directly sets the public certificate, and private key from memory.
225 .Fn tls_config_set_keypair_file
226 sets the files from which the public certificate, private key, and DER encoded
227 OCSP staple will be read.
229 .Fn tls_config_set_keypair_ocsp_mem
230 directly sets the public certificate, private key, and DER encoded OCSP staple
233 .Fn tls_config_add_keypair_file
234 adds an additional public certificate, and private key from the specified files,
235 used as an alternative certificate for Server Name Indication (server only).
237 .Fn tls_config_add_keypair_mem
238 adds an additional public certificate, and private key from memory, used as an
239 alternative certificate for Server Name Indication (server only).
241 .Fn tls_config_add_keypair_ocsp_file
242 adds an additional public certificate, private key, and DER encoded OCSP staple
243 from the specified files, used as an alternative certificate for Server Name
244 Indication (server only).
246 .Fn tls_config_add_keypair_ocsp_mem
247 adds an additional public certificate, private key, and DER encoded OCSP staple
248 from memory, used as an alternative certificate for Server Name Indication
251 .Fn tls_config_clear_keys
252 clears any secret keys from memory.
254 .Fn tls_config_set_verify_depth
255 limits the number of intermediate certificates that will be followed during
256 certificate validation.
258 .Fn tls_config_verify_client
259 enables client certificate verification, requiring the client to send
260 a certificate (server only).
262 .Fn tls_config_verify_client_optional
263 enables client certificate verification, without requiring the client
264 to send a certificate (server only).
269 on error or an out of memory condition.
271 The other functions return 0 on success or -1 on error.
273 .Xr tls_config_ocsp_require_stapling 3 ,
274 .Xr tls_config_set_protocols 3 ,
275 .Xr tls_config_set_session_id 3 ,
276 .Xr tls_configure 3 ,
279 .Fn tls_config_set_ca_file ,
280 .Fn tls_config_set_ca_path ,
281 .Fn tls_config_set_cert_file ,
282 .Fn tls_config_set_cert_mem ,
283 .Fn tls_config_set_key_file ,
284 .Fn tls_config_set_key_mem ,
286 .Fn tls_config_set_verify_depth
289 and got their final names in
293 .Fn tls_config_set_ca_mem ,
295 .Fn tls_config_clear_keys
299 .Fn tls_config_verify_client
301 .Fn tls_config_verify_client_optional
305 .Fn tls_config_set_keypair_file
307 .Fn tls_config_set_keypair_mem
311 .Fn tls_config_add_keypair_file
313 .Fn tls_config_add_keypair_mem
317 .An Joel Sing Aq Mt jsing@openbsd.org
318 with contibutions from
319 .An Ted Unangst Aq Mt tedu@openbsd.org
321 .An Bob Beck Aq Mt beck@openbsd.org .
325 .Fn tls_config_set_ca_mem
327 .An Reyk Floeter Aq Mt reyk@openbsd.org .