summaryrefslogtreecommitdiff
path: root/src/lib/libssl/man
diff options
context:
space:
mode:
authorschwarze <>2016-11-05 15:32:20 +0000
committerschwarze <>2016-11-05 15:32:20 +0000
commit5af30545c000c195ca6e44f207da004e5780ddb5 (patch)
tree1672f1234352c29443fcacb44e22f1b20f174d99 /src/lib/libssl/man
parentba7c6bac5d2c870a4d1c1ce9f08db5e57c660625 (diff)
downloadopenbsd-5af30545c000c195ca6e44f207da004e5780ddb5.tar.gz
openbsd-5af30545c000c195ca6e44f207da004e5780ddb5.tar.bz2
openbsd-5af30545c000c195ca6e44f207da004e5780ddb5.zip
move manual pages from doc/ to man/ for consistency with other
libraries, in particular considering that there are unrelated files in doc/; requested by jsing@ and beck@
Diffstat (limited to 'src/lib/libssl/man')
-rw-r--r--src/lib/libssl/man/BIO_f_ssl.3479
-rw-r--r--src/lib/libssl/man/Makefile93
-rw-r--r--src/lib/libssl/man/SSL_CIPHER_get_name.3196
-rw-r--r--src/lib/libssl/man/SSL_COMP_add_compression_method.368
-rw-r--r--src/lib/libssl/man/SSL_CTX_add_extra_chain_cert.345
-rw-r--r--src/lib/libssl/man/SSL_CTX_add_session.390
-rw-r--r--src/lib/libssl/man/SSL_CTX_ctrl.349
-rw-r--r--src/lib/libssl/man/SSL_CTX_flush_sessions.357
-rw-r--r--src/lib/libssl/man/SSL_CTX_free.353
-rw-r--r--src/lib/libssl/man/SSL_CTX_get_ex_new_index.370
-rw-r--r--src/lib/libssl/man/SSL_CTX_get_verify_mode.373
-rw-r--r--src/lib/libssl/man/SSL_CTX_load_verify_locations.3161
-rw-r--r--src/lib/libssl/man/SSL_CTX_new.3111
-rw-r--r--src/lib/libssl/man/SSL_CTX_sess_number.3104
-rw-r--r--src/lib/libssl/man/SSL_CTX_sess_set_cache_size.355
-rw-r--r--src/lib/libssl/man/SSL_CTX_sess_set_get_cb.3159
-rw-r--r--src/lib/libssl/man/SSL_CTX_sessions.335
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_cert_store.380
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_cert_verify_callback.3112
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_cipher_list.382
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_client_CA_list.3132
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_client_cert_cb.3143
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_default_passwd_cb.395
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_generate_session_id.3196
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_info_callback.3167
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_max_cert_list.3105
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_mode.3126
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_msg_callback.3135
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_options.3395
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_psk_client_callback.368
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_quiet_shutdown.3115
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_session_cache_mode.3143
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_session_id_context.3105
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_ssl_version.381
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_timeout.365
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_tmp_dh_callback.3235
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_tmp_rsa_callback.3231
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_verify.3415
-rw-r--r--src/lib/libssl/man/SSL_CTX_use_certificate.3336
-rw-r--r--src/lib/libssl/man/SSL_CTX_use_psk_identity_hint.3110
-rw-r--r--src/lib/libssl/man/SSL_SESSION_free.384
-rw-r--r--src/lib/libssl/man/SSL_SESSION_get_ex_new_index.380
-rw-r--r--src/lib/libssl/man/SSL_SESSION_get_time.398
-rw-r--r--src/lib/libssl/man/SSL_accept.3103
-rw-r--r--src/lib/libssl/man/SSL_alert_type_string.3193
-rw-r--r--src/lib/libssl/man/SSL_clear.392
-rw-r--r--src/lib/libssl/man/SSL_connect.3102
-rw-r--r--src/lib/libssl/man/SSL_do_handshake.3101
-rw-r--r--src/lib/libssl/man/SSL_free.367
-rw-r--r--src/lib/libssl/man/SSL_get_SSL_CTX.328
-rw-r--r--src/lib/libssl/man/SSL_get_ciphers.368
-rw-r--r--src/lib/libssl/man/SSL_get_client_CA_list.361
-rw-r--r--src/lib/libssl/man/SSL_get_current_cipher.352
-rw-r--r--src/lib/libssl/man/SSL_get_default_timeout.336
-rw-r--r--src/lib/libssl/man/SSL_get_error.3169
-rw-r--r--src/lib/libssl/man/SSL_get_ex_data_X509_STORE_CTX_idx.365
-rw-r--r--src/lib/libssl/man/SSL_get_ex_new_index.376
-rw-r--r--src/lib/libssl/man/SSL_get_fd.346
-rw-r--r--src/lib/libssl/man/SSL_get_peer_cert_chain.347
-rw-r--r--src/lib/libssl/man/SSL_get_peer_certificate.353
-rw-r--r--src/lib/libssl/man/SSL_get_psk_identity.344
-rw-r--r--src/lib/libssl/man/SSL_get_rbio.345
-rw-r--r--src/lib/libssl/man/SSL_get_session.397
-rw-r--r--src/lib/libssl/man/SSL_get_verify_result.349
-rw-r--r--src/lib/libssl/man/SSL_get_version.335
-rw-r--r--src/lib/libssl/man/SSL_library_init.354
-rw-r--r--src/lib/libssl/man/SSL_load_client_CA_file.353
-rw-r--r--src/lib/libssl/man/SSL_new.341
-rw-r--r--src/lib/libssl/man/SSL_pending.344
-rw-r--r--src/lib/libssl/man/SSL_read.3193
-rw-r--r--src/lib/libssl/man/SSL_rstate_string.355
-rw-r--r--src/lib/libssl/man/SSL_session_reused.332
-rw-r--r--src/lib/libssl/man/SSL_set_bio.351
-rw-r--r--src/lib/libssl/man/SSL_set_connect_state.371
-rw-r--r--src/lib/libssl/man/SSL_set_fd.373
-rw-r--r--src/lib/libssl/man/SSL_set_session.368
-rw-r--r--src/lib/libssl/man/SSL_set_shutdown.388
-rw-r--r--src/lib/libssl/man/SSL_set_verify_result.342
-rw-r--r--src/lib/libssl/man/SSL_shutdown.3204
-rw-r--r--src/lib/libssl/man/SSL_state_string.357
-rw-r--r--src/lib/libssl/man/SSL_want.3103
-rw-r--r--src/lib/libssl/man/SSL_write.3175
-rw-r--r--src/lib/libssl/man/d2i_SSL_SESSION.3129
-rw-r--r--src/lib/libssl/man/ssl.31319
84 files changed, 10313 insertions, 0 deletions
diff --git a/src/lib/libssl/man/BIO_f_ssl.3 b/src/lib/libssl/man/BIO_f_ssl.3
new file mode 100644
index 0000000000..e322fd7887
--- /dev/null
+++ b/src/lib/libssl/man/BIO_f_ssl.3
@@ -0,0 +1,479 @@
1.\"
2.\" $OpenBSD: BIO_f_ssl.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt BIO_F_SSL 3
6.Os
7.Sh NAME
8.Nm BIO_f_ssl ,
9.Nm BIO_set_ssl ,
10.Nm BIO_get_ssl ,
11.Nm BIO_set_ssl_mode ,
12.Nm BIO_set_ssl_renegotiate_bytes ,
13.Nm BIO_get_num_renegotiates ,
14.Nm BIO_set_ssl_renegotiate_timeout ,
15.Nm BIO_new_ssl ,
16.Nm BIO_new_ssl_connect ,
17.Nm BIO_new_buffer_ssl_connect ,
18.Nm BIO_ssl_copy_session_id ,
19.Nm BIO_ssl_shutdown ,
20.Nm BIO_do_handshake
21.Nd SSL BIO
22.Sh SYNOPSIS
23.In openssl/bio.h
24.In openssl/ssl.h
25.Ft BIO_METHOD *
26.Fn BIO_f_ssl void
27.Fd #define BIO_set_ssl(b,ssl,c) BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)ssl)
28.Fd #define BIO_get_ssl(b,sslp) BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)sslp)
29.Fd #define BIO_set_ssl_mode(b,client) BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL)
30.Fd #define BIO_set_ssl_renegotiate_bytes(b,num) \
31BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL)
32.Fd #define BIO_set_ssl_renegotiate_timeout(b,seconds) \
33BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL)
34.Fd #define BIO_get_num_renegotiates(b) \
35BIO_ctrl(b,BIO_C_SET_SSL_NUM_RENEGOTIATES,0,NULL)
36.Ft BIO *
37.Fn BIO_new_ssl "SSL_CTX *ctx" "int client"
38.Ft BIO *
39.Fn BIO_new_ssl_connect "SSL_CTX *ctx"
40.Ft BIO *
41.Fn BIO_new_buffer_ssl_connect "SSL_CTX *ctx"
42.Ft int
43.Fn BIO_ssl_copy_session_id "BIO *to" "BIO *from"
44.Ft void
45.Fn BIO_ssl_shutdown "BIO *bio"
46.Fd #define BIO_do_handshake(b) BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL)
47.Sh DESCRIPTION
48.Fn BIO_f_ssl
49returns the
50.Vt SSL
51.Vt BIO
52method.
53This is a filter
54.Vt BIO
55which is a wrapper around the OpenSSL
56.Vt SSL
57routines adding a
58.Vt BIO
59.Dq flavor
60to SSL I/O.
61.Pp
62I/O performed on an
63.Vt SSL
64.Vt BIO
65communicates using the SSL protocol with
66the
67.Vt SSL Ns 's
68read and write
69.Vt BIO Ns s.
70If an SSL connection is not established then an attempt is made to establish
71one on the first I/O call.
72.Pp
73If a
74.Vt BIO
75is appended to an
76.Vt SSL
77.Vt BIO
78using
79.Xr BIO_push 3
80it is automatically used as the
81.Vt SSL
82.Vt BIO Ns 's read and write
83.Vt BIO Ns s.
84.Pp
85Calling
86.Xr BIO_reset 3
87on an
88.Vt SSL
89.Vt BIO
90closes down any current SSL connection by calling
91.Xr SSL_shutdown 3 .
92.Xr BIO_reset
93is then sent to the next
94.Vt BIO
95in the chain; this will typically disconnect the underlying transport.
96The
97.Vt SSL
98.Vt BIO
99is then reset to the initial accept or connect state.
100.Pp
101If the close flag is set when an
102.Vt SSL
103.Vt BIO
104is freed then the internal
105.Vt SSL
106structure is also freed using
107.Xr SSL_free 3 .
108.Pp
109.Fn BIO_set_ssl
110sets the internal
111.Vt SSL
112pointer of
113.Vt BIO
114.Fa b
115to
116.Fa ssl
117using
118the close flag
119.Fa c .
120.Pp
121.Fn BIO_get_ssl
122retrieves the
123.Vt SSL
124pointer of
125.Vt BIO
126.Fa b ;
127it can then be manipulated using the standard SSL library functions.
128.Pp
129.Fn BIO_set_ssl_mode
130sets the
131.Vt SSL
132.Vt BIO
133mode to
134.Fa client .
135If
136.Fa client
137is 1, client mode is set.
138If
139.Fa client
140is 0, server mode is set.
141.Pp
142.Fn BIO_set_ssl_renegotiate_bytes
143sets the renegotiate byte count to
144.Fa num .
145When set after every
146.Fa num
147bytes of I/O (read and write) the SSL session is automatically renegotiated.
148.Fa num
149must be at least 512 bytes.
150.Pp
151.Fn BIO_set_ssl_renegotiate_timeout
152sets the renegotiate timeout to
153.Fa seconds .
154When the renegotiate timeout elapses the session is automatically renegotiated.
155.Pp
156.Fn BIO_get_num_renegotiates
157returns the total number of session renegotiations due to I/O or timeout.
158.Pp
159.Fn BIO_new_ssl
160allocates an
161.Vt SSL
162.Vt BIO
163using
164.Vt SSL_CTX
165.Va ctx
166and using client mode if
167.Fa client
168is nonzero.
169.Pp
170.Fn BIO_new_ssl_connect
171creates a new
172.Vt BIO
173chain consisting of an
174.Vt SSL
175.Vt BIO
176(using
177.Fa ctx )
178followed by a connect BIO.
179.Pp
180.Fn BIO_new_buffer_ssl_connect
181creates a new
182.Vt BIO
183chain consisting of a buffering
184.Vt BIO ,
185an
186.Vt SSL
187.Vt BIO
188(using
189.Fa ctx )
190and a connect
191.Vt BIO .
192.Pp
193.Fn BIO_ssl_copy_session_id
194copies an SSL session id between
195.Vt BIO
196chains
197.Fa from
198and
199.Fa to .
200It does this by locating the
201.Vt SSL
202.Vt BIO Ns s
203in each chain and calling
204.Xr SSL_copy_session_id 3
205on the internal
206.Vt SSL
207pointer.
208.Pp
209.Fn BIO_ssl_shutdown
210closes down an SSL connection on
211.Vt BIO
212chain
213.Fa bio .
214It does this by locating the
215.Vt SSL
216.Vt BIO
217in the
218chain and calling
219.Xr SSL_shutdown 3
220on its internal
221.Vt SSL
222pointer.
223.Pp
224.Fn BIO_do_handshake
225attempts to complete an SSL handshake on the supplied
226.Vt BIO
227and establish the SSL connection.
228It returns 1 if the connection was established successfully.
229A zero or negative value is returned if the connection could not be
230established; the call
231.Xr BIO_should_retry 3
232should be used for non blocking connect
233.Vt BIO Ns s
234to determine if the call should be retried.
235If an SSL connection has already been established this call has no effect.
236.Sh NOTES
237.Vt SSL
238.Vt BIO Ns s
239are exceptional in that if the underlying transport is non-blocking they can
240still request a retry in exceptional circumstances.
241Specifically this will happen if a session renegotiation takes place during a
242.Xr BIO_read 3
243operation.
244One case where this happens is when step up occurs.
245.Pp
246In OpenSSL 0.9.6 and later the SSL flag
247.Dv SSL_AUTO_RETRY
248can be set to disable this behaviour.
249In other words, when this flag is set an
250.Vt SSL
251.Vt BIO
252using a blocking transport will never request a retry.
253.Pp
254Since unknown
255.Xr BIO_ctrl 3
256operations are sent through filter
257.Vt BIO Ns s
258the server name and port can be set using
259.Xr BIO_set_host 3
260on the
261.Vt BIO
262returned by
263.Fn BIO_new_ssl_connect
264without having to locate the connect
265.Vt BIO
266first.
267.Pp
268Applications do not have to call
269.Fn BIO_do_handshake
270but may wish to do so to separate the handshake process from other I/O
271processing.
272.Sh RETURN VALUES
273.\" XXX
274This section is incomplete.
275.Sh EXAMPLES
276This SSL/TLS client example attempts to retrieve a page from an SSL/TLS web
277server.
278The I/O routines are identical to those of the unencrypted example in
279.Xr BIO_s_connect 3 .
280.Bd -literal
281BIO *sbio, *out;
282int len;
283char tmpbuf[1024];
284SSL_CTX *ctx;
285SSL *ssl;
286
287ERR_load_crypto_strings();
288ERR_load_SSL_strings();
289OpenSSL_add_all_algorithms();
290
291/*
292 * We would seed the PRNG here if the platform didn't do it automatically
293 */
294
295ctx = SSL_CTX_new(SSLv23_client_method());
296
297/*
298 * We'd normally set some stuff like the verify paths and mode here because
299 * as things stand this will connect to any server whose certificate is
300 * signed by any CA.
301 */
302
303sbio = BIO_new_ssl_connect(ctx);
304
305BIO_get_ssl(sbio, &ssl);
306
307if (!ssl) {
308 fprintf(stderr, "Can't locate SSL pointer\en");
309 /* whatever ... */
310}
311
312/* Don't want any retries */
313SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY);
314
315/* We might want to do other things with ssl here */
316
317BIO_set_conn_hostname(sbio, "localhost:https");
318
319out = BIO_new_fp(stdout, BIO_NOCLOSE);
320if (BIO_do_connect(sbio) <= 0) {
321 fprintf(stderr, "Error connecting to server\en");
322 ERR_print_errors_fp(stderr);
323 /* whatever ... */
324}
325
326if (BIO_do_handshake(sbio) <= 0) {
327 fprintf(stderr, "Error establishing SSL connection\en");
328 ERR_print_errors_fp(stderr);
329 /* whatever ... */
330}
331
332/* Could examine ssl here to get connection info */
333
334BIO_puts(sbio, "GET / HTTP/1.0\en\en");
335for (;;) {
336 len = BIO_read(sbio, tmpbuf, 1024);
337 if(len <= 0) break;
338 BIO_write(out, tmpbuf, len);
339}
340BIO_free_all(sbio);
341BIO_free(out);
342.Ed
343.Pp
344Here is a simple server example.
345It makes use of a buffering
346.Vt BIO
347to allow lines to be read from the
348.Vt SSL
349.Vt BIO
350using
351.Xr BIO_gets 3 .
352It creates a pseudo web page containing the actual request from a client and
353also echoes the request to standard output.
354.Bd -literal
355BIO *sbio, *bbio, *acpt, *out;
356int len;
357char tmpbuf[1024];
358SSL_CTX *ctx;
359SSL *ssl;
360
361ERR_load_crypto_strings();
362ERR_load_SSL_strings();
363OpenSSL_add_all_algorithms();
364
365/* Might seed PRNG here */
366
367ctx = SSL_CTX_new(SSLv23_server_method());
368
369if (!SSL_CTX_use_certificate_file(ctx,"server.pem",SSL_FILETYPE_PEM)
370 || !SSL_CTX_use_PrivateKey_file(ctx,"server.pem",SSL_FILETYPE_PEM)
371 || !SSL_CTX_check_private_key(ctx)) {
372 fprintf(stderr, "Error setting up SSL_CTX\en");
373 ERR_print_errors_fp(stderr);
374 return 0;
375}
376
377/*
378 * Might do other things here like setting verify locations and DH and/or
379 * RSA temporary key callbacks
380 */
381
382/* New SSL BIO setup as server */
383sbio = BIO_new_ssl(ctx,0);
384
385BIO_get_ssl(sbio, &ssl);
386
387if (!ssl) {
388 fprintf(stderr, "Can't locate SSL pointer\en");
389 /* whatever ... */
390}
391
392/* Don't want any retries */
393SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY);
394
395/* Create the buffering BIO */
396
397bbio = BIO_new(BIO_f_buffer());
398
399/* Add to chain */
400sbio = BIO_push(bbio, sbio);
401
402acpt = BIO_new_accept("4433");
403
404/*
405 * By doing this when a new connection is established we automatically
406 * have sbio inserted into it. The BIO chain is now 'swallowed' by the
407 * accept BIO and will be freed when the accept BIO is freed.
408 */
409
410BIO_set_accept_bios(acpt,sbio);
411
412out = BIO_new_fp(stdout, BIO_NOCLOSE);
413
414/* Setup accept BIO */
415if (BIO_do_accept(acpt) <= 0) {
416 fprintf(stderr, "Error setting up accept BIO\en");
417 ERR_print_errors_fp(stderr);
418 return 0;
419}
420
421/* Now wait for incoming connection */
422if (BIO_do_accept(acpt) <= 0) {
423 fprintf(stderr, "Error in connection\en");
424 ERR_print_errors_fp(stderr);
425 return 0;
426}
427
428/* We only want one connection so remove and free accept BIO */
429
430sbio = BIO_pop(acpt);
431
432BIO_free_all(acpt);
433
434if (BIO_do_handshake(sbio) <= 0) {
435 fprintf(stderr, "Error in SSL handshake\en");
436 ERR_print_errors_fp(stderr);
437 return 0;
438}
439
440BIO_puts(sbio, "HTTP/1.0 200 OK\er\enContent-type: text/plain\er\en\er\en");
441BIO_puts(sbio, "\er\enConnection Established\er\enRequest headers:\er\en");
442BIO_puts(sbio, "--------------------------------------------------\er\en");
443
444for (;;) {
445 len = BIO_gets(sbio, tmpbuf, 1024);
446 if (len <= 0)
447 break;
448 BIO_write(sbio, tmpbuf, len);
449 BIO_write(out, tmpbuf, len);
450 /* Look for blank line signifying end of headers */
451 if ((tmpbuf[0] == '\er') || (tmpbuf[0] == '\en'))
452 break;
453}
454
455BIO_puts(sbio, "--------------------------------------------------\er\en");
456BIO_puts(sbio, "\er\en");
457
458/* Since there is a buffering BIO present we had better flush it */
459BIO_flush(sbio);
460
461BIO_free_all(sbio);
462.Ed
463.Sh BUGS
464In OpenSSL versions before 1.0.0 the
465.Xr BIO_pop 3
466call was handled incorrectly:
467the I/O BIO reference count was incorrectly incremented (instead of
468decremented) and dissociated with the
469.Vt SSL
470.Vt BIO
471even if the
472.Vt SSL
473.Vt BIO
474was not
475explicitly being popped (e.g., a pop higher up the chain).
476Applications which included workarounds for this bug (e.g., freeing BIOs more
477than once) should be modified to handle this fix or they may free up an already
478freed
479.Vt BIO .
diff --git a/src/lib/libssl/man/Makefile b/src/lib/libssl/man/Makefile
new file mode 100644
index 0000000000..76afab5718
--- /dev/null
+++ b/src/lib/libssl/man/Makefile
@@ -0,0 +1,93 @@
1# $OpenBSD: Makefile,v 1.36 2016/11/05 15:32:19 schwarze Exp $
2
3.include <bsd.own.mk>
4
5MAN = BIO_f_ssl.3 \
6 SSL_CIPHER_get_name.3 \
7 SSL_COMP_add_compression_method.3 \
8 SSL_CTX_add_extra_chain_cert.3 \
9 SSL_CTX_add_session.3 \
10 SSL_CTX_ctrl.3 \
11 SSL_CTX_flush_sessions.3 \
12 SSL_CTX_free.3 \
13 SSL_CTX_get_ex_new_index.3 \
14 SSL_CTX_get_verify_mode.3 \
15 SSL_CTX_load_verify_locations.3 \
16 SSL_CTX_new.3 \
17 SSL_CTX_sess_number.3 \
18 SSL_CTX_sess_set_cache_size.3 \
19 SSL_CTX_sess_set_get_cb.3 \
20 SSL_CTX_sessions.3 \
21 SSL_CTX_set_cert_store.3 \
22 SSL_CTX_set_cert_verify_callback.3 \
23 SSL_CTX_set_cipher_list.3 \
24 SSL_CTX_set_client_CA_list.3 \
25 SSL_CTX_set_client_cert_cb.3 \
26 SSL_CTX_set_default_passwd_cb.3 \
27 SSL_CTX_set_generate_session_id.3 \
28 SSL_CTX_set_info_callback.3 \
29 SSL_CTX_set_max_cert_list.3 \
30 SSL_CTX_set_mode.3 \
31 SSL_CTX_set_msg_callback.3 \
32 SSL_CTX_set_options.3 \
33 SSL_CTX_set_psk_client_callback.3 \
34 SSL_CTX_set_quiet_shutdown.3 \
35 SSL_CTX_set_session_cache_mode.3 \
36 SSL_CTX_set_session_id_context.3 \
37 SSL_CTX_set_ssl_version.3 \
38 SSL_CTX_set_timeout.3 \
39 SSL_CTX_set_tmp_dh_callback.3 \
40 SSL_CTX_set_tmp_rsa_callback.3 \
41 SSL_CTX_set_verify.3 \
42 SSL_CTX_use_certificate.3 \
43 SSL_CTX_use_psk_identity_hint.3 \
44 SSL_SESSION_free.3 \
45 SSL_SESSION_get_ex_new_index.3 \
46 SSL_SESSION_get_time.3 \
47 SSL_accept.3 \
48 SSL_alert_type_string.3 \
49 SSL_clear.3 \
50 SSL_connect.3 \
51 SSL_do_handshake.3 \
52 SSL_free.3 \
53 SSL_get_SSL_CTX.3 \
54 SSL_get_ciphers.3 \
55 SSL_get_client_CA_list.3 \
56 SSL_get_current_cipher.3 \
57 SSL_get_default_timeout.3 \
58 SSL_get_error.3 \
59 SSL_get_ex_data_X509_STORE_CTX_idx.3 \
60 SSL_get_ex_new_index.3 \
61 SSL_get_fd.3 \
62 SSL_get_peer_cert_chain.3 \
63 SSL_get_peer_certificate.3 \
64 SSL_get_psk_identity.3 \
65 SSL_get_rbio.3 \
66 SSL_get_session.3 \
67 SSL_get_verify_result.3 \
68 SSL_get_version.3 \
69 SSL_library_init.3 \
70 SSL_load_client_CA_file.3 \
71 SSL_new.3 \
72 SSL_pending.3 \
73 SSL_read.3 \
74 SSL_rstate_string.3 \
75 SSL_session_reused.3 \
76 SSL_set_bio.3 \
77 SSL_set_connect_state.3 \
78 SSL_set_fd.3 \
79 SSL_set_session.3 \
80 SSL_set_shutdown.3 \
81 SSL_set_verify_result.3 \
82 SSL_shutdown.3 \
83 SSL_state_string.3 \
84 SSL_want.3 \
85 SSL_write.3 \
86 d2i_SSL_SESSION.3 \
87 ssl.3
88
89all clean cleandir depend includes obj tags:
90
91install: maninstall
92
93.include <bsd.man.mk>
diff --git a/src/lib/libssl/man/SSL_CIPHER_get_name.3 b/src/lib/libssl/man/SSL_CIPHER_get_name.3
new file mode 100644
index 0000000000..c4661c8faf
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CIPHER_get_name.3
@@ -0,0 +1,196 @@
1.\"
2.\" $OpenBSD: SSL_CIPHER_get_name.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CIPHER_GET_NAME 3
6.Os
7.Sh NAME
8.Nm SSL_CIPHER_get_name ,
9.Nm SSL_CIPHER_get_bits ,
10.Nm SSL_CIPHER_get_version ,
11.Nm SSL_CIPHER_description
12.Nd get SSL_CIPHER properties
13.Sh SYNOPSIS
14.In openssl/ssl.h
15.Ft const char *
16.Fn SSL_CIPHER_get_name "const SSL_CIPHER *cipher"
17.Ft int
18.Fn SSL_CIPHER_get_bits "const SSL_CIPHER *cipher" "int *alg_bits"
19.Ft char *
20.Fn SSL_CIPHER_get_version "const SSL_CIPHER *cipher"
21.Ft char *
22.Fn SSL_CIPHER_description "const SSL_CIPHER *cipher" "char *buf" "int size"
23.Sh DESCRIPTION
24.Fn SSL_CIPHER_get_name
25returns a pointer to the name of
26.Fa cipher .
27If the
28argument is the
29.Dv NULL
30pointer, a pointer to the constant value
31.Qq NONE
32is returned.
33.Pp
34.Fn SSL_CIPHER_get_bits
35returns the number of secret bits used for
36.Fa cipher .
37If
38.Fa alg_bits
39is not
40.Dv NULL ,
41it contains the number of bits processed by the
42chosen algorithm.
43If
44.Fa cipher
45is
46.Dv NULL ,
470 is returned.
48.Pp
49.Fn SSL_CIPHER_get_version
50returns a string which indicates the SSL/TLS protocol version that first
51defined the cipher.
52This is currently
53.Qq SSLv2
54or
55.Qq TLSv1/SSLv3 .
56In some cases it should possibly return
57.Qq TLSv1.2
58but the function does not; use
59.Xr SSL_CIPHER_description 3
60instead.
61If
62.Fa cipher
63is
64.Dv NULL ,
65.Qq (NONE)
66is returned.
67.Pp
68.Fn SSL_CIPHER_description
69returns a textual description of the cipher used into the buffer
70.Fa buf
71of length
72.Fa len
73provided.
74If
75.Fa buf
76is
77.Dv NULL ,
78a buffer is allocated using
79.Xr asprintf 3 ;
80that buffer should be freed using the
81.Xr free 3
82function.
83If
84.Fa len
85is too small, or if
86.Fa buf
87is
88.Dv NULL
89and the allocation fails, a pointer to the string
90.Qq Buffer too small
91is returned.
92.Sh NOTES
93The number of bits processed can be different from the secret bits.
94For example, an export cipher like EXP-RC4-MD5 has only 40 secret bits.
95The algorithm does use the full 128 bits (which would be returned for
96.Fa alg_bits ) ,
97but 88 bits are fixed.
98The search space is hence only 40 bits.
99.Pp
100The string returned by
101.Fn SSL_CIPHER_description
102in case of success consists
103of cleartext information separated by one or more blanks in the following
104sequence:
105.Bl -tag -width Ds
106.It Aq Ar ciphername
107Textual representation of the cipher name.
108.It Aq Ar protocol version
109Protocol version:
110.Em SSLv2 ,
111.Em SSLv3 ,
112.Em TLSv1.2 .
113The TLSv1.0 ciphers are flagged with SSLv3.
114No new ciphers were added by TLSv1.1.
115.It Kx= Ns Aq Ar key exchange
116Key exchange method:
117.Em RSA
118(for export ciphers as
119.Em RSA(512)
120or
121.Em RSA(1024) ) ,
122.Em DH
123(for export ciphers as
124.Em DH(512)
125or
126.Em DH(1024) ) ,
127.Em DH/RSA ,
128.Em DH/DSS ,
129.Em Fortezza .
130.It Au= Ns Aq Ar authentication
131Authentication method:
132.Em RSA ,
133.Em DSS ,
134.Em DH ,
135.Em None .
136.Em None
137is the representation of anonymous ciphers.
138.It Enc= Ns Aq Ar symmetric encryption method
139Encryption method with number of secret bits:
140.Em DES(40) ,
141.Em DES(56) ,
142.Em 3DES(168) ,
143.Em RC4(40) ,
144.Em RC4(56) ,
145.Em RC4(64) ,
146.Em RC4(128) ,
147.Em RC2(40) ,
148.Em RC2(56) ,
149.Em RC2(128) ,
150.Em IDEA(128) ,
151.Em Fortezza ,
152.Em None .
153.It Mac= Ns Aq Ar message authentication code
154Message digest:
155.Em MD5 ,
156.Em SHA1 .
157.It Aq Ar export flag
158If the cipher is flagged exportable with respect to old US crypto
159regulations, the word
160.Dq export
161is printed.
162.El
163.Sh RETURN VALUES
164See
165.Sx DESCRIPTION
166.Sh EXAMPLES
167Some examples for the output of
168.Fn SSL_CIPHER_description :
169.D1 "EDH-RSA-DES-CBC3-SHA SSLv3 Kx=DH Au=RSA Enc=3DES(168) Mac=SHA1"
170.D1 "EDH-DSS-DES-CBC3-SHA SSLv3 Kx=DH Au=DSS Enc=3DES(168) Mac=SHA1"
171.D1 "RC4-MD5 SSLv3 Kx=RSA Au=RSA Enc=RC4(128) Mac=MD5"
172.D1 "EXP-RC4-MD5 SSLv3 Kx=RSA(512) Au=RSA Enc=RC4(40) Mac=MD5 export"
173.Pp
174A complete list can be retrieved by invoking the following command:
175.Pp
176.Dl $ openssl ciphers -v ALL
177.Sh SEE ALSO
178.Xr openssl 1 ,
179.Xr ssl 3 ,
180.Xr SSL_get_ciphers 3 ,
181.Xr SSL_get_current_cipher 3
182.Sh BUGS
183If
184.Fn SSL_CIPHER_description
185is called with
186.Fa cipher
187being
188.Dv NULL ,
189the library crashes.
190.Pp
191If
192.Fn SSL_CIPHER_description
193cannot handle a built-in cipher,
194the according description of the cipher property is
195.Qq unknown .
196This case should not occur.
diff --git a/src/lib/libssl/man/SSL_COMP_add_compression_method.3 b/src/lib/libssl/man/SSL_COMP_add_compression_method.3
new file mode 100644
index 0000000000..957b2e8bed
--- /dev/null
+++ b/src/lib/libssl/man/SSL_COMP_add_compression_method.3
@@ -0,0 +1,68 @@
1.\"
2.\" $OpenBSD: SSL_COMP_add_compression_method.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_COMP_ADD_COMPRESSION_METHOD 3
6.Os
7.Sh NAME
8.Nm SSL_COMP_add_compression_method
9.Nd handle SSL/TLS integrated compression methods
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft int
13.Fn SSL_COMP_add_compression_method "int id" "COMP_METHOD *cm"
14.Sh DESCRIPTION
15.Fn SSL_COMP_add_compression_method
16adds the compression method
17.Fa cm
18with the identifier
19.Fa id
20to the list of available compression methods.
21This list is globally maintained for all SSL operations within this application.
22It cannot be set for specific SSL_CTX or SSL objects.
23.Sh NOTES
24The TLS standard (or SSLv3) allows the integration of compression methods
25into the communication.
26The TLS RFC does however not specify compression methods or their corresponding
27identifiers, so there is currently no compatible way to integrate compression
28with unknown peers.
29It is therefore currently not recommended to integrate compression into
30applications.
31Applications for non-public use may agree on certain compression methods.
32Using different compression methods with the same identifier will lead to
33connection failure.
34.Pp
35An OpenSSL client speaking a protocol that allows compression (SSLv3, TLSv1)
36will unconditionally send the list of all compression methods enabled with
37.Fn SSL_COMP_add_compression_method
38to the server during the handshake.
39Unlike the mechanisms to set a cipher list, there is no method available to
40restrict the list of compression method on a per connection basis.
41.Pp
42An OpenSSL server will match the identifiers listed by a client against
43its own compression methods and will unconditionally activate compression
44when a matching identifier is found.
45There is no way to restrict the list of compression methods supported on a per
46connection basis.
47.Pp
48The OpenSSL library has the compression methods
49.Fn COMP_rle
50and (when especially enabled during compilation)
51.Fn COMP_zlib
52available.
53.Sh WARNINGS
54Once the identities of the compression methods for the TLS protocol have
55been standardized, the compression API will most likely be changed.
56Using it in the current state is not recommended.
57.Sh RETURN VALUES
58.Fn SSL_COMP_add_compression_method
59may return the following values:
60.Bl -tag -width Ds
61.It 0
62The operation succeeded.
63.It 1
64The operation failed.
65Check the error queue to find out the reason.
66.El
67.Sh SEE ALSO
68.Xr ssl 3
diff --git a/src/lib/libssl/man/SSL_CTX_add_extra_chain_cert.3 b/src/lib/libssl/man/SSL_CTX_add_extra_chain_cert.3
new file mode 100644
index 0000000000..b7ece44811
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_add_extra_chain_cert.3
@@ -0,0 +1,45 @@
1.\"
2.\" $OpenBSD: SSL_CTX_add_extra_chain_cert.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_ADD_EXTRA_CHAIN_CERT 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_add_extra_chain_cert
9.Nd add certificate to chain
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft long
13.Fn SSL_CTX_add_extra_chain_cert "SSL_CTX ctx" "X509 *x509"
14.Sh DESCRIPTION
15.Fn SSL_CTX_add_extra_chain_cert
16adds the certificate
17.Fa x509
18to the certificate chain presented together with the certificate.
19Several certificates can be added one after the other.
20.Sh NOTES
21When constructing the certificate chain, the chain will be formed from
22these certificates explicitly specified.
23If no chain is specified, the library will try to complete the chain from the
24available CA certificates in the trusted CA storage, see
25.Xr SSL_CTX_load_verify_locations 3 .
26.Pp
27The x509 certificate provided to
28.Fn SSL_CTX_add_extra_chain_cert
29will be freed by the library when the
30.Vt SSL_CTX
31is destroyed.
32An application
33.Em should not
34free the
35.Fa x509
36object.
37.Sh RETURN VALUES
38.Fn SSL_CTX_add_extra_chain_cert
39returns 1 on success.
40Check out the error stack to find out the reason for failure otherwise.
41.Sh SEE ALSO
42.Xr ssl 3 ,
43.Xr SSL_CTX_load_verify_locations 3 ,
44.Xr SSL_CTX_set_client_cert_cb 3 ,
45.Xr SSL_CTX_use_certificate 3
diff --git a/src/lib/libssl/man/SSL_CTX_add_session.3 b/src/lib/libssl/man/SSL_CTX_add_session.3
new file mode 100644
index 0000000000..fe60c6ea92
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_add_session.3
@@ -0,0 +1,90 @@
1.\"
2.\" $OpenBSD: SSL_CTX_add_session.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_ADD_SESSION 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_add_session ,
9.Nm SSL_add_session ,
10.Nm SSL_CTX_remove_session ,
11.Nm SSL_remove_session
12.Nd manipulate session cache
13.Sh SYNOPSIS
14.In openssl/ssl.h
15.Ft int
16.Fn SSL_CTX_add_session "SSL_CTX *ctx" "SSL_SESSION *c"
17.Ft int
18.Fn SSL_add_session "SSL_CTX *ctx" "SSL_SESSION *c"
19.Ft int
20.Fn SSL_CTX_remove_session "SSL_CTX *ctx" "SSL_SESSION *c"
21.Ft int
22.Fn SSL_remove_session "SSL_CTX *ctx" "SSL_SESSION *c"
23.Sh DESCRIPTION
24.Fn SSL_CTX_add_session
25adds the session
26.Fa c
27to the context
28.Fa ctx .
29The reference count for session
30.Fa c
31is incremented by 1.
32If a session with the same session id already exists,
33the old session is removed by calling
34.Xr SSL_SESSION_free 3 .
35.Pp
36.Fn SSL_CTX_remove_session
37removes the session
38.Fa c
39from the context
40.Fa ctx .
41.Xr SSL_SESSION_free 3
42is called once for
43.Fa c .
44.Pp
45.Fn SSL_add_session
46and
47.Fn SSL_remove_session
48are synonyms for their
49.Fn SSL_CTX_*
50counterparts.
51.Sh NOTES
52When adding a new session to the internal session cache, it is examined
53whether a session with the same session id already exists.
54In this case it is assumed that both sessions are identical.
55If the same session is stored in a different
56.Vt SSL_SESSION
57object, the old session is removed and replaced by the new session.
58If the session is actually identical (the
59.Vt SSL_SESSION
60object is identical),
61.Fn SSL_CTX_add_session
62is a no-op, and the return value is 0.
63.Pp
64If a server
65.Vt SSL_CTX
66is configured with the
67.Dv SSL_SESS_CACHE_NO_INTERNAL_STORE
68flag then the internal cache will not be populated automatically by new
69sessions negotiated by the SSL/TLS implementation, even though the internal
70cache will be searched automatically for session-resume requests (the
71latter can be suppressed by
72.Dv SSL_SESS_CACHE_NO_INTERNAL_LOOKUP ) .
73So the application can use
74.Fn SSL_CTX_add_session
75directly to have full control over the sessions that can be resumed if desired.
76.Sh RETURN VALUES
77The following values are returned by all functions:
78.Bl -tag -width Ds
79.It 0
80The operation failed.
81In case of the add operation, it was tried to add the same (identical) session
82twice.
83In case of the remove operation, the session was not found in the cache.
84.It 1
85The operation succeeded.
86.El
87.Sh SEE ALSO
88.Xr ssl 3 ,
89.Xr SSL_CTX_set_session_cache_mode 3 ,
90.Xr SSL_SESSION_free 3
diff --git a/src/lib/libssl/man/SSL_CTX_ctrl.3 b/src/lib/libssl/man/SSL_CTX_ctrl.3
new file mode 100644
index 0000000000..47cf609491
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_ctrl.3
@@ -0,0 +1,49 @@
1.\"
2.\" $OpenBSD: SSL_CTX_ctrl.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_CTRL 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_ctrl ,
9.Nm SSL_CTX_callback_ctrl ,
10.Nm SSL_ctrl ,
11.Nm SSL_callback_ctrl
12.Nd internal handling functions for SSL_CTX and SSL objects
13.Sh SYNOPSIS
14.In openssl/ssl.h
15.Ft long
16.Fn SSL_CTX_ctrl "SSL_CTX *ctx" "int cmd" "long larg" "void *parg"
17.Ft long
18.Fn SSL_CTX_callback_ctrl "SSL_CTX *" "int cmd" "void (*fp)()"
19.Ft long
20.Fn SSL_ctrl "SSL *ssl" "int cmd" "long larg" "void *parg"
21.Ft long
22.Fn SSL_callback_ctrl "SSL *" "int cmd" "void (*fp)()"
23.Sh DESCRIPTION
24The
25.Fn SSL_*_ctrl
26family of functions is used to manipulate settings of
27the
28.Vt SSL_CTX
29and
30.Vt SSL
31objects.
32Depending on the command
33.Fa cmd
34the arguments
35.Fa larg ,
36.Fa parg ,
37or
38.Fa fp
39are evaluated.
40These functions should never be called directly.
41All functionalities needed are made available via other functions or macros.
42.Sh RETURN VALUES
43The return values of the
44.Fn SSL*_ctrl
45functions depend on the command supplied via the
46.Fn cmd
47parameter.
48.Sh SEE ALSO
49.Xr ssl 3
diff --git a/src/lib/libssl/man/SSL_CTX_flush_sessions.3 b/src/lib/libssl/man/SSL_CTX_flush_sessions.3
new file mode 100644
index 0000000000..11d33e81a1
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_flush_sessions.3
@@ -0,0 +1,57 @@
1.\"
2.\" $OpenBSD: SSL_CTX_flush_sessions.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_FLUSH_SESSIONS 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_flush_sessions ,
9.Nm SSL_flush_sessions
10.Nd remove expired sessions
11.Sh SYNOPSIS
12.In openssl/ssl.h
13.Ft void
14.Fn SSL_CTX_flush_sessions "SSL_CTX *ctx" "long tm"
15.Ft void
16.Fn SSL_flush_sessions "SSL_CTX *ctx" "long tm"
17.Sh DESCRIPTION
18.Fn SSL_CTX_flush_sessions
19causes a run through the session cache of
20.Fa ctx
21to remove sessions expired at time
22.Fa tm .
23.Pp
24.Fn SSL_flush_sessions
25is a synonym for
26.Fn SSL_CTX_flush_sessions .
27.Sh NOTES
28If enabled, the internal session cache will collect all sessions established
29up to the specified maximum number (see
30.Fn SSL_CTX_sess_set_cache_size ) .
31As sessions will not be reused ones they are expired, they should be
32removed from the cache to save resources.
33This can either be done automatically whenever 255 new sessions were
34established (see
35.Xr SSL_CTX_set_session_cache_mode 3 )
36or manually by calling
37.Fn SSL_CTX_flush_sessions .
38.Pp
39The parameter
40.Fa tm
41specifies the time which should be used for the
42expiration test, in most cases the actual time given by
43.Fn time 0
44will be used.
45.Pp
46.Fn SSL_CTX_flush_sessions
47will only check sessions stored in the internal cache.
48When a session is found and removed, the
49.Va remove_session_cb
50is however called to synchronize with the external cache (see
51.Xr SSL_CTX_sess_set_get_cb 3 ) .
52.Sh RETURN VALUES
53.Sh SEE ALSO
54.Xr ssl 3 ,
55.Xr SSL_CTX_sess_set_get_cb 3 ,
56.Xr SSL_CTX_set_session_cache_mode 3 ,
57.Xr SSL_CTX_set_timeout 3
diff --git a/src/lib/libssl/man/SSL_CTX_free.3 b/src/lib/libssl/man/SSL_CTX_free.3
new file mode 100644
index 0000000000..24a19ffaf6
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_free.3
@@ -0,0 +1,53 @@
1.\"
2.\" $OpenBSD: SSL_CTX_free.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_FREE 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_free
9.Nd free an allocated SSL_CTX object
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft void
13.Fn SSL_CTX_free "SSL_CTX *ctx"
14.Sh DESCRIPTION
15.Fn SSL_CTX_free
16decrements the reference count of
17.Fa ctx ,
18and removes the
19.Vt SSL_CTX
20object pointed to by
21.Fa ctx
22and frees up the allocated memory if the reference count has reached 0.
23If
24.Fa ctx
25is a
26.Dv NULL
27pointer, no action occurs.
28.Pp
29It also calls the
30.Xr free 3 Ns ing
31procedures for indirectly affected items, if applicable:
32the session cache, the list of ciphers, the list of Client CAs,
33the certificates and keys.
34.Sh WARNINGS
35If a session-remove callback is set
36.Pq Xr SSL_CTX_sess_set_remove_cb 3 ,
37this callback will be called for each session being freed from
38.Fa ctx Ns 's
39session cache.
40This implies that all corresponding sessions from an external session cache are
41removed as well.
42If this is not desired, the user should explicitly unset the callback by
43calling
44.Fn SSL_CTX_sess_set_remove_cb ctx NULL
45prior to calling
46.Fn SSL_CTX_free .
47.Sh RETURN VALUES
48.Fn SSL_CTX_free
49does not provide diagnostic information.
50.Sh SEE ALSO
51.Xr ssl 3 ,
52.Xr SSL_CTX_new 3 ,
53.Xr SSL_CTX_sess_set_get_cb 3
diff --git a/src/lib/libssl/man/SSL_CTX_get_ex_new_index.3 b/src/lib/libssl/man/SSL_CTX_get_ex_new_index.3
new file mode 100644
index 0000000000..8afb1ebc96
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_get_ex_new_index.3
@@ -0,0 +1,70 @@
1.\"
2.\" $OpenBSD: SSL_CTX_get_ex_new_index.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_GET_EX_NEW_INDEX 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_get_ex_new_index ,
9.Nm SSL_CTX_set_ex_data ,
10.Nm SSL_CTX_get_ex_data
11.Nd internal application specific data functions
12.Sh SYNOPSIS
13.In openssl/ssl.h
14.Ft int
15.Fo SSL_CTX_get_ex_new_index
16.Fa "long argl"
17.Fa "void *argp"
18.Fa "CRYPTO_EX_new *new_func"
19.Fa "CRYPTO_EX_dup *dup_func"
20.Fa "CRYPTO_EX_free *free_func"
21.Fc
22.Ft int
23.Fn SSL_CTX_set_ex_data "SSL_CTX *ctx" "int idx" "void *arg"
24.Ft void *
25.Fn SSL_CTX_get_ex_data "const SSL_CTX *ctx" "int idx"
26.Bd -literal
27 typedef int new_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
28 int idx, long argl, void *argp);
29 typedef void free_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
30 int idx, long argl, void *argp);
31 typedef int dup_func(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
32 int idx, long argl, void *argp);
33.Ed
34.Sh DESCRIPTION
35Several OpenSSL structures can have application specific data attached to them.
36These functions are used internally by OpenSSL to manipulate application
37specific data attached to a specific structure.
38.Pp
39.Fn SSL_CTX_get_ex_new_index
40is used to register a new index for application specific data.
41.Pp
42.Fn SSL_CTX_set_ex_data
43is used to store application data at
44.Fa arg
45for
46.Fa idx
47into the
48.Fa ctx
49object.
50.Pp
51.Fn SSL_CTX_get_ex_data
52is used to retrieve the information for
53.Fa idx
54from
55.Fa ctx .
56.Pp
57A detailed description for the
58.Fn *_get_ex_new_index
59functionality can be found in
60.Xr RSA_get_ex_new_index 3 .
61The
62.Fn *_get_ex_data
63and
64.Fn *_set_ex_data
65functionality is described in
66.Xr CRYPTO_set_ex_data 3 .
67.Sh SEE ALSO
68.Xr CRYPTO_set_ex_data 3 ,
69.Xr RSA_get_ex_new_index 3 ,
70.Xr ssl 3
diff --git a/src/lib/libssl/man/SSL_CTX_get_verify_mode.3 b/src/lib/libssl/man/SSL_CTX_get_verify_mode.3
new file mode 100644
index 0000000000..c8ada8fb21
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_get_verify_mode.3
@@ -0,0 +1,73 @@
1.\"
2.\" $OpenBSD: SSL_CTX_get_verify_mode.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_GET_VERIFY_MODE 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_get_verify_mode ,
9.Nm SSL_get_verify_mode ,
10.Nm SSL_CTX_get_verify_depth ,
11.Nm SSL_get_verify_depth ,
12.Nm SSL_get_verify_callback ,
13.Nm SSL_CTX_get_verify_callback
14.Nd get currently set verification parameters
15.Sh SYNOPSIS
16.In openssl/ssl.h
17.Ft int
18.Fn SSL_CTX_get_verify_mode "const SSL_CTX *ctx"
19.Ft int
20.Fn SSL_get_verify_mode "const SSL *ssl"
21.Ft int
22.Fn SSL_CTX_get_verify_depth "const SSL_CTX *ctx"
23.Ft int
24.Fn SSL_get_verify_depth "const SSL *ssl"
25.Ft int
26.Fo "(*SSL_CTX_get_verify_callback(const SSL_CTX *ctx))"
27.Fa int "X509_STORE_CTX *"
28.Fc
29.Ft int
30.Fo "(*SSL_get_verify_callback(const SSL *ssl))"
31.Fa int "X509_STORE_CTX *"
32.Fc
33.Sh DESCRIPTION
34.Fn SSL_CTX_get_verify_mode
35returns the verification mode currently set in
36.Fa ctx .
37.Pp
38.Fn SSL_get_verify_mode
39returns the verification mode currently set in
40.Fa ssl .
41.Pp
42.Fn SSL_CTX_get_verify_depth
43returns the verification depth limit currently set
44in
45.Fa ctx .
46If no limit has been explicitly set,
47\(mi1 is returned and the default value will be used.
48.Pp
49.Fn SSL_get_verify_depth
50returns the verification depth limit currently set in
51.Fa ssl .
52If no limit has been explicitly set,
53\(mi1 is returned and the default value will be used.
54.Pp
55.Fn SSL_CTX_get_verify_callback
56returns a function pointer to the verification callback currently set in
57.Fa ctx .
58If no callback was explicitly set, the
59.Dv NULL
60pointer is returned and the default callback will be used.
61.Pp
62.Fn SSL_get_verify_callback
63returns a function pointer to the verification callback currently set in
64.Fa ssl .
65If no callback was explicitly set, the
66.Dv NULL
67pointer is returned and the default callback will be used.
68.Sh RETURN VALUES
69See
70.Sx DESCRIPTION
71.Sh SEE ALSO
72.Xr ssl 3 ,
73.Xr SSL_CTX_set_verify 3
diff --git a/src/lib/libssl/man/SSL_CTX_load_verify_locations.3 b/src/lib/libssl/man/SSL_CTX_load_verify_locations.3
new file mode 100644
index 0000000000..0d023cb475
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_load_verify_locations.3
@@ -0,0 +1,161 @@
1.\"
2.\" $OpenBSD: SSL_CTX_load_verify_locations.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_LOAD_VERIFY_LOCATIONS 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_load_verify_locations
9.Nd set default locations for trusted CA certificates
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft int
13.Fo SSL_CTX_load_verify_locations
14.Fa "SSL_CTX *ctx" "const char *CAfile" "const char *CApath"
15.Fc
16.Sh DESCRIPTION
17.Fn SSL_CTX_load_verify_locations
18specifies the locations for
19.Fa ctx ,
20at which CA certificates for verification purposes are located.
21The certificates available via
22.Fa CAfile
23and
24.Fa CApath
25are trusted.
26.Sh NOTES
27If
28.Fa CAfile
29is not
30.Dv NULL ,
31it points to a file of CA certificates in PEM format.
32The file can contain several CA certificates identified by sequences of:
33.Bd -literal
34 -----BEGIN CERTIFICATE-----
35 ... (CA certificate in base64 encoding) ...
36 -----END CERTIFICATE-----
37.Ed
38Before, between, and after the certificates arbitrary text is allowed which can
39be used, e.g., for descriptions of the certificates.
40.Pp
41The
42.Fa CAfile
43is processed on execution of the
44.Fn SSL_CTX_load_verify_locations
45function.
46.Pp
47If
48.Fa CApath
49is not NULL, it points to a directory containing CA certificates in PEM format.
50The files each contain one CA certificate.
51The files are looked up by the CA subject name hash value,
52which must hence be available.
53If more than one CA certificate with the same name hash value exist,
54the extension must be different (e.g.,
55.Pa 9d66eef0.0 ,
56.Pa 9d66eef0.1 ,
57etc.).
58The search is performed in the ordering of the extension number,
59regardless of other properties of the certificates.
60.Pp
61The certificates in
62.Fa CApath
63are only looked up when required, e.g., when building the certificate chain or
64when actually performing the verification of a peer certificate.
65.Pp
66When looking up CA certificates, the OpenSSL library will first search the
67certificates in
68.Fa CAfile ,
69then those in
70.Fa CApath .
71Certificate matching is done based on the subject name, the key identifier (if
72present), and the serial number as taken from the certificate to be verified.
73If these data do not match, the next certificate will be tried.
74If a first certificate matching the parameters is found,
75the verification process will be performed;
76no other certificates for the same parameters will be searched in case of
77failure.
78.Pp
79In server mode, when requesting a client certificate, the server must send
80the list of CAs of which it will accept client certificates.
81This list is not influenced by the contents of
82.Fa CAfile
83or
84.Fa CApath
85and must explicitly be set using the
86.Xr SSL_CTX_set_client_CA_list 3
87family of functions.
88.Pp
89When building its own certificate chain, an OpenSSL client/server will try to
90fill in missing certificates from
91.Fa CAfile Ns / Fa CApath ,
92if the
93certificate chain was not explicitly specified (see
94.Xr SSL_CTX_add_extra_chain_cert 3
95and
96.Xr SSL_CTX_use_certificate 3 ) .
97.Sh WARNINGS
98If several CA certificates matching the name, key identifier, and serial
99number condition are available, only the first one will be examined.
100This may lead to unexpected results if the same CA certificate is available
101with different expiration dates.
102If a
103.Dq certificate expired
104verification error occurs, no other certificate will be searched.
105Make sure to not have expired certificates mixed with valid ones.
106.Sh RETURN VALUES
107The following return values can occur:
108.Bl -tag -width Ds
109.It 0
110The operation failed because
111.Fa CAfile
112and
113.Fa CApath
114are
115.Dv NULL
116or the processing at one of the locations specified failed.
117Check the error stack to find out the reason.
118.It 1
119The operation succeeded.
120.El
121.Sh EXAMPLES
122Generate a CA certificate file with descriptive text from the CA certificates
123.Pa ca1.pem
124.Pa ca2.pem
125.Pa ca3.pem :
126.Bd -literal
127#!/bin/sh
128rm CAfile.pem
129for i in ca1.pem ca2.pem ca3.pem; do
130 openssl x509 -in $i -text >> CAfile.pem
131done
132.Ed
133.Pp
134Prepare the directory /some/where/certs containing several CA certificates
135for use as
136.Fa CApath :
137.Bd -literal
138$ cd /some/where/certs
139$ rm -f *.[0-9]* *.r[0-9]*
140$ for c in *.pem; do
141> [ "$c" = "*.pem" ] && continue
142> hash=$(openssl x509 -noout -hash -in "$c")
143> if egrep -q -- '-BEGIN( X509 | TRUSTED | )CERTIFICATE-' "$c"; then
144> suf=0
145> while [ -e $hash.$suf ]; do suf=$(( $suf + 1 )); done
146> ln -s "$c" $hash.$suf
147> fi
148> if egrep -q -- '-BEGIN X509 CRL-' "$c"; then
149> suf=0
150> while [ -e $hash.r$suf ]; do suf=$(( $suf + 1 )); done
151> ln -s "$c" $hash.r$suf
152> fi
153> done
154.Ed
155.Sh SEE ALSO
156.Xr ssl 3 ,
157.Xr SSL_CTX_add_extra_chain_cert 3 ,
158.Xr SSL_CTX_set_cert_store 3 ,
159.Xr SSL_CTX_set_client_CA_list 3 ,
160.Xr SSL_CTX_use_certificate 3 ,
161.Xr SSL_get_client_CA_list 3
diff --git a/src/lib/libssl/man/SSL_CTX_new.3 b/src/lib/libssl/man/SSL_CTX_new.3
new file mode 100644
index 0000000000..872d302b24
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_new.3
@@ -0,0 +1,111 @@
1.\"
2.\" $OpenBSD: SSL_CTX_new.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_NEW 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_new ,
9.Nm SSLv3_method ,
10.Nm SSLv3_server_method ,
11.Nm SSLv3_client_method ,
12.Nm TLSv1_method ,
13.Nm TLSv1_server_method ,
14.Nm TLSv1_client_method ,
15.Nm TLSv1_1_method ,
16.Nm TLSv1_1_server_method ,
17.Nm TLSv1_1_client_method ,
18.Nm SSLv23_method ,
19.Nm SSLv23_server_method ,
20.Nm SSLv23_client_method
21.Nd create a new SSL_CTX object as framework for TLS/SSL enabled functions
22.Sh SYNOPSIS
23.In openssl/ssl.h
24.Ft SSL_CTX *
25.Fn SSL_CTX_new "const SSL_METHOD *method"
26.Sh DESCRIPTION
27.Fn SSL_CTX_new
28creates a new
29.Vt SSL_CTX
30object as framework to establish TLS/SSL enabled connections.
31.Sh NOTES
32The
33.Vt SSL_CTX
34object uses
35.Fa method
36as its connection method.
37The methods exist in a generic type (for client and server use),
38a server only type, and a client only type.
39.Fa method
40can be of the following types:
41.Bl -tag -width Ds
42.It Fn SSLv3_method void , Fn SSLv3_server_method void , \
43Fn SSLv3_client_method void
44A TLS/SSL connection established with these methods will only understand the
45SSLv3 protocol.
46A client will send out SSLv3 client hello messages and will indicate that it
47only understands SSLv3.
48A server will only understand SSLv3 client hello messages.
49Importantly, this means that it will not understand SSLv2 client hello messages
50which are widely used for compatibility reasons; see
51.Fn SSLv23_*_method .
52.It Fn TLSv1_method void , Fn TLSv1_server_method void , \
53Fn TLSv1_client_method void
54A TLS/SSL connection established with these methods will only understand the
55TLSv1 protocol.
56A client will send out TLSv1 client hello messages and will indicate that it
57only understands TLSv1.
58A server will only understand TLSv1 client hello messages.
59Importantly, this means that it will not understand SSLv2 client hello messages
60which are widely used for compatibility reasons; see
61.Fn SSLv23_*_method .
62It will also not understand SSLv3 client hello messages.
63.It Fn SSLv23_method void , Fn SSLv23_server_method void , \
64Fn SSLv23_client_method void
65A TLS/SSL connection established with these methods may understand the SSLv3,
66TLSv1, TLSv1.1 and TLSv1.2 protocols.
67.Pp
68A client will send out TLSv1 client hello messages including extensions and
69will indicate that it also understands TLSv1.1, TLSv1.2 and permits a fallback
70to SSLv3.
71A server will support SSLv3, TLSv1, TLSv1.1 and TLSv1.2 protocols.
72This is the best choice when compatibility is a concern.
73.El
74.Pp
75The list of protocols available can later be limited using the
76.Dv SSL_OP_NO_SSLv3 ,
77.Dv SSL_OP_NO_TLSv1 ,
78.Dv SSL_OP_NO_TLSv1_1 ,
79and
80.Dv SSL_OP_NO_TLSv1_2
81options of the
82.Fn SSL_CTX_set_options
83or
84.Fn SSL_set_options
85functions.
86Using these options it is possible to choose, for example,
87.Fn SSLv23_server_method
88and be able to negotiate with all possible clients,
89but to only allow newer protocols like TLSv1, TLSv1.1 or TLS v1.2.
90.Pp
91.Fn SSL_CTX_new
92initializes the list of ciphers, the session cache setting, the callbacks,
93the keys and certificates, and the options to its default values.
94.Sh RETURN VALUES
95The following return values can occur:
96.Bl -tag -width Ds
97.It Dv NULL
98The creation of a new
99.Vt SSL_CTX
100object failed.
101Check the error stack to find out the reason.
102.It Pointer to an SSL_CTX object
103The return value points to an allocated
104.Vt SSL_CTX
105object.
106.El
107.Sh SEE ALSO
108.Xr ssl 3 ,
109.Xr SSL_accept 3 ,
110.Xr SSL_CTX_free 3 ,
111.Xr SSL_set_connect_state 3
diff --git a/src/lib/libssl/man/SSL_CTX_sess_number.3 b/src/lib/libssl/man/SSL_CTX_sess_number.3
new file mode 100644
index 0000000000..3171fe21ea
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_sess_number.3
@@ -0,0 +1,104 @@
1.\"
2.\" $OpenBSD: SSL_CTX_sess_number.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_SESS_NUMBER 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_sess_number ,
9.Nm SSL_CTX_sess_connect ,
10.Nm SSL_CTX_sess_connect_good ,
11.Nm SSL_CTX_sess_connect_renegotiate ,
12.Nm SSL_CTX_sess_accept ,
13.Nm SSL_CTX_sess_accept_good ,
14.Nm SSL_CTX_sess_accept_renegotiate ,
15.Nm SSL_CTX_sess_hits ,
16.Nm SSL_CTX_sess_cb_hits ,
17.Nm SSL_CTX_sess_misses ,
18.Nm SSL_CTX_sess_timeouts ,
19.Nm SSL_CTX_sess_cache_full
20.Nd obtain session cache statistics
21.Sh SYNOPSIS
22.In openssl/ssl.h
23.Ft long
24.Fn SSL_CTX_sess_number "SSL_CTX *ctx"
25.Ft long
26.Fn SSL_CTX_sess_connect "SSL_CTX *ctx"
27.Ft long
28.Fn SSL_CTX_sess_connect_good "SSL_CTX *ctx"
29.Ft long
30.Fn SSL_CTX_sess_connect_renegotiate "SSL_CTX *ctx"
31.Ft long
32.Fn SSL_CTX_sess_accept "SSL_CTX *ctx"
33.Ft long
34.Fn SSL_CTX_sess_accept_good "SSL_CTX *ctx"
35.Ft long
36.Fn SSL_CTX_sess_accept_renegotiate "SSL_CTX *ctx"
37.Ft long
38.Fn SSL_CTX_sess_hits "SSL_CTX *ctx"
39.Ft long
40.Fn SSL_CTX_sess_cb_hits "SSL_CTX *ctx"
41.Ft long
42.Fn SSL_CTX_sess_misses "SSL_CTX *ctx"
43.Ft long
44.Fn SSL_CTX_sess_timeouts "SSL_CTX *ctx"
45.Ft long
46.Fn SSL_CTX_sess_cache_full "SSL_CTX *ctx"
47.Sh DESCRIPTION
48.Fn SSL_CTX_sess_number
49returns the current number of sessions in the internal session cache.
50.Pp
51.Fn SSL_CTX_sess_connect
52returns the number of started SSL/TLS handshakes in client mode.
53.Pp
54.Fn SSL_CTX_sess_connect_good
55returns the number of successfully established SSL/TLS sessions in client mode.
56.Pp
57.Fn SSL_CTX_sess_connect_renegotiate
58returns the number of start renegotiations in client mode.
59.Pp
60.Fn SSL_CTX_sess_accept
61returns the number of started SSL/TLS handshakes in server mode.
62.Pp
63.Fn SSL_CTX_sess_accept_good
64returns the number of successfully established SSL/TLS sessions in server mode.
65.Pp
66.Fn SSL_CTX_sess_accept_renegotiate
67returns the number of start renegotiations in server mode.
68.Pp
69.Fn SSL_CTX_sess_hits
70returns the number of successfully reused sessions.
71In client mode a session set with
72.Xr SSL_set_session 3
73successfully reused is counted as a hit.
74In server mode a session successfully retrieved from internal or external cache
75is counted as a hit.
76.Pp
77.Fn SSL_CTX_sess_cb_hits
78returns the number of successfully retrieved sessions from the external session
79cache in server mode.
80.Pp
81.Fn SSL_CTX_sess_misses
82returns the number of sessions proposed by clients that were not found in the
83internal session cache in server mode.
84.Pp
85.Fn SSL_CTX_sess_timeouts
86returns the number of sessions proposed by clients and either found in the
87internal or external session cache in server mode,
88but that were invalid due to timeout.
89These sessions are not included in the
90.Fn SSL_CTX_sess_hits
91count.
92.Pp
93.Fn SSL_CTX_sess_cache_full
94returns the number of sessions that were removed because the maximum session
95cache size was exceeded.
96.Sh RETURN VALUES
97The functions return the values indicated in the
98.Sx DESCRIPTION
99section.
100.Sh SEE ALSO
101.Xr ssl 3 ,
102.Xr SSL_CTX_sess_set_cache_size 3 ,
103.Xr SSL_CTX_set_session_cache_mode 3 ,
104.Xr SSL_set_session 3
diff --git a/src/lib/libssl/man/SSL_CTX_sess_set_cache_size.3 b/src/lib/libssl/man/SSL_CTX_sess_set_cache_size.3
new file mode 100644
index 0000000000..1cc6516d20
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_sess_set_cache_size.3
@@ -0,0 +1,55 @@
1.\"
2.\" $OpenBSD: SSL_CTX_sess_set_cache_size.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_SESS_SET_CACHE_SIZE 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_sess_set_cache_size ,
9.Nm SSL_CTX_sess_get_cache_size
10.Nd manipulate session cache size
11.Sh SYNOPSIS
12.In openssl/ssl.h
13.Ft long
14.Fn SSL_CTX_sess_set_cache_size "SSL_CTX *ctx" "long t"
15.Ft long
16.Fn SSL_CTX_sess_get_cache_size "SSL_CTX *ctx"
17.Sh DESCRIPTION
18.Fn SSL_CTX_sess_set_cache_size
19sets the size of the internal session cache of context
20.Fa ctx
21to
22.Fa t .
23.Pp
24.Fn SSL_CTX_sess_get_cache_size
25returns the currently valid session cache size.
26.Sh NOTES
27The internal session cache size is
28.Dv SSL_SESSION_CACHE_MAX_SIZE_DEFAULT ,
29currently 1024\(mu20, so that up to 20000 sessions can be held.
30This size can be modified using the
31.Fn SSL_CTX_sess_set_cache_size
32call.
33A special case is the size 0, which is used for unlimited size.
34.Pp
35When the maximum number of sessions is reached,
36no more new sessions are added to the cache.
37New space may be added by calling
38.Xr SSL_CTX_flush_sessions 3
39to remove expired sessions.
40.Pp
41If the size of the session cache is reduced and more sessions are already in
42the session cache,
43old session will be removed the next time a session shall be added.
44This removal is not synchronized with the expiration of sessions.
45.Sh RETURN VALUES
46.Fn SSL_CTX_sess_set_cache_size
47returns the previously valid size.
48.Pp
49.Fn SSL_CTX_sess_get_cache_size
50returns the currently valid size.
51.Sh SEE ALSO
52.Xr ssl 3 ,
53.Xr SSL_CTX_flush_sessions 3 ,
54.Xr SSL_CTX_sess_number 3 ,
55.Xr SSL_CTX_set_session_cache_mode 3
diff --git a/src/lib/libssl/man/SSL_CTX_sess_set_get_cb.3 b/src/lib/libssl/man/SSL_CTX_sess_set_get_cb.3
new file mode 100644
index 0000000000..44ed2cb82a
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_sess_set_get_cb.3
@@ -0,0 +1,159 @@
1.\"
2.\" $OpenBSD: SSL_CTX_sess_set_get_cb.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_SESS_SET_GET_CB 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_sess_set_new_cb ,
9.Nm SSL_CTX_sess_set_remove_cb ,
10.Nm SSL_CTX_sess_set_get_cb ,
11.Nm SSL_CTX_sess_get_new_cb ,
12.Nm SSL_CTX_sess_get_remove_cb ,
13.Nm SSL_CTX_sess_get_get_cb
14.Nd provide callback functions for server side external session caching
15.Sh SYNOPSIS
16.In openssl/ssl.h
17.Ft void
18.Fo SSL_CTX_sess_set_new_cb
19.Fa "SSL_CTX *ctx"
20.Fa "int (*new_session_cb)(SSL *, SSL_SESSION *)"
21.Fc
22.Ft void
23.Fo SSL_CTX_sess_set_remove_cb
24.Fa "SSL_CTX *ctx"
25.Fa "void (*remove_session_cb)(SSL_CTX *ctx, SSL_SESSION *)"
26.Fc
27.Ft void
28.Fo SSL_CTX_sess_set_get_cb
29.Fa "SSL_CTX *ctx"
30.Fa "SSL_SESSION (*get_session_cb)(SSL *, unsigned char *, int, int *)"
31.Fc
32.Ft int
33.Fo "(*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx))"
34.Fa "struct ssl_st *ssl"
35.Fa "SSL_SESSION *sess"
36.Fc
37.Ft void
38.Fo "(*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx))"
39.Fa "struct ssl_ctx_st *ctx"
40.Fa "SSL_SESSION *sess"
41.Fc
42.Ft SSL_SESSION *
43.Fo "(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx))"
44.Fa "struct ssl_st *ssl"
45.Fa "unsigned char *data"
46.Fa "int len"
47.Fa "int *copy"
48.Fc
49.Ft int
50.Fo "(*new_session_cb)"
51.Fa "struct ssl_st *ssl"
52.Fa "SSL_SESSION *sess"
53.Fc
54.Ft void
55.Fo "(*remove_session_cb)"
56.Fa "struct ssl_ctx_st *ctx"
57.Fa "SSL_SESSION *sess"
58.Fc
59.Ft SSL_SESSION *
60.Fo "(*get_session_cb)"
61.Fa "struct ssl_st *ssl"
62.Fa "unsigned char *data"
63.Fa "int len"
64.Fa "int *copy"
65.Fc
66.Sh DESCRIPTION
67.Fn SSL_CTX_sess_set_new_cb
68sets the callback function which is automatically called whenever a new session
69was negotiated.
70.Pp
71.Fn SSL_CTX_sess_set_remove_cb
72sets the callback function which is automatically called whenever a session is
73removed by the SSL engine (because it is considered faulty or the session has
74become obsolete because of exceeding the timeout value).
75.Pp
76.Fn SSL_CTX_sess_set_get_cb
77sets the callback function which is called whenever a SSL/TLS client proposes
78to resume a session but the session cannot be found in the internal session
79cache (see
80.Xr SSL_CTX_set_session_cache_mode 3 ) .
81(SSL/TLS server only.)
82.Pp
83.Fn SSL_CTX_sess_get_new_cb ,
84.Fn SSL_CTX_sess_get_remove_cb ,
85and
86.Fn SSL_CTX_sess_get_get_cb
87retrieve the function pointers of the provided callback functions.
88If a callback function has not been set, the
89.Dv NULL
90pointer is returned.
91.Sh NOTES
92In order to allow external session caching, synchronization with the internal
93session cache is realized via callback functions.
94Inside these callback functions, session can be saved to disk or put into a
95database using the
96.Xr d2i_SSL_SESSION 3
97interface.
98.Pp
99The
100.Fn new_session_cb
101function is called whenever a new session has been negotiated and session
102caching is enabled (see
103.Xr SSL_CTX_set_session_cache_mode 3 ) .
104The
105.Fn new_session_cb
106is passed the
107.Fa ssl
108connection and the ssl session
109.Fa sess .
110If the callback returns 0, the session will be immediately removed again.
111.Pp
112The
113.Fn remove_session_cb
114is called whenever the SSL engine removes a session from the internal cache.
115This happens when the session is removed because it is expired or when a
116connection was not shut down cleanly.
117It also happens for all sessions in the internal session cache when
118.Xr SSL_CTX_free 3
119is called.
120The
121.Fn remove_session_cb
122function is passed the
123.Fa ctx
124and the
125.Vt ssl
126session
127.Fa sess .
128It does not provide any feedback.
129.Pp
130The
131.Fn get_session_cb
132function is only called on SSL/TLS servers with the session id proposed by the
133client.
134The
135.Fn get_session_cb
136function is always called, also when session caching was disabled.
137The
138.Fn get_session_cb
139is passed the
140.Fa ssl
141connection, the session id of length
142.Fa length
143at the memory location
144.Fa data .
145With the parameter
146.Fa copy
147the callback can require the SSL engine to increment the reference count of the
148.Vt SSL_SESSION
149object,
150Normally the reference count is not incremented and therefore the session must
151not be explicitly freed with
152.Xr SSL_SESSION_free 3 .
153.Sh SEE ALSO
154.Xr d2i_SSL_SESSION 3 ,
155.Xr ssl 3 ,
156.Xr SSL_CTX_flush_sessions 3 ,
157.Xr SSL_CTX_free 3 ,
158.Xr SSL_CTX_set_session_cache_mode 3 ,
159.Xr SSL_SESSION_free 3
diff --git a/src/lib/libssl/man/SSL_CTX_sessions.3 b/src/lib/libssl/man/SSL_CTX_sessions.3
new file mode 100644
index 0000000000..72311699c8
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_sessions.3
@@ -0,0 +1,35 @@
1.\"
2.\" $OpenBSD: SSL_CTX_sessions.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_SESSIONS 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_sessions
9.Nd access internal session cache
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft struct lhash_st *
13.Fn SSL_CTX_sessions "SSL_CTX *ctx"
14.Sh DESCRIPTION
15.Fn SSL_CTX_sessions
16returns a pointer to the lhash databases containing the internal session cache
17for
18.Fa ctx .
19.Sh NOTES
20The sessions in the internal session cache are kept in an
21lhash-type database
22(see
23.Xr lh_new 3 ) .
24It is possible to directly access this database, e.g., for searching.
25In parallel,
26the sessions form a linked list which is maintained separately from the
27lhash operations,
28so that the database must not be modified directly but by using the
29.Xr SSL_CTX_add_session 3
30family of functions.
31.Sh SEE ALSO
32.Xr lh_new 3 ,
33.Xr ssl 3 ,
34.Xr SSL_CTX_add_session 3 ,
35.Xr SSL_CTX_set_session_cache_mode 3
diff --git a/src/lib/libssl/man/SSL_CTX_set_cert_store.3 b/src/lib/libssl/man/SSL_CTX_set_cert_store.3
new file mode 100644
index 0000000000..fcd531136a
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_set_cert_store.3
@@ -0,0 +1,80 @@
1.\"
2.\" $OpenBSD: SSL_CTX_set_cert_store.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_SET_CERT_STORE 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_set_cert_store ,
9.Nm SSL_CTX_get_cert_store
10.Nd manipulate X509 certificate verification storage
11.Sh SYNOPSIS
12.In openssl/ssl.h
13.Ft void
14.Fn SSL_CTX_set_cert_store "SSL_CTX *ctx" "X509_STORE *store"
15.Ft X509_STORE *
16.Fn SSL_CTX_get_cert_store "const SSL_CTX *ctx"
17.Sh DESCRIPTION
18.Fn SSL_CTX_set_cert_store
19setsthe verification storage of
20.Fa ctx
21to or replaces it with
22.Fa store .
23If another
24.Vt X509_STORE
25object is currently set in
26.Fa ctx ,
27it will be
28.Xr X509_STORE_free 3 Ns ed.
29.Pp
30.Fn SSL_CTX_get_cert_store
31returns a pointer to the current certificate verification storage.
32.Sh NOTES
33In order to verify the certificates presented by the peer, trusted CA
34certificates must be accessed.
35These CA certificates are made available via lookup methods, handled inside the
36.Vt X509_STORE .
37From the
38.Vt X509_STORE
39the
40.Vt X509_STORE_CTX
41used when verifying certificates is created.
42.Pp
43Typically the trusted certificate store is handled indirectly via using
44.Xr SSL_CTX_load_verify_locations 3 .
45Using the
46.Fn SSL_CTX_set_cert_store
47and
48.Fn SSL_CTX_get_cert_store
49functions it is possible to manipulate the
50.Vt X509_STORE
51object beyond the
52.Xr SSL_CTX_load_verify_locations 3
53call.
54.Pp
55Currently no detailed documentation on how to use the
56.Vt X509_STORE
57object is available.
58Not all members of the
59.Vt X509_STORE
60are used when the verification takes place.
61So will, for example, the
62.Fn verify_callback
63be overridden with the
64.Fn verify_callback
65set via the
66.Xr SSL_CTX_set_verify 3
67family of functions.
68This document must therefore be updated when documentation about the
69.Vt X509_STORE
70object and its handling becomes available.
71.Sh RETURN VALUES
72.Fn SSL_CTX_set_cert_store
73does not return diagnostic output.
74.Pp
75.Fn SSL_CTX_get_cert_store
76returns the current setting.
77.Sh SEE ALSO
78.Xr ssl 3 ,
79.Xr SSL_CTX_load_verify_locations 3 ,
80.Xr SSL_CTX_set_verify 3
diff --git a/src/lib/libssl/man/SSL_CTX_set_cert_verify_callback.3 b/src/lib/libssl/man/SSL_CTX_set_cert_verify_callback.3
new file mode 100644
index 0000000000..1dc57001aa
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_set_cert_verify_callback.3
@@ -0,0 +1,112 @@
1.\"
2.\" $OpenBSD: SSL_CTX_set_cert_verify_callback.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_SET_CERT_VERIFY_CALLBACK 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_set_cert_verify_callback
9.Nd set peer certificate verification procedure
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft void
13.Fo SSL_CTX_set_cert_verify_callback
14.Fa "SSL_CTX *ctx"
15.Fa "int (*callback)(X509_STORE_CTX *, void *)"
16.Fa "void *arg"
17.Fc
18.Sh DESCRIPTION
19.Fn SSL_CTX_set_cert_verify_callback
20sets the verification callback function for
21.Fa ctx .
22.Vt SSL
23objects that are created from
24.Fa ctx
25inherit the setting valid at the time when
26.Xr SSL_new 3
27is called.
28.Sh NOTES
29Whenever a certificate is verified during a SSL/TLS handshake,
30a verification function is called.
31If the application does not explicitly specify a verification callback
32function, the built-in verification function is used.
33If a verification callback
34.Fa callback
35is specified via
36.Fn SSL_CTX_set_cert_verify_callback ,
37the supplied callback function is called instead.
38By setting
39.Fa callback
40to
41.Dv NULL ,
42the default behaviour is restored.
43.Pp
44When the verification must be performed,
45.Fa callback
46will be called with the arguments
47.Fn callback "X509_STORE_CTX *x509_store_ctx" "void *arg" .
48The argument
49.Fa arg
50is specified by the application when setting
51.Fa callback .
52.Pp
53.Fa callback
54should return 1 to indicate verification success and 0 to indicate verification
55failure.
56If
57.Dv SSL_VERIFY_PEER
58is set and
59.Fa callback
60returns 0, the handshake will fail.
61As the verification procedure may allow the connection to continue in case of
62failure (by always returning 1) the verification result must be set in any case
63using the
64.Fa error
65member of
66.Fa x509_store_ctx
67so that the calling application will be informed about the detailed result of
68the verification procedure!
69.Pp
70Within
71.Fa x509_store_ctx ,
72.Fa callback
73has access to the
74.Fa verify_callback
75function set using
76.Xr SSL_CTX_set_verify 3 .
77.Sh WARNINGS
78Do not mix the verification callback described in this function with the
79.Fa verify_callback
80function called during the verification process.
81The latter is set using the
82.Xr SSL_CTX_set_verify 3
83family of functions.
84.Pp
85Providing a complete verification procedure including certificate purpose
86settings, etc., is a complex task.
87The built-in procedure is quite powerful and in most cases it should be
88sufficient to modify its behaviour using the
89.Fa verify_callback
90function.
91.Sh RETURN VALUES
92.Fn SSL_CTX_set_cert_verify_callback
93does not provide diagnostic information.
94.Sh SEE ALSO
95.Xr ssl 3 ,
96.Xr SSL_CTX_load_verify_locations 3 ,
97.Xr SSL_CTX_set_verify 3 ,
98.Xr SSL_get_verify_result 3
99.Sh HISTORY
100Previous to OpenSSL 0.9.7, the
101.Fa arg
102argument to
103.Fn SSL_CTX_set_cert_verify_callback
104was ignored, and
105.Fa callback
106was called
107simply as
108.Ft int
109.Fn (*callback) "X509_STORE_CTX *" .
110To compile software written for previous versions of OpenSSL,
111a dummy argument will have to be added to
112.Fa callback .
diff --git a/src/lib/libssl/man/SSL_CTX_set_cipher_list.3 b/src/lib/libssl/man/SSL_CTX_set_cipher_list.3
new file mode 100644
index 0000000000..7fb094a3b1
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_set_cipher_list.3
@@ -0,0 +1,82 @@
1.\"
2.\" $OpenBSD: SSL_CTX_set_cipher_list.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_SET_CIPHER_LIST 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_set_cipher_list ,
9.Nm SSL_set_cipher_list
10.Nd choose list of available SSL_CIPHERs
11.Sh SYNOPSIS
12.In openssl/ssl.h
13.Ft int
14.Fn SSL_CTX_set_cipher_list "SSL_CTX *ctx" "const char *str"
15.Ft int
16.Fn SSL_set_cipher_list "SSL *ssl" "const char *str"
17.Sh DESCRIPTION
18.Fn SSL_CTX_set_cipher_list
19sets the list of available ciphers for
20.Fa ctx
21using the control string
22.Fa str .
23The format of the string is described
24in
25.Xr openssl 1 .
26The list of ciphers is inherited by all
27.Fa ssl
28objects created from
29.Fa ctx .
30.Pp
31.Fn SSL_set_cipher_list
32sets the list of ciphers only for
33.Fa ssl .
34.Sh NOTES
35The control string
36.Fa str
37should be universally usable and not depend on details of the library
38configuration (ciphers compiled in).
39Thus no syntax checking takes place.
40Items that are not recognized, because the corresponding ciphers are not
41compiled in or because they are mistyped, are simply ignored.
42Failure is only flagged if no ciphers could be collected at all.
43.Pp
44It should be noted that inclusion of a cipher to be used into the list is a
45necessary condition.
46On the client side, the inclusion into the list is also sufficient.
47On the server side, additional restrictions apply.
48All ciphers have additional requirements.
49ADH ciphers don't need a certificate, but DH-parameters must have been set.
50All other ciphers need a corresponding certificate and key.
51.Pp
52A RSA cipher can only be chosen when a RSA certificate is available.
53RSA export ciphers with a keylength of 512 bits for the RSA key require a
54temporary 512 bit RSA key, as typically the supplied key has a length of 1024
55bits (see
56.Xr SSL_CTX_set_tmp_rsa_callback 3 ) .
57RSA ciphers using EDH need a certificate and key and additional DH-parameters
58(see
59.Xr SSL_CTX_set_tmp_dh_callback 3 ) .
60.Pp
61A DSA cipher can only be chosen when a DSA certificate is available.
62DSA ciphers always use DH key exchange and therefore need DH-parameters (see
63.Xr SSL_CTX_set_tmp_dh_callback 3 ) .
64.Pp
65When these conditions are not met for any cipher in the list (for example, a
66client only supports export RSA ciphers with an asymmetric key length of 512
67bits and the server is not configured to use temporary RSA keys), the
68.Dq no shared cipher
69.Pq Dv SSL_R_NO_SHARED_CIPHER
70error is generated and the handshake will fail.
71.Sh RETURN VALUES
72.Fn SSL_CTX_set_cipher_list
73and
74.Fn SSL_set_cipher_list
75return 1 if any cipher could be selected and 0 on complete failure.
76.Sh SEE ALSO
77.Xr ciphers 1 ,
78.Xr ssl 3 ,
79.Xr SSL_CTX_set_tmp_dh_callback 3 ,
80.Xr SSL_CTX_set_tmp_rsa_callback 3 ,
81.Xr SSL_CTX_use_certificate 3 ,
82.Xr SSL_get_ciphers 3
diff --git a/src/lib/libssl/man/SSL_CTX_set_client_CA_list.3 b/src/lib/libssl/man/SSL_CTX_set_client_CA_list.3
new file mode 100644
index 0000000000..bcc53fb0d6
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_set_client_CA_list.3
@@ -0,0 +1,132 @@
1.\"
2.\" $OpenBSD: SSL_CTX_set_client_CA_list.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_SET_CLIENT_CA_LIST 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_set_client_CA_list ,
9.Nm SSL_set_client_CA_list ,
10.Nm SSL_CTX_add_client_CA ,
11.Nm SSL_add_client_CA
12.Nd set list of CAs sent to the client when requesting a client certificate
13.Sh SYNOPSIS
14.In openssl/ssl.h
15.Ft void
16.Fn SSL_CTX_set_client_CA_list "SSL_CTX *ctx" "STACK_OF(X509_NAME) *list"
17.Ft void
18.Fn SSL_set_client_CA_list "SSL *s" "STACK_OF(X509_NAME) *list"
19.Ft int
20.Fn SSL_CTX_add_client_CA "SSL_CTX *ctx" "X509 *cacert"
21.Ft int
22.Fn SSL_add_client_CA "SSL *ssl" "X509 *cacert"
23.Sh DESCRIPTION
24.Fn SSL_CTX_set_client_CA_list
25sets the
26.Fa list
27of CAs sent to the client when requesting a client certificate for
28.Fa ctx .
29.Pp
30.Fn SSL_set_client_CA_list
31sets the
32.Fa list
33of CAs sent to the client when requesting a client certificate for the chosen
34.Fa ssl ,
35overriding the setting valid for
36.Fa ssl Ns 's
37.Vt SSL_CTX
38object.
39.Pp
40.Fn SSL_CTX_add_client_CA
41adds the CA name extracted from
42.Fa cacert
43to the list of CAs sent to the client when requesting a client certificate for
44.Fa ctx .
45.Pp
46.Fn SSL_add_client_CA
47adds the CA name extracted from
48.Fa cacert
49to the list of CAs sent to the client when requesting a client certificate for
50the chosen
51.Fa ssl ,
52overriding the setting valid for
53.Fa ssl Ns 's
54.Va SSL_CTX
55object.
56.Sh NOTES
57When a TLS/SSL server requests a client certificate (see
58.Fn SSL_CTX_set_verify ) ,
59it sends a list of CAs for which it will accept certificates to the client.
60.Pp
61This list must explicitly be set using
62.Fn SSL_CTX_set_client_CA_list
63for
64.Fa ctx
65and
66.Fn SSL_set_client_CA_list
67for the specific
68.Fa ssl .
69The list specified overrides the previous setting.
70The CAs listed do not become trusted
71.Po
72.Fa list
73only contains the names, not the complete certificates
74.Pc ;
75use
76.Xr SSL_CTX_load_verify_locations 3
77to additionally load them for verification.
78.Pp
79If the list of acceptable CAs is compiled in a file, the
80.Xr SSL_load_client_CA_file 3
81function can be used to help importing the necessary data.
82.Pp
83.Fn SSL_CTX_add_client_CA
84and
85.Fn SSL_add_client_CA
86can be used to add additional items the list of client CAs.
87If no list was specified before using
88.Fn SSL_CTX_set_client_CA_list
89or
90.Fn SSL_set_client_CA_list ,
91a new client CA list for
92.Fa ctx
93or
94.Fa ssl
95(as appropriate) is opened.
96.Pp
97These functions are only useful for TLS/SSL servers.
98.Sh RETURN VALUES
99.Fn SSL_CTX_set_client_CA_list
100and
101.Fn SSL_set_client_CA_list
102do not return diagnostic information.
103.Pp
104.Fn SSL_CTX_add_client_CA
105and
106.Fn SSL_add_client_CA
107have the following return values:
108.Bl -tag -width Ds
109.It 0
110A failure while manipulating the
111.Dv STACK_OF Ns
112.Pq Vt X509_NAME
113object occurred or the
114.Vt X509_NAME
115could not be extracted from
116.Fa cacert .
117Check the error stack to find out the reason.
118.It 1
119The operation succeeded.
120.El
121.Sh EXAMPLES
122Scan all certificates in
123.Fa CAfile
124and list them as acceptable CAs:
125.Bd -literal
126SSL_CTX_set_client_CA_list(ctx, SSL_load_client_CA_file(CAfile));
127.Ed
128.Sh SEE ALSO
129.Xr ssl 3 ,
130.Xr SSL_CTX_load_verify_locations 3 ,
131.Xr SSL_get_client_CA_list 3 ,
132.Xr SSL_load_client_CA_file 3
diff --git a/src/lib/libssl/man/SSL_CTX_set_client_cert_cb.3 b/src/lib/libssl/man/SSL_CTX_set_client_cert_cb.3
new file mode 100644
index 0000000000..c4057ae4cc
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_set_client_cert_cb.3
@@ -0,0 +1,143 @@
1.\"
2.\" $OpenBSD: SSL_CTX_set_client_cert_cb.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_SET_CLIENT_CERT_CB 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_set_client_cert_cb ,
9.Nm SSL_CTX_get_client_cert_cb
10.Nd handle client certificate callback function
11.Sh SYNOPSIS
12.In openssl/ssl.h
13.Ft void
14.Fo SSL_CTX_set_client_cert_cb
15.Fa "SSL_CTX *ctx"
16.Fa "int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey)"
17.Fc
18.Ft int
19.Fo "(*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx))"
20.Fa "SSL *ssl" "X509 **x509" "EVP_PKEY **pkey"
21.Fc
22.Ft int
23.Fn "(*client_cert_cb)" "SSL *ssl" "X509 **x509" "EVP_PKEY **pkey"
24.Sh DESCRIPTION
25.Fn SSL_CTX_set_client_cert_cb
26sets the
27.Fa client_cert_cb()
28callback that is called when a client certificate is requested by a server and
29no certificate was yet set for the SSL object.
30.Pp
31When
32.Fa client_cert_cb
33is
34.Dv NULL ,
35no callback function is used.
36.Pp
37.Fn SSL_CTX_get_client_cert_cb
38returns a pointer to the currently set callback function.
39.Pp
40.Fn client_cert_cb
41is the application-defined callback.
42If it wants to set a certificate,
43a certificate/private key combination must be set using the
44.Fa x509
45and
46.Fa pkey
47arguments and 1 must be returned.
48The certificate will be installed into
49.Fa ssl ;
50see the
51.Sx NOTES
52and
53.Sx BUGS
54sections.
55If no certificate should be set,
560 has to be returned and no certificate will be sent.
57A negative return value will suspend the handshake and the handshake function
58will return immediately.
59.Xr SSL_get_error 3
60will return
61.Dv SSL_ERROR_WANT_X509_LOOKUP
62to indicate that the handshake was suspended.
63The next call to the handshake function will again lead to the call of
64.Fa client_cert_cb() .
65It is the job of the
66.Fa client_cert_cb()
67to store information
68about the state of the last call, if required to continue.
69.Sh NOTES
70During a handshake (or renegotiation)
71a server may request a certificate from the client.
72A client certificate must only be sent when the server did send the request.
73.Pp
74When a certificate has been set using the
75.Xr SSL_CTX_use_certificate 3
76family of functions,
77it will be sent to the server.
78The TLS standard requires that only a certificate is sent if it matches the
79list of acceptable CAs sent by the server.
80This constraint is violated by the default behavior of the OpenSSL library.
81Using the callback function it is possible to implement a proper selection
82routine or to allow a user interaction to choose the certificate to be sent.
83.Pp
84If a callback function is defined and no certificate was yet defined for the
85.Vt SSL
86object, the callback function will be called.
87If the callback function returns a certificate, the OpenSSL library
88will try to load the private key and certificate data into the
89.Vt SSL
90object using the
91.Fn SSL_use_certificate
92and
93.Fn SSL_use_private_key
94functions.
95Thus it will permanently install the certificate and key for this SSL object.
96It will not be reset by calling
97.Xr SSL_clear 3 .
98If the callback returns no certificate, the OpenSSL library will not send a
99certificate.
100.Sh SEE ALSO
101.Xr ssl 3 ,
102.Xr SSL_clear 3 ,
103.Xr SSL_CTX_add_extra_chain_cert 3 ,
104.Xr SSL_CTX_use_certificate 3 ,
105.Xr SSL_free 3 ,
106.Xr SSL_get_client_CA_list 3
107.Sh BUGS
108The
109.Fa client_cert_cb()
110cannot return a complete certificate chain;
111it can only return one client certificate.
112If the chain only has a length of 2,
113the root CA certificate may be omitted according to the TLS standard and
114thus a standard conforming answer can be sent to the server.
115For a longer chain, the client must send the complete chain
116(with the option to leave out the root CA certificate).
117This can be accomplished only by either adding the intermediate CA certificates
118into the trusted certificate store for the
119.Vt SSL_CTX
120object (resulting in having to add CA certificates that otherwise maybe would
121not be trusted), or by adding the chain certificates using the
122.Xr SSL_CTX_add_extra_chain_cert 3
123function, which is only available for the
124.Vt SSL_CTX
125object as a whole and that therefore probably can only apply for one client
126certificate, making the concept of the callback function
127(to allow the choice from several certificates) questionable.
128.Pp
129Once the
130.Vt SSL
131object has been used in conjunction with the callback function,
132the certificate will be set for the
133.Vt SSL
134object and will not be cleared even when
135.Xr SSL_clear 3
136is called.
137It is therefore
138.Em mandatory
139to destroy the
140.Vt SSL
141object using
142.Xr SSL_free 3
143and create a new one to return to the previous state.
diff --git a/src/lib/libssl/man/SSL_CTX_set_default_passwd_cb.3 b/src/lib/libssl/man/SSL_CTX_set_default_passwd_cb.3
new file mode 100644
index 0000000000..599c574c3d
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_set_default_passwd_cb.3
@@ -0,0 +1,95 @@
1.\"
2.\" $OpenBSD: SSL_CTX_set_default_passwd_cb.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_SET_DEFAULT_PASSWD_CB 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_set_default_passwd_cb ,
9.Nm SSL_CTX_set_default_passwd_cb_userdata
10.Nd set passwd callback for encrypted PEM file handling
11.Sh SYNOPSIS
12.In openssl/ssl.h
13.Ft void
14.Fn SSL_CTX_set_default_passwd_cb "SSL_CTX *ctx" "pem_password_cb *cb"
15.Ft void
16.Fn SSL_CTX_set_default_passwd_cb_userdata "SSL_CTX *ctx" "void *u"
17.Ft int
18.Fn pem_passwd_cb "char *buf" "int size" "int rwflag" "void *userdata"
19.Sh DESCRIPTION
20.Fn SSL_CTX_set_default_passwd_cb
21sets the default password callback called when loading/storing a PEM
22certificate with encryption.
23.Pp
24.Fn SSL_CTX_set_default_passwd_cb_userdata
25sets a pointer to userdata
26.Fa u
27which will be provided to the password callback on invocation.
28.Pp
29The
30.Fn pem_passwd_cb ,
31which must be provided by the application,
32hands back the password to be used during decryption.
33On invocation a pointer to
34.Fa userdata
35is provided.
36The pem_passwd_cb must write the password into the provided buffer
37.Fa buf
38which is of size
39.Fa size .
40The actual length of the password must be returned to the calling function.
41.Fa rwflag
42indicates whether the callback is used for reading/decryption
43.Pq Fa rwflag No = 0
44or writing/encryption
45.Pq Fa rwflag No = 1 .
46.Sh NOTES
47When loading or storing private keys, a password might be supplied to protect
48the private key.
49The way this password can be supplied may depend on the application.
50If only one private key is handled, it can be practical to have
51.Fn pem_passwd_cb
52handle the password dialog interactively.
53If several keys have to be handled, it can be practical to ask for the password
54once, then keep it in memory and use it several times.
55In the last case, the password could be stored into the
56.Fa userdata
57storage and the
58.Fn pem_passwd_cb
59only returns the password already stored.
60.Pp
61When asking for the password interactively,
62.Fn pem_passwd_cb
63can use
64.Fa rwflag
65to check whether an item shall be encrypted
66.Pq Fa rwflag No = 1 .
67In this case the password dialog may ask for the same password twice for
68comparison in order to catch typos which would make decryption impossible.
69.Pp
70Other items in PEM formatting (certificates) can also be encrypted; it is
71however atypical, as certificate information is considered public.
72.Sh RETURN VALUES
73.Fn SSL_CTX_set_default_passwd_cb
74and
75.Fn SSL_CTX_set_default_passwd_cb_userdata
76do not provide diagnostic information.
77.Sh EXAMPLES
78The following example returns the password provided as
79.Fa userdata
80to the calling function.
81The password is considered to be a
82.Sq \e0
83terminated string.
84If the password does not fit into the buffer, the password is truncated.
85.Bd -literal
86int pem_passwd_cb(char *buf, int size, int rwflag, void *password)
87{
88 strncpy(buf, (char *)password, size);
89 buf[size - 1] = '\e0';
90 return strlen(buf);
91}
92.Ed
93.Sh SEE ALSO
94.Xr ssl 3 ,
95.Xr SSL_CTX_use_certificate 3
diff --git a/src/lib/libssl/man/SSL_CTX_set_generate_session_id.3 b/src/lib/libssl/man/SSL_CTX_set_generate_session_id.3
new file mode 100644
index 0000000000..29ff6a123e
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_set_generate_session_id.3
@@ -0,0 +1,196 @@
1.\"
2.\" $OpenBSD: SSL_CTX_set_generate_session_id.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_SET_GENERATE_SESSION_ID 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_set_generate_session_id ,
9.Nm SSL_set_generate_session_id ,
10.Nm SSL_has_matching_session_id
11.Nd manipulate generation of SSL session IDs (server only)
12.Sh SYNOPSIS
13.In openssl/ssl.h
14.Bd -literal
15 typedef int (*GEN_SESSION_CB)(const SSL *ssl, unsigned char *id,
16 unsigned int *id_len);
17.Ed
18.Ft int
19.Fn SSL_CTX_set_generate_session_id "SSL_CTX *ctx" "GEN_SESSION_CB cb"
20.Ft int
21.Fn SSL_set_generate_session_id "SSL *ssl" "GEN_SESSION_CB" "cb);"
22.Ft int
23.Fo SSL_has_matching_session_id
24.Fa "const SSL *ssl" "const unsigned char *id" "unsigned int id_len"
25.Fc
26.Sh DESCRIPTION
27.Fn SSL_CTX_set_generate_session_id
28sets the callback function for generating new session ids for SSL/TLS sessions
29for
30.Fa ctx
31to be
32.Fa cb .
33.Pp
34.Fn SSL_set_generate_session_id
35sets the callback function for generating new session ids for SSL/TLS sessions
36for
37.Fa ssl
38to be
39.Fa cb .
40.Pp
41.Fn SSL_has_matching_session_id
42checks, whether a session with id
43.Fa id
44(of length
45.Fa id_len )
46is already contained in the internal session cache
47of the parent context of
48.Fa ssl .
49.Sh NOTES
50When a new session is established between client and server,
51the server generates a session id.
52The session id is an arbitrary sequence of bytes.
53The length of the session id is 16 bytes for SSLv2 sessions and between 1 and
5432 bytes for SSLv3/TLSv1.
55The session id is not security critical but must be unique for the server.
56Additionally, the session id is transmitted in the clear when reusing the
57session so it must not contain sensitive information.
58.Pp
59Without a callback being set, an OpenSSL server will generate a unique session
60id from pseudo random numbers of the maximum possible length.
61Using the callback function, the session id can be changed to contain
62additional information like, e.g., a host id in order to improve load balancing
63or external caching techniques.
64.Pp
65The callback function receives a pointer to the memory location to put
66.Fa id
67into and a pointer to the maximum allowed length
68.Fa id_len .
69The buffer at location
70.Fa id
71is only guaranteed to have the size
72.Fa id_len .
73The callback is only allowed to generate a shorter id and reduce
74.Fa id_len ;
75the callback
76.Em must never
77increase
78.Fa id_len
79or write to the location
80.Fa id
81exceeding the given limit.
82.Pp
83If a SSLv2 session id is generated and
84.Fa id_len
85is reduced, it will be restored after the callback has finished and the session
86id will be padded with 0x00.
87It is not recommended to change the
88.Fa id_len
89for SSLv2 sessions.
90The callback can use the
91.Xr SSL_get_version 3
92function to check whether the session is of type SSLv2.
93.Pp
94The location
95.Fa id
96is filled with 0x00 before the callback is called,
97so the callback may only fill part of the possible length and leave
98.Fa id_len
99untouched while maintaining reproducibility.
100.Pp
101Since the sessions must be distinguished, session ids must be unique.
102Without the callback a random number is used,
103so that the probability of generating the same session id is extremely small
104(2^128 possible ids for an SSLv2 session, 2^256 for SSLv3/TLSv1).
105In order to ensure the uniqueness of the generated session id,
106the callback must call
107.Fn SSL_has_matching_session_id
108and generate another id if a conflict occurs.
109If an id conflict is not resolved, the handshake will fail.
110If the application codes, e.g., a unique host id, a unique process number, and
111a unique sequence number into the session id, uniqueness could easily be
112achieved without randomness added (it should however be taken care that
113no confidential information is leaked this way).
114If the application cannot guarantee uniqueness,
115it is recommended to use the maximum
116.Fa id_len
117and fill in the bytes not used to code special information with random data to
118avoid collisions.
119.Pp
120.Fn SSL_has_matching_session_id
121will only query the internal session cache, not the external one.
122Since the session id is generated before the handshake is completed,
123it is not immediately added to the cache.
124If another thread is using the same internal session cache,
125a race condition can occur in that another thread generates the same session id.
126Collisions can also occur when using an external session cache,
127since the external cache is not tested with
128.Fn SSL_has_matching_session_id
129and the same race condition applies.
130.Pp
131When calling
132.Fn SSL_has_matching_session_id
133for an SSLv2 session with reduced
134.Fa id_len Ns ,
135the match operation will be performed using the fixed length required and with
136a 0x00 padded id.
137.Pp
138The callback must return 0 if it cannot generate a session id for whatever
139reason and return 1 on success.
140.Sh RETURN VALUES
141.Fn SSL_CTX_set_generate_session_id
142and
143.Fn SSL_set_generate_session_id
144always return 1.
145.Pp
146.Fn SSL_has_matching_session_id
147returns 1 if another session with the same id is already in the cache.
148.Sh EXAMPLES
149The callback function listed will generate a session id with the server id
150given, and will fill the rest with pseudo random bytes:
151.Bd -literal
152const char session_id_prefix = "www-18";
153
154#define MAX_SESSION_ID_ATTEMPTS 10
155static int
156generate_session_id(const SSL *ssl, unsigned char *id,
157 unsigned int *id_len)
158{
159 unsigned int count = 0;
160 const char *version;
161
162 version = SSL_get_version(ssl);
163 if (!strcmp(version, "SSLv2")) {
164 /* we must not change id_len */
165 ;
166 }
167
168 do {
169 RAND_pseudo_bytes(id, *id_len);
170 /*
171 * Prefix the session_id with the required prefix. NB: If
172 * our prefix is too long, clip it \(en but there will be
173 * worse effects anyway, e.g., the server could only
174 * possibly create one session ID (the prefix!) so all
175 * future session negotiations will fail due to conflicts.
176 */
177 memcpy(id, session_id_prefix,
178 (strlen(session_id_prefix) < *id_len) ?
179 strlen(session_id_prefix) : *id_len);
180 } while (SSL_has_matching_session_id(ssl, id, *id_len) &&
181 (++count < MAX_SESSION_ID_ATTEMPTS));
182
183 if (count >= MAX_SESSION_ID_ATTEMPTS)
184 return 0;
185 return 1;
186}
187.Ed
188.Sh SEE ALSO
189.Xr ssl 3 ,
190.Xr SSL_get_version 3
191.Sh HISTORY
192.Fn SSL_CTX_set_generate_session_id ,
193.Fn SSL_set_generate_session_id
194and
195.Fn SSL_has_matching_session_id
196were introduced in OpenSSL 0.9.7.
diff --git a/src/lib/libssl/man/SSL_CTX_set_info_callback.3 b/src/lib/libssl/man/SSL_CTX_set_info_callback.3
new file mode 100644
index 0000000000..760c239951
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_set_info_callback.3
@@ -0,0 +1,167 @@
1.\"
2.\" $OpenBSD: SSL_CTX_set_info_callback.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_SET_INFO_CALLBACK 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_set_info_callback ,
9.Nm SSL_CTX_get_info_callback ,
10.Nm SSL_set_info_callback ,
11.Nm SSL_get_info_callback
12.Nd handle information callback for SSL connections
13.Sh SYNOPSIS
14.In openssl/ssl.h
15.Ft void
16.Fn SSL_CTX_set_info_callback "SSL_CTX *ctx" "void (*callback)()"
17.Ft void
18.Fn "(*SSL_CTX_get_info_callback(const SSL_CTX *ctx))"
19.Ft void
20.Fn SSL_set_info_callback "SSL *ssl" "void (*callback)()"
21.Ft void
22.Fn "(*SSL_get_info_callback(const SSL *ssl))"
23.Sh DESCRIPTION
24.Fn SSL_CTX_set_info_callback
25sets the
26.Fa callback
27function that can be used to obtain state information for SSL objects created
28from
29.Fa ctx
30during connection setup and use.
31The setting for
32.Fa ctx
33is overridden from the setting for a specific SSL object, if specified.
34When
35.Fa callback
36is
37.Dv NULL ,
38no callback function is used.
39.Pp
40.Fn SSL_set_info_callback
41sets the
42.Fa callback
43function that can be used to
44obtain state information for
45.Fa ssl
46during connection setup and use.
47When
48.Fa callback
49is
50.Dv NULL ,
51the callback setting currently valid for
52.Fa ctx
53is used.
54.Pp
55.Fn SSL_CTX_get_info_callback
56returns a pointer to the currently set information callback function for
57.Fa ctx .
58.Pp
59.Fn SSL_get_info_callback
60returns a pointer to the currently set information callback function for
61.Fa ssl .
62.Sh NOTES
63When setting up a connection and during use,
64it is possible to obtain state information from the SSL/TLS engine.
65When set, an information callback function is called whenever the state changes,
66an alert appears, or an error occurs.
67.Pp
68The callback function is called as
69.Fn callback "SSL *ssl" "int where" "int ret" .
70The
71.Fa where
72argument specifies information about where (in which context)
73the callback function was called.
74If
75.Fa ret
76is 0, an error condition occurred.
77If an alert is handled,
78.Dv SSL_CB_ALERT
79is set and
80.Fa ret
81specifies the alert information.
82.Pp
83.Fa where
84is a bitmask made up of the following bits:
85.Bl -tag -width Ds
86.It Dv SSL_CB_LOOP
87Callback has been called to indicate state change inside a loop.
88.It Dv SSL_CB_EXIT
89Callback has been called to indicate error exit of a handshake function.
90(May be soft error with retry option for non-blocking setups.)
91.It Dv SSL_CB_READ
92Callback has been called during read operation.
93.It Dv SSL_CB_WRITE
94Callback has been called during write operation.
95.It Dv SSL_CB_ALERT
96Callback has been called due to an alert being sent or received.
97.It Dv SSL_CB_READ_ALERT
98.It Dv SSL_CB_WRITE_ALERT
99.It Dv SSL_CB_ACCEPT_LOOP
100.It Dv SSL_CB_ACCEPT_EXIT
101.It Dv SSL_CB_CONNECT_LOOP
102.It Dv SSL_CB_CONNECT_EXIT
103.It Dv SSL_CB_HANDSHAKE_START
104Callback has been called because a new handshake is started.
105.It Dv SSL_CB_HANDSHAKE_DONE
106Callback has been called because a handshake is finished.
107.El
108.Pp
109The current state information can be obtained using the
110.Xr SSL_state_string 3
111family of functions.
112.Pp
113The
114.Fa ret
115information can be evaluated using the
116.Xr SSL_alert_type_string 3
117family of functions.
118.Sh RETURN VALUES
119.Fn SSL_set_info_callback
120does not provide diagnostic information.
121.Pp
122.Fn SSL_get_info_callback
123returns the current setting.
124.Sh EXAMPLES
125The following example callback function prints state strings,
126information about alerts being handled and error messages to the
127.Va bio_err
128.Vt BIO .
129.Bd -literal
130void
131apps_ssl_info_callback(SSL *s, int where, int ret)
132{
133 const char *str;
134 int w;
135
136 w = where & ~SSL_ST_MASK;
137
138 if (w & SSL_ST_CONNECT)
139 str = "SSL_connect";
140 else if (w & SSL_ST_ACCEPT)
141 str = "SSL_accept";
142 else
143 str = "undefined";
144
145 if (where & SSL_CB_LOOP) {
146 BIO_printf(bio_err, "%s:%s\en", str,
147 SSL_state_string_long(s));
148 } else if (where & SSL_CB_ALERT) {
149 str = (where & SSL_CB_READ) ? "read" : "write";
150 BIO_printf(bio_err, "SSL3 alert %s:%s:%s\en", str,
151 SSL_alert_type_string_long(ret),
152 SSL_alert_desc_string_long(ret));
153 } else if (where & SSL_CB_EXIT) {
154 if (ret == 0)
155 BIO_printf(bio_err, "%s:failed in %s\en",
156 str, SSL_state_string_long(s));
157 else if (ret < 0) {
158 BIO_printf(bio_err, "%s:error in %s\en",
159 str, SSL_state_string_long(s));
160 }
161 }
162}
163.Ed
164.Sh SEE ALSO
165.Xr ssl 3 ,
166.Xr SSL_alert_type_string 3 ,
167.Xr SSL_state_string 3
diff --git a/src/lib/libssl/man/SSL_CTX_set_max_cert_list.3 b/src/lib/libssl/man/SSL_CTX_set_max_cert_list.3
new file mode 100644
index 0000000000..c9cd6e6d2b
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_set_max_cert_list.3
@@ -0,0 +1,105 @@
1.\"
2.\" $OpenBSD: SSL_CTX_set_max_cert_list.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_SET_MAX_CERT_LIST 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_set_max_cert_list ,
9.Nm SSL_CTX_get_max_cert_list ,
10.Nm SSL_set_max_cert_list ,
11.Nm SSL_get_max_cert_list
12.Nd manipulate allowed size for the peer's certificate chain
13.Sh SYNOPSIS
14.In openssl/ssl.h
15.Ft long
16.Fn SSL_CTX_set_max_cert_list "SSL_CTX *ctx" "long size"
17.Ft long
18.Fn SSL_CTX_get_max_cert_list "SSL_CTX *ctx"
19.Ft long
20.Fn SSL_set_max_cert_list "SSL *ssl" "long size"
21.Ft long
22.Fn SSL_get_max_cert_list "SSL *ctx"
23.Sh DESCRIPTION
24.Fn SSL_CTX_set_max_cert_list
25sets the maximum size allowed for the peer's certificate chain for all
26.Vt SSL
27objects created from
28.Fa ctx
29to be
30.Fa size
31bytes.
32The
33.Vt SSL
34objects inherit the setting valid for
35.Fa ctx
36at the time
37.Xr SSL_new 3
38is being called.
39.Pp
40.Fn SSL_CTX_get_max_cert_list
41returns the currently set maximum size for
42.Fa ctx .
43.Pp
44.Fn SSL_set_max_cert_list
45sets the maximum size allowed for the peer's certificate chain for
46.Fa ssl
47to be
48.Fa size
49bytes.
50This setting stays valid until a new value is set.
51.Pp
52.Fn SSL_get_max_cert_list
53returns the currently set maximum size for
54.Fa ssl .
55.Sh NOTES
56During the handshake process, the peer may send a certificate chain.
57The TLS/SSL standard does not give any maximum size of the certificate chain.
58The OpenSSL library handles incoming data by a dynamically allocated buffer.
59In order to prevent this buffer from growing without bound due to data
60received from a faulty or malicious peer, a maximum size for the certificate
61chain is set.
62.Pp
63The default value for the maximum certificate chain size is 100kB (30kB
64on the 16bit DOS platform).
65This should be sufficient for usual certificate chains
66(OpenSSL's default maximum chain length is 10, see
67.Xr SSL_CTX_set_verify 3 ,
68and certificates without special extensions have a typical size of 1-2kB).
69.Pp
70For special applications it can be necessary to extend the maximum certificate
71chain size allowed to be sent by the peer.
72See for example the work on
73.%T "Internet X.509 Public Key Infrastructure Proxy Certificate Profile"
74and
75.%T "TLS Delegation Protocol"
76at
77.Lk https://www.ietf.org/
78and
79.Lk http://www.globus.org/ .
80.Pp
81Under normal conditions it should never be necessary to set a value smaller
82than the default, as the buffer is handled dynamically and only uses the
83memory actually required by the data sent by the peer.
84.Pp
85If the maximum certificate chain size allowed is exceeded, the handshake will
86fail with a
87.Dv SSL_R_EXCESSIVE_MESSAGE_SIZE
88error.
89.Sh RETURN VALUES
90.Fn SSL_CTX_set_max_cert_list
91and
92.Fn SSL_set_max_cert_list
93return the previously set value.
94.Pp
95.Fn SSL_CTX_get_max_cert_list
96and
97.Fn SSL_get_max_cert_list
98return the currently set value.
99.Sh SEE ALSO
100.Xr ssl 3 ,
101.Xr SSL_CTX_set_verify 3 ,
102.Xr SSL_new 3
103.Sh HISTORY
104.Fn SSL*_set/get_max_cert_list
105were introduced in OpenSSL 0.9.7.
diff --git a/src/lib/libssl/man/SSL_CTX_set_mode.3 b/src/lib/libssl/man/SSL_CTX_set_mode.3
new file mode 100644
index 0000000000..a2d53884da
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_set_mode.3
@@ -0,0 +1,126 @@
1.\"
2.\" $OpenBSD: SSL_CTX_set_mode.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_SET_MODE 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_set_mode ,
9.Nm SSL_set_mode ,
10.Nm SSL_CTX_get_mode ,
11.Nm SSL_get_mode
12.Nd manipulate SSL engine mode
13.Sh SYNOPSIS
14.In openssl/ssl.h
15.Ft long
16.Fn SSL_CTX_set_mode "SSL_CTX *ctx" "long mode"
17.Ft long
18.Fn SSL_set_mode "SSL *ssl" "long mode"
19.Ft long
20.Fn SSL_CTX_get_mode "SSL_CTX *ctx"
21.Ft long
22.Fn SSL_get_mode "SSL *ssl"
23.Sh DESCRIPTION
24.Fn SSL_CTX_set_mode
25adds the mode set via bitmask in
26.Fa mode
27to
28.Fa ctx .
29Options already set before are not cleared.
30.Pp
31.Fn SSL_set_mode
32adds the mode set via bitmask in
33.Fa mode
34to
35.Fa ssl .
36Options already set before are not cleared.
37.Pp
38.Fn SSL_CTX_get_mode
39returns the mode set for
40.Fa ctx .
41.Pp
42.Fn SSL_get_mode
43returns the mode set for
44.Fa ssl .
45.Sh NOTES
46The following mode changes are available:
47.Bl -tag -width Ds
48.It Dv SSL_MODE_ENABLE_PARTIAL_WRITE
49Allow
50.Fn SSL_write ... n
51to return
52.Ms r
53with
54.EQ
550 < r < n
56.EN
57(i.e., report success when just a single record has been written).
58When not set (the default),
59.Xr SSL_write 3
60will only report success once the complete chunk was written.
61Once
62.Xr SSL_write 3
63returns with
64.Ms r ,
65.Ms r
66bytes have been successfully written and the next call to
67.Xr SSL_write 3
68must only send the
69.Ms n \(mi r
70bytes left, imitating the behaviour of
71.Xr write 2 .
72.It Dv SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER
73Make it possible to retry
74.Xr SSL_write 3
75with changed buffer location (the buffer contents must stay the same).
76This is not the default to avoid the misconception that non-blocking
77.Xr SSL_write 3
78behaves like non-blocking
79.Xr write 2 .
80.It Dv SSL_MODE_AUTO_RETRY
81Never bother the application with retries if the transport is blocking.
82If a renegotiation take place during normal operation, a
83.Xr SSL_read 3
84or
85.Xr SSL_write 3
86would return
87with \(mi1 and indicate the need to retry with
88.Dv SSL_ERROR_WANT_READ .
89In a non-blocking environment applications must be prepared to handle
90incomplete read/write operations.
91In a blocking environment, applications are not always prepared to deal with
92read/write operations returning without success report.
93The flag
94.Dv SSL_MODE_AUTO_RETRY
95will cause read/write operations to only return after the handshake and
96successful completion.
97.It Dv SSL_MODE_RELEASE_BUFFERS
98When we no longer need a read buffer or a write buffer for a given
99.Vt SSL ,
100then release the memory we were using to hold it.
101Released memory is either appended to a list of unused RAM chunks on the
102.Vt SSL_CTX ,
103or simply freed if the list of unused chunks would become longer than
104.Va "SSL_CTX->freelist_max_len" ,
105which defaults to 32.
106Using this flag can save around 34k per idle SSL connection.
107This flag has no effect on SSL v2 connections, or on DTLS connections.
108.El
109.Sh RETURN VALUES
110.Fn SSL_CTX_set_mode
111and
112.Fn SSL_set_mode
113return the new mode bitmask after adding
114.Fa mode .
115.Pp
116.Fn SSL_CTX_get_mode
117and
118.Fn SSL_get_mode
119return the current bitmask.
120.Sh SEE ALSO
121.Xr ssl 3 ,
122.Xr SSL_read 3 ,
123.Xr SSL_write 3
124.Sh HISTORY
125.Dv SSL_MODE_AUTO_RETRY
126was added in OpenSSL 0.9.6.
diff --git a/src/lib/libssl/man/SSL_CTX_set_msg_callback.3 b/src/lib/libssl/man/SSL_CTX_set_msg_callback.3
new file mode 100644
index 0000000000..7142c40545
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_set_msg_callback.3
@@ -0,0 +1,135 @@
1.\"
2.\" $OpenBSD: SSL_CTX_set_msg_callback.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_SET_MSG_CALLBACK 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_set_msg_callback ,
9.Nm SSL_CTX_set_msg_callback_arg ,
10.Nm SSL_set_msg_callback ,
11.Nm SSL_set_msg_callback_arg
12.Nd install callback for observing protocol messages
13.Sh SYNOPSIS
14.In openssl/ssl.h
15.Ft void
16.Fo SSL_CTX_set_msg_callback
17.Fa "SSL_CTX *ctx"
18.Fa "void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)"
19.Fc
20.Ft void
21.Fn SSL_CTX_set_msg_callback_arg "SSL_CTX *ctx" "void *arg"
22.Ft void
23.Fo SSL_set_msg_callback
24.Fa "SSL *ssl"
25.Fa "void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)"
26.Fc
27.Ft void
28.Fn SSL_set_msg_callback_arg "SSL *ssl" "void *arg"
29.Sh DESCRIPTION
30.Fn SSL_CTX_set_msg_callback
31or
32.Fn SSL_set_msg_callback
33can be used to define a message callback function
34.Fa cb
35for observing all SSL/TLS protocol messages (such as handshake messages)
36that are received or sent.
37.Fn SSL_CTX_set_msg_callback_arg
38and
39.Fn SSL_set_msg_callback_arg
40can be used to set argument
41.Fa arg
42to the callback function, which is available for arbitrary application use.
43.Pp
44.Fn SSL_CTX_set_msg_callback
45and
46.Fn SSL_CTX_set_msg_callback_arg
47specify default settings that will be copied to new
48.Vt SSL
49objects by
50.Xr SSL_new 3 .
51.Fn SSL_set_msg_callback
52and
53.Fn SSL_set_msg_callback_arg
54modify the actual settings of an
55.Vt SSL
56object.
57Using a
58.Dv NULL
59pointer for
60.Fa cb
61disables the message callback.
62.Pp
63When
64.Fa cb
65is called by the SSL/TLS library for a protocol message,
66the function arguments have the following meaning:
67.Bl -tag -width Ds
68.It Fa write_p
69This flag is 0 when a protocol message has been received and 1 when a protocol
70message has been sent.
71.It Fa version
72The protocol version according to which the protocol message is
73interpreted by the library.
74Currently, this is one of
75.Dv SSL2_VERSION ,
76.Dv SSL3_VERSION
77and
78.Dv TLS1_VERSION
79(for SSL 2.0, SSL 3.0 and TLS 1.0, respectively).
80.It Fa content_type
81In the case of SSL 2.0, this is always 0.
82In the case of SSL 3.0 or TLS 1.0, this is one of the
83.Em ContentType
84values defined in the protocol specification
85.Po
86.Dq change_cipher_spec(20) ,
87.Dq alert(21) ,
88.Dq handshake(22) ;
89but never
90.Dq application_data(23)
91because the callback will only be called for protocol messages.
92.Pc
93.It Fa buf , Fa len
94.Fa buf
95points to a buffer containing the protocol message, which consists of
96.Fa len
97bytes.
98The buffer is no longer valid after the callback function has returned.
99.It Fa ssl
100The
101.Vt SSL
102object that received or sent the message.
103.It Fa arg
104The user-defined argument optionally defined by
105.Fn SSL_CTX_set_msg_callback_arg
106or
107.Fn SSL_set_msg_callback_arg .
108.El
109.Sh NOTES
110Protocol messages are passed to the callback function after decryption
111and fragment collection where applicable.
112(Thus record boundaries are not visible.)
113.Pp
114If processing a received protocol message results in an error,
115the callback function may not be called.
116For example, the callback function will never see messages that are considered
117too large to be processed.
118.Pp
119Due to automatic protocol version negotiation,
120.Fa version
121is not necessarily the protocol version used by the sender of the message:
122If a TLS 1.0 ClientHello message is received by an SSL 3.0-only server,
123.Fa version
124will be
125.Dv SSL3_VERSION .
126.Sh SEE ALSO
127.Xr ssl 3 ,
128.Xr SSL_new 3
129.Sh HISTORY
130.Fn SSL_CTX_set_msg_callback ,
131.Fn SSL_CTX_set_msg_callback_arg ,
132.Fn SSL_set_msg_callback
133and
134.Fn SSL_set_msg_callback_arg
135were added in OpenSSL 0.9.7.
diff --git a/src/lib/libssl/man/SSL_CTX_set_options.3 b/src/lib/libssl/man/SSL_CTX_set_options.3
new file mode 100644
index 0000000000..1818be0d86
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_set_options.3
@@ -0,0 +1,395 @@
1.\"
2.\" $OpenBSD: SSL_CTX_set_options.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_SET_OPTIONS 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_set_options ,
9.Nm SSL_set_options ,
10.Nm SSL_CTX_clear_options ,
11.Nm SSL_clear_options ,
12.Nm SSL_CTX_get_options ,
13.Nm SSL_get_options ,
14.Nm SSL_get_secure_renegotiation_support
15.Nd manipulate SSL options
16.Sh SYNOPSIS
17.In openssl/ssl.h
18.Ft long
19.Fn SSL_CTX_set_options "SSL_CTX *ctx" "long options"
20.Ft long
21.Fn SSL_set_options "SSL *ssl" "long options"
22.Ft long
23.Fn SSL_CTX_clear_options "SSL_CTX *ctx" "long options"
24.Ft long
25.Fn SSL_clear_options "SSL *ssl" "long options"
26.Ft long
27.Fn SSL_CTX_get_options "SSL_CTX *ctx"
28.Ft long
29.Fn SSL_get_options "SSL *ssl"
30.Ft long
31.Fn SSL_get_secure_renegotiation_support "SSL *ssl"
32.Sh DESCRIPTION
33Note: all these functions are implemented using macros.
34.Pp
35.Fn SSL_CTX_set_options
36adds the options set via bitmask in
37.Fa options
38to
39.Fa ctx .
40Options already set before are not cleared!
41.Pp
42.Fn SSL_set_options
43adds the options set via bitmask in
44.Fa options
45to
46.Fa ssl .
47Options already set before are not cleared!
48.Pp
49.Fn SSL_CTX_clear_options
50clears the options set via bitmask in
51.Fa options
52to
53.Fa ctx .
54.Pp
55.Fn SSL_clear_options
56clears the options set via bitmask in
57.Fa options
58to
59.Fa ssl .
60.Pp
61.Fn SSL_CTX_get_options
62returns the options set for
63.Fa ctx .
64.Pp
65.Fn SSL_get_options
66returns the options set for
67.Fa ssl .
68.Pp
69.Fn SSL_get_secure_renegotiation_support
70indicates whether the peer supports secure renegotiation.
71.Sh NOTES
72The behaviour of the SSL library can be changed by setting several options.
73The options are coded as bitmasks and can be combined by a bitwise OR
74operation (|).
75.Pp
76.Fn SSL_CTX_set_options
77and
78.Fn SSL_set_options
79affect the (external) protocol behaviour of the SSL library.
80The (internal) behaviour of the API can be changed by using the similar
81.Xr SSL_CTX_set_mode 3
82and
83.Xr SSL_set_mode 3
84functions.
85.Pp
86During a handshake, the option settings of the SSL object are used.
87When a new SSL object is created from a context using
88.Xr SSL_new 3 ,
89the current option setting is copied.
90Changes to
91.Fa ctx
92do not affect already created
93.Vt SSL
94objects.
95.Fn SSL_clear
96does not affect the settings.
97.Pp
98The following
99.Em bug workaround
100options are available:
101.Bl -tag -width Ds
102.It Dv SSL_OP_MICROSOFT_SESS_ID_BUG
103As of
104.Ox 5.8 ,
105this option has no effect.
106.It Dv SSL_OP_NETSCAPE_CHALLENGE_BUG
107As of
108.Ox 5.8 ,
109this option has no effect.
110.It Dv SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG
111As of OpenSSL 0.9.8q and 1.0.0c, this option has no effect.
112.It Dv SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG
113As of
114.Ox 5.8 ,
115this option has no effect.
116.It Dv SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER
117As of
118.Ox 5.8 ,
119this option has no effect.
120.It Dv SSL_OP_SAFARI_ECDHE_ECDSA_BUG
121As of
122.Ox 5.8 ,
123this option has no effect.
124.It Dv SSL_OP_SSLEAY_080_CLIENT_DH_BUG
125As of
126.Ox 5.8 ,
127this option has no effect.
128.It Dv SSL_OP_TLS_D5_BUG
129As of
130.Ox 5.8 ,
131this option has no effect.
132.It Dv SSL_OP_TLS_BLOCK_PADDING_BUG
133As of
134.Ox 5.8 ,
135this option has no effect.
136.It Dv SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS
137Disables a countermeasure against a SSL 3.0/TLS 1.0 protocol vulnerability
138affecting CBC ciphers, which cannot be handled by some broken SSL
139implementations.
140This option has no effect for connections using other ciphers.
141.It Dv SSL_OP_TLSEXT_PADDING
142Adds a padding extension to ensure the ClientHello size is never between 256
143and 511 bytes in length.
144This is needed as a workaround for some implementations.
145.It Dv SSL_OP_ALL
146All of the above bug workarounds.
147.El
148.Pp
149It is usually safe to use
150.Dv SSL_OP_ALL
151to enable the bug workaround options if compatibility with somewhat broken
152implementations is desired.
153.Pp
154The following
155.Em modifying
156options are available:
157.Bl -tag -width Ds
158.It Dv SSL_OP_TLS_ROLLBACK_BUG
159Disable version rollback attack detection.
160.Pp
161During the client key exchange, the client must send the same information
162about acceptable SSL/TLS protocol levels as during the first hello.
163Some clients violate this rule by adapting to the server's answer.
164(Example: the client sends a SSLv2 hello and accepts up to SSLv3.1=TLSv1,
165the server only understands up to SSLv3.
166In this case the client must still use the same SSLv3.1=TLSv1 announcement.
167Some clients step down to SSLv3 with respect to the server's answer and violate
168the version rollback protection.)
169.It Dv SSL_OP_SINGLE_DH_USE
170Always create a new key when using temporary/ephemeral DH parameters
171(see
172.Xr SSL_CTX_set_tmp_dh_callback 3 ) .
173This option must be used to prevent small subgroup attacks, when the DH
174parameters were not generated using
175.Dq strong
176primes (e.g., when using DSA-parameters, see
177.Xr openssl 1 ) .
178If
179.Dq strong
180primes were used, it is not strictly necessary to generate a new DH key during
181each handshake but it is also recommended.
182.Dv SSL_OP_SINGLE_DH_USE
183should therefore be enabled whenever temporary/ephemeral DH parameters are used.
184.It SSL_OP_EPHEMERAL_RSA
185Always use ephemeral (temporary) RSA key when doing RSA operations (see
186.Xr SSL_CTX_set_tmp_rsa_callback 3 ) .
187According to the specifications, this is only done when a RSA key can only be
188used for signature operations (namely under export ciphers with restricted RSA
189keylength).
190By setting this option, ephemeral RSA keys are always used.
191This option breaks compatibility with the SSL/TLS specifications and may lead
192to interoperability problems with clients and should therefore never be used.
193Ciphers with EDH (ephemeral Diffie-Hellman) key exchange should be used instead.
194.It Dv SSL_OP_CIPHER_SERVER_PREFERENCE
195When choosing a cipher, use the server's preferences instead of the client
196preferences.
197When not set, the SSL server will always follow the client's preferences.
198When set, the SSLv3/TLSv1 server will choose following its own preferences.
199Because of the different protocol, for SSLv2 the server will send its list of
200preferences to the client and the client chooses.
201.It Dv SSL_OP_NETSCAPE_CA_DN_BUG
202As of
203.Ox 5.8 ,
204this option has no effect.
205.It Dv SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG
206As of
207.Ox 5.8 ,
208this option has no effect.
209.It Dv SSL_OP_NO_SSLv2
210As of
211.Ox 5.6 ,
212this option has no effect as SSLv2 support has been removed.
213In previous versions it disabled use of the SSLv2 protocol.
214.It Dv SSL_OP_NO_SSLv3
215Do not use the SSLv3 protocol.
216.It Dv SSL_OP_NO_TLSv1
217Do not use the TLSv1.0 protocol.
218.It Dv SSL_OP_NO_TLSv1_1
219Do not use the TLSv1.1 protocol.
220.It Dv SSL_OP_NO_TLSv1_2
221Do not use the TLSv1.2 protocol.
222.It Dv SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION
223When performing renegotiation as a server, always start a new session (i.e.,
224session resumption requests are only accepted in the initial handshake).
225This option is not needed for clients.
226.It Dv SSL_OP_NO_TICKET
227Normally clients and servers will, where possible, transparently make use of
228RFC4507bis tickets for stateless session resumption.
229.Pp
230If this option is set this functionality is disabled and tickets will not be
231used by clients or servers.
232.It Dv SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION
233As of
234.Ox 5.6 ,
235this option has no effect.
236In previous versions it allowed legacy insecure renegotiation between OpenSSL
237and unpatched clients or servers.
238See the
239.Sx SECURE RENEGOTIATION
240section for more details.
241.It Dv SSL_OP_LEGACY_SERVER_CONNECT
242Allow legacy insecure renegotiation between OpenSSL and unpatched servers
243.Em only :
244this option is currently set by default.
245See the
246.Sx SECURE RENEGOTIATION
247section for more details.
248.El
249.Sh SECURE RENEGOTIATION
250OpenSSL 0.9.8m and later always attempts to use secure renegotiation as
251described in RFC5746.
252This counters the prefix attack described in CVE-2009-3555 and elsewhere.
253.Pp
254The deprecated and highly broken SSLv2 protocol does not support renegotiation
255at all; its use is
256.Em strongly
257discouraged.
258.Pp
259This attack has far-reaching consequences which application writers should be
260aware of.
261In the description below an implementation supporting secure renegotiation is
262referred to as
263.Dq patched .
264A server not supporting secure
265renegotiation is referred to as
266.Dq unpatched .
267.Pp
268The following sections describe the operations permitted by OpenSSL's secure
269renegotiation implementation.
270.Ss Patched client and server
271Connections and renegotiation are always permitted by OpenSSL implementations.
272.Ss Unpatched client and patched OpenSSL server
273The initial connection succeeds but client renegotiation is denied by the
274server with a
275.Em no_renegotiation
276warning alert if TLS v1.0 is used or a fatal
277.Em handshake_failure
278alert in SSL v3.0.
279.Pp
280If the patched OpenSSL server attempts to renegotiate a fatal
281.Em handshake_failure
282alert is sent.
283This is because the server code may be unaware of the unpatched nature of the
284client.
285.Pp
286.Em N.B.:
287a bug in OpenSSL clients earlier than 0.9.8m (all of which are unpatched) will
288result in the connection hanging if it receives a
289.Em no_renegotiation
290alert.
291OpenSSL versions 0.9.8m and later will regard a
292.Em no_renegotiation
293alert as fatal and respond with a fatal
294.Em handshake_failure
295alert.
296This is because the OpenSSL API currently has no provision to indicate to an
297application that a renegotiation attempt was refused.
298.Ss Patched OpenSSL client and unpatched server
299If the option
300.Dv SSL_OP_LEGACY_SERVER_CONNECT
301is set then initial connections and renegotiation between patched OpenSSL
302clients and unpatched servers succeeds.
303If neither option is set then initial connections to unpatched servers will
304fail.
305.Pp
306The option
307.Dv SSL_OP_LEGACY_SERVER_CONNECT
308is currently set by default even though it has security implications:
309otherwise it would be impossible to connect to unpatched servers (i.e., all of
310them initially) and this is clearly not acceptable.
311Renegotiation is permitted because this does not add any additional security
312issues: during an attack clients do not see any renegotiations anyway.
313.Pp
314As more servers become patched the option
315.Dv SSL_OP_LEGACY_SERVER_CONNECT
316will
317.Em not
318be set by default in a future version of OpenSSL.
319.Pp
320OpenSSL client applications wishing to ensure they can connect to unpatched
321servers should always
322.Em set
323.Dv SSL_OP_LEGACY_SERVER_CONNECT
324.Pp
325OpenSSL client applications that want to ensure they can
326.Em not
327connect to unpatched servers (and thus avoid any security issues) should always
328.Em clear
329.Dv SSL_OP_LEGACY_SERVER_CONNECT
330using
331.Fn SSL_CTX_clear_options
332or
333.Fn SSL_clear_options .
334.Sh RETURN VALUES
335.Fn SSL_CTX_set_options
336and
337.Fn SSL_set_options
338return the new options bitmask after adding
339.Fa options .
340.Pp
341.Fn SSL_CTX_clear_options
342and
343.Fn SSL_clear_options
344return the new options bitmask after clearing
345.Fa options .
346.Pp
347.Fn SSL_CTX_get_options
348and
349.Fn SSL_get_options
350return the current bitmask.
351.Pp
352.Fn SSL_get_secure_renegotiation_support
353returns 1 is the peer supports secure renegotiation and 0 if it does not.
354.Sh SEE ALSO
355.Xr openssl 1 ,
356.Xr ssl 3 ,
357.Xr SSL_clear 3 ,
358.Xr SSL_CTX_set_tmp_dh_callback 3 ,
359.Xr SSL_CTX_set_tmp_rsa_callback 3 ,
360.Xr SSL_new 3
361.Sh HISTORY
362.Dv SSL_OP_CIPHER_SERVER_PREFERENCE
363and
364.Dv SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION
365have been added in
366OpenSSL 0.9.7.
367.Pp
368.Dv SSL_OP_TLS_ROLLBACK_BUG
369has been added in OpenSSL 0.9.6 and was automatically enabled with
370.Dv SSL_OP_ALL .
371As of 0.9.7, it is no longer included in
372.Dv SSL_OP_ALL
373and must be explicitly set.
374.Pp
375.Dv SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS
376has been added in OpenSSL 0.9.6e.
377Versions up to OpenSSL 0.9.6c do not include the countermeasure that can be
378disabled with this option (in OpenSSL 0.9.6d, it was always enabled).
379.Pp
380.Fn SSL_CTX_clear_options
381and
382.Fn SSL_clear_options
383were first added in OpenSSL 0.9.8m.
384.Pp
385.Dv SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION ,
386.Dv SSL_OP_LEGACY_SERVER_CONNECT
387and the function
388.Fn SSL_get_secure_renegotiation_support
389were first added in OpenSSL 0.9.8m.
390.Pp
391.Dv SSL_OP_NO_SSLv2
392and
393.Dv SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION
394were changed to have no effect in
395.Ox 5.6 .
diff --git a/src/lib/libssl/man/SSL_CTX_set_psk_client_callback.3 b/src/lib/libssl/man/SSL_CTX_set_psk_client_callback.3
new file mode 100644
index 0000000000..0325a9405a
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_set_psk_client_callback.3
@@ -0,0 +1,68 @@
1.\"
2.\" $OpenBSD: SSL_CTX_set_psk_client_callback.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_SET_PSK_CLIENT_CALLBACK 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_set_psk_client_callback ,
9.Nm SSL_set_psk_client_callback
10.Nd set PSK client callback
11.Sh SYNOPSIS
12.In openssl/ssl.h
13.Ft void
14.Fo SSL_CTX_set_psk_client_callback
15.Fa "SSL_CTX *ctx"
16.Fa "unsigned int (*callback)(SSL *ssl, const char *hint, char *identity, \
17unsigned int max_identity_len, unsigned char *psk, unsigned int max_psk_len)"
18.Fc
19.Ft void
20.Fo SSL_set_psk_client_callback
21.Fa "SSL *ssl"
22.Fa "unsigned int (*callback)(SSL *ssl, const char *hint, char *identity, \
23unsigned int max_identity_len, unsigned char *psk, unsigned int max_psk_len)"
24.Fc
25.Sh DESCRIPTION
26A client application must provide a callback function which is called
27when the client is sending the ClientKeyExchange message to the server.
28.Pp
29The purpose of the callback function is to select the PSK identity and
30the pre-shared key to use during the connection setup phase.
31.Pp
32The callback is set using functions
33.Fn SSL_CTX_set_psk_client_callback
34or
35.Fn SSL_set_psk_client_callback .
36The callback function is given the connection in parameter
37.Fa ssl ,
38a
39.Dv NULL Ns
40-terminated PSK identity hint sent by the server in parameter
41.Fa hint ,
42a buffer
43.Fa identity
44of length
45.Fa max_identity_len
46bytes where the resulting
47.Dv NULL Ns
48-terminated identity is to be stored, and a buffer
49.Fa psk
50of
51length
52.Fa max_psk_len
53bytes where the resulting pre-shared key is to be stored.
54.Sh NOTES
55Note that parameter
56.Fa hint
57given to the callback may be
58.Dv NULL .
59.Sh RETURN VALUES
60Return values from the client callback are interpreted as follows:
61.Pp
62On success (callback found a PSK identity and a pre-shared key to use)
63the length (> 0) of
64.Fa psk
65in bytes is returned.
66.Pp
67Otherwise or on errors callback should return 0.
68In this case the connection setup fails.
diff --git a/src/lib/libssl/man/SSL_CTX_set_quiet_shutdown.3 b/src/lib/libssl/man/SSL_CTX_set_quiet_shutdown.3
new file mode 100644
index 0000000000..e840661125
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_set_quiet_shutdown.3
@@ -0,0 +1,115 @@
1.\"
2.\" $OpenBSD: SSL_CTX_set_quiet_shutdown.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_SET_QUIET_SHUTDOWN 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_set_quiet_shutdown ,
9.Nm SSL_CTX_get_quiet_shutdown ,
10.Nm SSL_set_quiet_shutdown ,
11.Nm SSL_get_quiet_shutdown
12.Nd manipulate shutdown behaviour
13.Sh SYNOPSIS
14.In openssl/ssl.h
15.Ft void
16.Fn SSL_CTX_set_quiet_shutdown "SSL_CTX *ctx" "int mode"
17.Ft int
18.Fn SSL_CTX_get_quiet_shutdown "const SSL_CTX *ctx"
19.Ft void
20.Fn SSL_set_quiet_shutdown "SSL *ssl" "int mode"
21.Ft int
22.Fn SSL_get_quiet_shutdown "const SSL *ssl"
23.Sh DESCRIPTION
24.Fn SSL_CTX_set_quiet_shutdown
25sets the
26.Dq quiet shutdown
27flag for
28.Fa ctx
29to be
30.Fa mode .
31.Vt SSL
32objects created from
33.Fa ctx
34inherit the
35.Fa mode
36valid at the time
37.Xr SSL_new 3
38is called.
39.Fa mode
40may be 0 or 1.
41.Pp
42.Fn SSL_CTX_get_quiet_shutdown
43returns the
44.Dq quiet shutdown
45setting of
46.Fa ctx .
47.Pp
48.Fn SSL_set_quiet_shutdown
49sets the
50.Dq quiet shutdown
51flag for
52.Fa ssl
53to be
54.Fa mode .
55The setting stays valid until
56.Fa ssl
57is removed with
58.Xr SSL_free 3
59or
60.Fn SSL_set_quiet_shutdown
61is called again.
62It is not changed when
63.Xr SSL_clear 3
64is called.
65.Fa mode
66may be 0 or 1.
67.Pp
68.Fn SSL_get_quiet_shutdown
69returns the
70.Dq quiet shutdown
71setting of
72.Fa ssl .
73.Sh NOTES
74Normally when a SSL connection is finished, the parties must send out
75.Dq close notify
76alert messages using
77.Xr SSL_shutdown 3
78for a clean shutdown.
79.Pp
80When setting the
81.Dq quiet shutdown
82flag to 1,
83.Xr SSL_shutdown 3
84will set the internal flags to
85.Dv SSL_SENT_SHUTDOWN Ns | Ns Dv SSL_RECEIVED_SHUTDOWN
86.Po
87.Xr SSL_shutdown 3
88then behaves like
89.Xr SSL_set_shutdown 3
90called with
91.Dv SSL_SENT_SHUTDOWN Ns | Ns Dv SSL_RECEIVED_SHUTDOWN
92.Pc .
93The session is thus considered to be shut down, but no
94.Dq close notify
95alert is sent to the peer.
96This behaviour violates the TLS standard.
97.Pp
98The default is normal shutdown behaviour as described by the TLS standard.
99.Sh RETURN VALUES
100.Fn SSL_CTX_set_quiet_shutdown
101and
102.Fn SSL_set_quiet_shutdown
103do not return diagnostic information.
104.Pp
105.Fn SSL_CTX_get_quiet_shutdown
106and
107.Fn SSL_get_quiet_shutdown
108return the current setting.
109.Sh SEE ALSO
110.Xr ssl 3 ,
111.Xr SSL_clear 3 ,
112.Xr SSL_free 3 ,
113.Xr SSL_new 3 ,
114.Xr SSL_set_shutdown 3 ,
115.Xr SSL_shutdown 3
diff --git a/src/lib/libssl/man/SSL_CTX_set_session_cache_mode.3 b/src/lib/libssl/man/SSL_CTX_set_session_cache_mode.3
new file mode 100644
index 0000000000..5ba6728a8a
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_set_session_cache_mode.3
@@ -0,0 +1,143 @@
1.\"
2.\" $OpenBSD: SSL_CTX_set_session_cache_mode.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_SET_SESSION_CACHE_MODE 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_set_session_cache_mode ,
9.Nm SSL_CTX_get_session_cache_mode
10.Nd enable/disable session caching
11.Sh SYNOPSIS
12.In openssl/ssl.h
13.Ft long
14.Fn SSL_CTX_set_session_cache_mode "SSL_CTX ctx" "long mode"
15.Ft long
16.Fn SSL_CTX_get_session_cache_mode "SSL_CTX ctx"
17.Sh DESCRIPTION
18.Fn SSL_CTX_set_session_cache_mode
19enables/disables session caching by setting the operational mode for
20.Ar ctx
21to
22.Ar mode .
23.Pp
24.Fn SSL_CTX_get_session_cache_mode
25returns the currently used cache mode.
26.Sh NOTES
27The OpenSSL library can store/retrieve SSL/TLS sessions for later reuse.
28The sessions can be held in memory for each
29.Fa ctx ,
30if more than one
31.Vt SSL_CTX
32object is being maintained, the sessions are unique for each
33.Vt SSL_CTX
34object.
35.Pp
36In order to reuse a session, a client must send the session's id to the server.
37It can only send exactly one id.
38The server then either agrees to reuse the session or it starts a full
39handshake (to create a new session).
40.Pp
41A server will lookup up the session in its internal session storage.
42If the session is not found in internal storage or lookups for the internal
43storage have been deactivated
44.Pq Dv SSL_SESS_CACHE_NO_INTERNAL_LOOKUP ,
45the server will try the external storage if available.
46.Pp
47Since a client may try to reuse a session intended for use in a different
48context, the session id context must be set by the server (see
49.Xr SSL_CTX_set_session_id_context 3 ) .
50.Pp
51The following session cache modes and modifiers are available:
52.Bl -tag -width Ds
53.It Dv SSL_SESS_CACHE_OFF
54No session caching for client or server takes place.
55.It Dv SSL_SESS_CACHE_CLIENT
56Client sessions are added to the session cache.
57As there is no reliable way for the OpenSSL library to know whether a session
58should be reused or which session to choose (due to the abstract BIO layer the
59SSL engine does not have details about the connection),
60the application must select the session to be reused by using the
61.Xr SSL_set_session 3
62function.
63This option is not activated by default.
64.It Dv SSL_SESS_CACHE_SERVER
65Server sessions are added to the session cache.
66When a client proposes a session to be reused, the server looks for the
67corresponding session in (first) the internal session cache (unless
68.Dv SSL_SESS_CACHE_NO_INTERNAL_LOOKUP
69is set), then (second) in the external cache if available.
70If the session is found, the server will try to reuse the session.
71This is the default.
72.It Dv SSL_SESS_CACHE_BOTH
73Enable both
74.Dv SSL_SESS_CACHE_CLIENT
75and
76.Dv SSL_SESS_CACHE_SERVER
77at the same time.
78.It Dv SSL_SESS_CACHE_NO_AUTO_CLEAR
79Normally the session cache is checked for expired sessions every 255
80connections using the
81.Xr SSL_CTX_flush_sessions 3
82function.
83Since this may lead to a delay which cannot be controlled,
84the automatic flushing may be disabled and
85.Xr SSL_CTX_flush_sessions 3
86can be called explicitly by the application.
87.It Dv SSL_SESS_CACHE_NO_INTERNAL_LOOKUP
88By setting this flag, session-resume operations in an SSL/TLS server will not
89automatically look up sessions in the internal cache,
90even if sessions are automatically stored there.
91If external session caching callbacks are in use,
92this flag guarantees that all lookups are directed to the external cache.
93As automatic lookup only applies for SSL/TLS servers,
94the flag has no effect on clients.
95.It Dv SSL_SESS_CACHE_NO_INTERNAL_STORE
96Depending on the presence of
97.Dv SSL_SESS_CACHE_CLIENT
98and/or
99.Dv SSL_SESS_CACHE_SERVER ,
100sessions negotiated in an SSL/TLS handshake may be cached for possible reuse.
101Normally a new session is added to the internal cache as well as any external
102session caching (callback) that is configured for the
103.Vt SSL_CTX .
104This flag will prevent sessions being stored in the internal cache
105(though the application can add them manually using
106.Xr SSL_CTX_add_session 3 ) .
107Note:
108in any SSL/TLS servers where external caching is configured, any successful
109session lookups in the external cache (e.g., for session-resume requests) would
110normally be copied into the local cache before processing continues \(en this
111flag prevents these additions to the internal cache as well.
112.It Dv SSL_SESS_CACHE_NO_INTERNAL
113Enable both
114.Dv SSL_SESS_CACHE_NO_INTERNAL_LOOKUP
115and
116.Dv SSL_SESS_CACHE_NO_INTERNAL_STORE
117at the same time.
118.El
119.Pp
120The default mode is
121.Dv SSL_SESS_CACHE_SERVER .
122.Sh RETURN VALUES
123.Fn SSL_CTX_set_session_cache_mode
124returns the previously set cache mode.
125.Pp
126.Fn SSL_CTX_get_session_cache_mode
127returns the currently set cache mode.
128.Sh SEE ALSO
129.Xr ssl 3 ,
130.Xr SSL_CTX_add_session 3 ,
131.Xr SSL_CTX_flush_sessions 3 ,
132.Xr SSL_CTX_sess_number 3 ,
133.Xr SSL_CTX_sess_set_cache_size 3 ,
134.Xr SSL_CTX_sess_set_get_cb 3 ,
135.Xr SSL_CTX_set_session_id_context 3 ,
136.Xr SSL_CTX_set_timeout 3 ,
137.Xr SSL_session_reused 3 ,
138.Xr SSL_set_session 3
139.Sh HISTORY
140.Dv SSL_SESS_CACHE_NO_INTERNAL_STORE
141and
142.Dv SSL_SESS_CACHE_NO_INTERNAL
143were introduced in OpenSSL 0.9.6h.
diff --git a/src/lib/libssl/man/SSL_CTX_set_session_id_context.3 b/src/lib/libssl/man/SSL_CTX_set_session_id_context.3
new file mode 100644
index 0000000000..37028cc6ca
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_set_session_id_context.3
@@ -0,0 +1,105 @@
1.\"
2.\" $OpenBSD: SSL_CTX_set_session_id_context.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_SET_SESSION_ID_CONTEXT 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_set_session_id_context ,
9.Nm SSL_set_session_id_context
10.Nd set context within which session can be reused (server side only)
11.Sh SYNOPSIS
12.In openssl/ssl.h
13.Ft int
14.Fo SSL_CTX_set_session_id_context
15.Fa "SSL_CTX *ctx"
16.Fa "const unsigned char *sid_ctx"
17.Fa "unsigned int sid_ctx_len"
18.Fc
19.Ft int
20.Fo SSL_set_session_id_context
21.Fa "SSL *ssl"
22.Fa "const unsigned char *sid_ctx"
23.Fa "unsigned int sid_ctx_len"
24.Fc
25.Sh DESCRIPTION
26.Fn SSL_CTX_set_session_id_context
27sets the context
28.Fa sid_ctx
29of length
30.Fa sid_ctx_len
31within which a session can be reused for the
32.Fa ctx
33object.
34.Pp
35.Fn SSL_set_session_id_context
36sets the context
37.Fa sid_ctx
38of length
39.Fa sid_ctx_len
40within which a session can be reused for the
41.Fa ssl
42object.
43.Sh NOTES
44Sessions are generated within a certain context.
45When exporting/importing sessions with
46.Xr i2d_SSL_SESSION 3
47and
48.Xr d2i_SSL_SESSION 3 ,
49it would be possible to re-import a session generated from another context
50(e.g., another application), which might lead to malfunctions.
51Therefore each application must set its own session id context
52.Fa sid_ctx
53which is used to distinguish the contexts and is stored in exported sessions.
54The
55.Fa sid_ctx
56can be any kind of binary data with a given length; it is therefore possible
57to use, for instance, the name of the application, the hostname, the service
58name...
59.Pp
60The session id context becomes part of the session.
61The session id context is set by the SSL/TLS server.
62The
63.Fn SSL_CTX_set_session_id_context
64and
65.Fn SSL_set_session_id_context
66functions are therefore only useful on the server side.
67.Pp
68OpenSSL clients will check the session id context returned by the server when
69reusing a session.
70.Pp
71The maximum length of the
72.Fa sid_ctx
73is limited to
74.Dv SSL_MAX_SSL_SESSION_ID_LENGTH .
75.Sh WARNINGS
76If the session id context is not set on an SSL/TLS server and client
77certificates are used, stored sessions will not be reused but a fatal error
78will be flagged and the handshake will fail.
79.Pp
80If a server returns a different session id context to an OpenSSL client
81when reusing a session, an error will be flagged and the handshake will
82fail.
83OpenSSL servers will always return the correct session id context,
84as an OpenSSL server checks the session id context itself before reusing
85a session as described above.
86.Sh RETURN VALUES
87.Fn SSL_CTX_set_session_id_context
88and
89.Fn SSL_set_session_id_context
90return the following values:
91.Bl -tag -width Ds
92.It 0
93The length
94.Fa sid_ctx_len
95of the session id context
96.Fa sid_ctx
97exceeded
98the maximum allowed length of
99.Dv SSL_MAX_SSL_SESSION_ID_LENGTH .
100The error is logged to the error stack.
101.It 1
102The operation succeeded.
103.El
104.Sh SEE ALSO
105.Xr ssl 3
diff --git a/src/lib/libssl/man/SSL_CTX_set_ssl_version.3 b/src/lib/libssl/man/SSL_CTX_set_ssl_version.3
new file mode 100644
index 0000000000..3359f195b4
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_set_ssl_version.3
@@ -0,0 +1,81 @@
1.\"
2.\" $OpenBSD: SSL_CTX_set_ssl_version.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_SET_SSL_VERSION 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_set_ssl_version ,
9.Nm SSL_set_ssl_method ,
10.Nm SSL_get_ssl_method
11.Nd choose a new TLS/SSL method
12.Sh SYNOPSIS
13.In openssl/ssl.h
14.Ft int
15.Fn SSL_CTX_set_ssl_version "SSL_CTX *ctx" "const SSL_METHOD *method"
16.Ft int
17.Fn SSL_set_ssl_method "SSL *s" "const SSL_METHOD *method"
18.Ft const SSL_METHOD *
19.Fn SSL_get_ssl_method "SSL *ssl"
20.Sh DESCRIPTION
21.Fn SSL_CTX_set_ssl_version
22sets a new default TLS/SSL
23.Fa method
24for
25.Vt SSL
26objects newly created from this
27.Fa ctx .
28.Vt SSL
29objects already created with
30.Xr SSL_new 3
31are not affected, except when
32.Xr SSL_clear 3
33is called.
34.Pp
35.Fn SSL_set_ssl_method
36sets a new TLS/SSL
37.Fa method
38for a particular
39.Vt SSL
40object
41.Fa s .
42It may be reset when
43.Xr SSL_clear 3
44is called.
45.Pp
46.Fn SSL_get_ssl_method
47returns a function pointer to the TLS/SSL method set in
48.Fa ssl .
49.Sh NOTES
50The available
51.Fa method
52choices are described in
53.Xr SSL_CTX_new 3 .
54.Pp
55When
56.Xr SSL_clear 3
57is called and no session is connected to an
58.Vt SSL
59object, the method of the
60.Vt SSL
61object is reset to the method currently set in the corresponding
62.Vt SSL_CTX
63object.
64.Sh RETURN VALUES
65The following return values can occur for
66.Fn SSL_CTX_set_ssl_version
67and
68.Fn SSL_set_ssl_method :
69.Bl -tag -width Ds
70.It 0
71The new choice failed.
72Check the error stack to find out the reason.
73.It 1
74The operation succeeded.
75.El
76.Sh SEE ALSO
77.Xr ssl 3 ,
78.Xr SSL_clear 3 ,
79.Xr SSL_CTX_new 3 ,
80.Xr SSL_new 3 ,
81.Xr SSL_set_connect_state 3
diff --git a/src/lib/libssl/man/SSL_CTX_set_timeout.3 b/src/lib/libssl/man/SSL_CTX_set_timeout.3
new file mode 100644
index 0000000000..d8d699352e
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_set_timeout.3
@@ -0,0 +1,65 @@
1.\"
2.\" $OpenBSD: SSL_CTX_set_timeout.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_SET_TIMEOUT 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_set_timeout ,
9.Nm SSL_CTX_get_timeout
10.Nd manipulate timeout values for session caching
11.Sh SYNOPSIS
12.In openssl/ssl.h
13.Ft long
14.Fn SSL_CTX_set_timeout "SSL_CTX *ctx" "long t"
15.Ft long
16.Fn SSL_CTX_get_timeout "SSL_CTX *ctx"
17.Sh DESCRIPTION
18.Fn SSL_CTX_set_timeout
19sets the timeout for newly created sessions for
20.Fa ctx
21to
22.Fa t .
23The timeout value
24.Fa t
25must be given in seconds.
26.Pp
27.Fn SSL_CTX_get_timeout
28returns the currently set timeout value for
29.Fa ctx .
30.Sh NOTES
31Whenever a new session is created, it is assigned a maximum lifetime.
32This lifetime is specified by storing the creation time of the session and the
33timeout value valid at this time.
34If the actual time is later than creation time plus timeout,
35the session is not reused.
36.Pp
37Due to this realization, all sessions behave according to the timeout value
38valid at the time of the session negotiation.
39Changes of the timeout value do not affect already established sessions.
40.Pp
41The expiration time of a single session can be modified using the
42.Xr SSL_SESSION_get_time 3
43family of functions.
44.Pp
45Expired sessions are removed from the internal session cache, whenever
46.Xr SSL_CTX_flush_sessions 3
47is called, either directly by the application or automatically (see
48.Xr SSL_CTX_set_session_cache_mode 3 ) .
49.Pp
50The default value for session timeout is decided on a per-protocol basis; see
51.Xr SSL_get_default_timeout 3 .
52All currently supported protocols have the same default timeout value of 300
53seconds.
54.Sh RETURN VALUES
55.Fn SSL_CTX_set_timeout
56returns the previously set timeout value.
57.Pp
58.Fn SSL_CTX_get_timeout
59returns the currently set timeout value.
60.Sh SEE ALSO
61.Xr ssl 3 ,
62.Xr SSL_CTX_flush_sessions 3 ,
63.Xr SSL_CTX_set_session_cache_mode 3 ,
64.Xr SSL_get_default_timeout 3 ,
65.Xr SSL_SESSION_get_time 3
diff --git a/src/lib/libssl/man/SSL_CTX_set_tmp_dh_callback.3 b/src/lib/libssl/man/SSL_CTX_set_tmp_dh_callback.3
new file mode 100644
index 0000000000..ad734839a9
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_set_tmp_dh_callback.3
@@ -0,0 +1,235 @@
1.\"
2.\" $OpenBSD: SSL_CTX_set_tmp_dh_callback.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_SET_TMP_DH_CALLBACK 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_set_tmp_dh_callback ,
9.Nm SSL_CTX_set_tmp_dh ,
10.Nm SSL_set_tmp_dh_callback ,
11.Nm SSL_set_tmp_dh
12.Nd handle DH keys for ephemeral key exchange
13.Sh SYNOPSIS
14.In openssl/ssl.h
15.Ft void
16.Fo SSL_CTX_set_tmp_dh_callback
17.Fa "SSL_CTX *ctx"
18.Fa "DH *(*tmp_dh_callback)(SSL *ssl, int is_export, int keylength)"
19.Fc
20.Ft long
21.Fn SSL_CTX_set_tmp_dh "SSL_CTX *ctx" "DH *dh"
22.Ft void
23.Fo SSL_set_tmp_dh_callback
24.Fa "SSL *ssl"
25.Fa "DH *(*tmp_dh_callback)(SSL *ssl, int is_export, int keylength"
26.Fc
27.Ft long
28.Fn SSL_set_tmp_dh "SSL *ssl" "DH *dh"
29.Sh DESCRIPTION
30.Fn SSL_CTX_set_tmp_dh_callback
31sets the callback function for
32.Fa ctx
33to be used when a DH parameters are required to
34.Fa tmp_dh_callback .
35The callback is inherited by all
36.Vt ssl
37objects created from
38.Fa ctx .
39.Pp
40.Fn SSL_CTX_set_tmp_dh
41sets DH parameters to be used to be
42.Sy dh Ns .
43The key is inherited by all
44.Fa ssl
45objects created from
46.Fa ctx .
47.Pp
48.Fn SSL_set_tmp_dh_callback
49sets the callback only for
50.Fa ssl .
51.Pp
52.Fn SSL_set_tmp_dh
53sets the parameters only for
54.Fa ssl .
55.Pp
56These functions apply to SSL/TLS servers only.
57.Sh NOTES
58When using a cipher with RSA authentication,
59an ephemeral DH key exchange can take place.
60Ciphers with DSA keys always use ephemeral DH keys as well.
61In these cases, the session data are negotiated using the ephemeral/temporary
62DH key and the key supplied and certified by the certificate chain is only used
63for signing.
64Anonymous ciphers (without a permanent server key) also use ephemeral DH keys.
65.Pp
66Using ephemeral DH key exchange yields forward secrecy,
67as the connection can only be decrypted when the DH key is known.
68By generating a temporary DH key inside the server application that is lost
69when the application is left, it becomes impossible for an attacker to decrypt
70past sessions, even if he gets hold of the normal (certified) key,
71as this key was only used for signing.
72.Pp
73In order to perform a DH key exchange the server must use a DH group
74(DH parameters) and generate a DH key.
75The server will always generate a new DH key during the negotiation,
76when the DH parameters are supplied via callback and/or when the
77.Dv SSL_OP_SINGLE_DH_USE
78option of
79.Xr SSL_CTX_set_options 3
80is set.
81It will immediately create a DH key, when DH parameters are supplied via
82.Fn SSL_CTX_set_tmp_dh
83and
84.Dv SSL_OP_SINGLE_DH_USE
85is not set.
86In this case, it may happen that a key is generated on initialization without
87later being needed, while on the other hand the computer time during the
88negotiation is being saved.
89.Pp
90If
91.Dq strong
92primes were used to generate the DH parameters, it is not strictly necessary to
93generate a new key for each handshake but it does improve forward secrecy.
94If it is not assured that
95.Dq strong
96primes were used (see especially the section about DSA parameters below),
97.Dv SSL_OP_SINGLE_DH_USE
98must be used in order to prevent small subgroup attacks.
99Always using
100.Dv SSL_OP_SINGLE_DH_USE
101has an impact on the computer time needed during negotiation,
102but it is not very large,
103so application authors/users should consider always enabling this option.
104.Pp
105As generating DH parameters is extremely time consuming, an application should
106not generate the parameters on the fly but supply the parameters.
107DH parameters can be reused,
108as the actual key is newly generated during the negotiation.
109The risk in reusing DH parameters is that an attacker may specialize on a very
110often used DH group.
111Applications should therefore generate their own DH parameters during the
112installation process using the openssl
113.Xr openssl 1
114application.
115In order to reduce the computer time needed for this generation,
116it is possible to use DSA parameters instead (see
117.Xr openssl 1 ) ,
118but in this case
119.Dv SSL_OP_SINGLE_DH_USE
120is mandatory.
121.Pp
122Application authors may compile in DH parameters.
123Files
124.Pa dh512.pem ,
125.Pa dh1024.pem ,
126.Pa dh2048.pem ,
127and
128.Pa dh4096.pem
129in the
130.Pa apps
131directory of the current version of the OpenSSL distribution contain the
132.Sq SKIP
133DH parameters,
134which use safe primes and were generated verifiably pseudo-randomly.
135These files can be converted into C code using the
136.Fl C
137option of the
138.Xr openssl 1
139application.
140Authors may also generate their own set of parameters using
141.Xr openssl 1 ,
142but a user may not be sure how the parameters were generated.
143The generation of DH parameters during installation is therefore recommended.
144.Pp
145An application may either directly specify the DH parameters or can supply the
146DH parameters via a callback function.
147The callback approach has the advantage that the callback may supply DH
148parameters for different key lengths.
149.Pp
150The
151.Fa tmp_dh_callback
152is called with the
153.Fa keylength
154needed and the
155.Fa is_export
156information.
157The
158.Fa is_export
159flag is set when the ephemeral DH key exchange is performed with an export
160cipher.
161.Sh RETURN VALUES
162.Fn SSL_CTX_set_tmp_dh_callback
163and
164.Fn SSL_set_tmp_dh_callback
165do not return diagnostic output.
166.Pp
167.Fn SSL_CTX_set_tmp_dh
168and
169.Fn SSL_set_tmp_dh
170do return 1 on success and 0 on failure.
171Check the error queue to find out the reason of failure.
172.Sh EXAMPLES
173Handle DH parameters for key lengths of 512 and 1024 bits.
174(Error handling partly left out.)
175.Bd -literal
176\&...
177/* Set up ephemeral DH stuff */
178DH *dh_512 = NULL;
179DH *dh_1024 = NULL;
180FILE *paramfile;
181
182\&...
183
184/* "openssl dhparam -out dh_param_512.pem -2 512" */
185paramfile = fopen("dh_param_512.pem", "r");
186if (paramfile) {
187 dh_512 = PEM_read_DHparams(paramfile, NULL, NULL, NULL);
188 fclose(paramfile);
189}
190/* "openssl dhparam -out dh_param_1024.pem -2 1024" */
191paramfile = fopen("dh_param_1024.pem", "r");
192if (paramfile) {
193 dh_1024 = PEM_read_DHparams(paramfile, NULL, NULL, NULL);
194 fclose(paramfile);
195}
196
197\&...
198
199/* "openssl dhparam -C -2 512" etc... */
200DH *get_dh512() { ... }
201DH *get_dh1024() { ... }
202
203DH *
204tmp_dh_callback(SSL *s, int is_export, int keylength)
205{
206 DH *dh_tmp=NULL;
207
208 switch (keylength) {
209 case 512:
210 if (!dh_512)
211 dh_512 = get_dh512();
212 dh_tmp = dh_512;
213 break;
214 case 1024:
215 if (!dh_1024)
216 dh_1024 = get_dh1024();
217 dh_tmp = dh_1024;
218 break;
219 default:
220 /*
221 * Generating a key on the fly is very costly,
222 * so use what is there
223 */
224 setup_dh_parameters_like_above();
225 }
226
227 return(dh_tmp);
228}
229.Ed
230.Sh SEE ALSO
231.Xr openssl 1 ,
232.Xr ssl 3 ,
233.Xr SSL_CTX_set_cipher_list 3 ,
234.Xr SSL_CTX_set_options 3 ,
235.Xr SSL_CTX_set_tmp_rsa_callback 3
diff --git a/src/lib/libssl/man/SSL_CTX_set_tmp_rsa_callback.3 b/src/lib/libssl/man/SSL_CTX_set_tmp_rsa_callback.3
new file mode 100644
index 0000000000..bf68f49206
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_set_tmp_rsa_callback.3
@@ -0,0 +1,231 @@
1.\"
2.\" $OpenBSD: SSL_CTX_set_tmp_rsa_callback.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_SET_TMP_RSA_CALLBACK.POD 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_set_tmp_rsa_callback ,
9.Nm SSL_CTX_set_tmp_rsa ,
10.Nm SSL_CTX_need_tmp_rsa ,
11.Nm SSL_set_tmp_rsa_callback ,
12.Nm SSL_set_tmp_rsa ,
13.Nm SSL_need_tmp_rsa
14.Nd handle RSA keys for ephemeral key exchange
15.Sh SYNOPSIS
16.In openssl/ssl.h
17.Ft void
18.Fo SSL_CTX_set_tmp_rsa_callback
19.Fa "SSL_CTX *ctx"
20.Fa "RSA *(*tmp_rsa_callback)(SSL *ssl, int is_export, int keylength)"
21.Fc
22.Ft long
23.Fn SSL_CTX_set_tmp_rsa "SSL_CTX *ctx" "RSA *rsa"
24.Ft long
25.Fn SSL_CTX_need_tmp_rsa "SSL_CTX *ctx"
26.Ft void
27.Fo SSL_set_tmp_rsa_callback
28.Fa "SSL_CTX *ctx"
29.Fa "RSA *(*tmp_rsa_callback)(SSL *ssl, int is_export, int keylength)"
30.Fc
31.Ft long
32.Fn SSL_set_tmp_rsa "SSL *ssl" "RSA *rsa"
33.Ft long
34.Fn SSL_need_tmp_rsa "SSL *ssl"
35.Ft RSA *
36.Fn "(*tmp_rsa_callback)" "SSL *ssl" "int is_export" "int keylength"
37.Sh DESCRIPTION
38.Fn SSL_CTX_set_tmp_rsa_callback
39sets the callback function for
40.Fa ctx
41to be used when a temporary/ephemeral RSA key is required to
42.Fa tmp_rsa_callback .
43The callback is inherited by all
44.Vt SSL
45objects newly created from
46.Fa ctx
47with
48.Xr SSL_new 3 .
49Already created SSL objects are not affected.
50.Pp
51.Fn SSL_CTX_set_tmp_rsa
52sets the temporary/ephemeral RSA key to be used to be
53.Fa rsa .
54The key is inherited by all
55.Vt SSL
56objects newly created from
57.Fa ctx
58with
59.Xr SSL_new 3 .
60Already created SSL objects are not affected.
61.Pp
62.Fn SSL_CTX_need_tmp_rsa
63returns 1,
64if a temporary/ephemeral RSA key is needed for RSA-based strength-limited
65.Sq exportable
66ciphersuites because a RSA key with a keysize larger than 512 bits is installed.
67.Pp
68.Fn SSL_set_tmp_rsa_callback
69sets the callback only for
70.Fa ssl .
71.Pp
72.Fn SSL_set_tmp_rsa
73sets the key only for
74.Fa ssl .
75.Pp
76.Fn SSL_need_tmp_rsa
77returns 1,
78if a temporary/ephemeral RSA key is needed for RSA-based strength-limited
79.Sq exportable
80ciphersuites because a RSA key with a keysize larger than 512 bits is installed.
81.Pp
82These functions apply to SSL/TLS servers only.
83.Sh NOTES
84When using a cipher with RSA authentication,
85an ephemeral RSA key exchange can take place.
86In this case the session data are negotiated using the ephemeral/temporary RSA
87key and the RSA key supplied and certified by the certificate chain is only
88used for signing.
89.Pp
90Under previous export restrictions, ciphers with RSA keys shorter (512 bits)
91than the usual key length of 1024 bits were created.
92To use these ciphers with RSA keys of usual length, an ephemeral key exchange
93must be performed, as the normal (certified) key cannot be directly used.
94.Pp
95Using ephemeral RSA key exchange yields forward secrecy,
96as the connection can only be decrypted when the RSA key is known.
97By generating a temporary RSA key inside the server application that is lost
98when the application is left, it becomes impossible for an attacker to decrypt
99past sessions, even if he gets hold of the normal (certified) RSA key,
100as this key was used for signing only.
101The downside is that creating a RSA key is computationally expensive.
102.Pp
103Additionally, the use of ephemeral RSA key exchange is only allowed in the TLS
104standard when the RSA key can be used for signing only, that is,
105for export ciphers.
106Using ephemeral RSA key exchange for other purposes violates the standard and
107can break interoperability with clients.
108It is therefore strongly recommended to not use ephemeral RSA key exchange and
109use EDH (Ephemeral Diffie-Hellman) key exchange instead in order to achieve
110forward secrecy (see
111.Xr SSL_CTX_set_tmp_dh_callback 3 ) .
112.Pp
113On OpenSSL servers ephemeral RSA key exchange is therefore disabled by default
114and must be explicitly enabled using the
115.Dv SSL_OP_EPHEMERAL_RSA
116option of
117.Xr SSL_CTX_set_options 3 ,
118violating the TLS/SSL
119standard.
120When ephemeral RSA key exchange is required for export ciphers,
121it will automatically be used without this option!
122.Pp
123An application may either directly specify the key or can supply the key via
124a callback function.
125The callback approach has the advantage that the callback may generate the key
126only in case it is actually needed.
127However, as the generation of a RSA key is costly,
128it will lead to a significant delay in the handshake procedure.
129Another advantage of the callback function is that it can supply keys of
130different size (e.g., for
131.Dv SSL_OP_EPHEMERAL_RSA
132usage) while the explicit setting of the key is only useful for key size of
133512 bits to satisfy the export restricted ciphers and does give away key length
134if a longer key would be allowed.
135.Pp
136The
137.Fa tmp_rsa_callback
138is called with the
139.Fa keylength
140needed and the
141.Fa is_export
142information.
143The
144.Fa is_export
145flag is set when the ephemeral RSA key exchange is performed with an export
146cipher.
147.Sh RETURN VALUES
148.Fn SSL_CTX_set_tmp_rsa_callback
149and
150.Fn SSL_set_tmp_rsa_callback
151do not return diagnostic output.
152.Pp
153.Fn SSL_CTX_set_tmp_rsa
154and
155.Fn SSL_set_tmp_rsa
156return 1 on success and 0 on failure.
157Check the error queue to find out the reason of failure.
158.Pp
159.Fn SSL_CTX_need_tmp_rsa
160and
161.Fn SSL_need_tmp_rsa
162return 1 if a temporary RSA key is needed and 0 otherwise.
163.Sh EXAMPLES
164Generate temporary RSA keys to prepare ephemeral RSA key exchange.
165As the generation of a RSA key costs a lot of computer time,
166they are saved for later reuse.
167For demonstration purposes, two keys for 512 bits and 1024 bits
168respectively are generated.
169.Bd -literal
170\&...
171
172/* Set up ephemeral RSA stuff */
173RSA *rsa_512 = NULL;
174RSA *rsa_1024 = NULL;
175
176rsa_512 = RSA_generate_key(512, RSA_F4, NULL, NULL);
177if (rsa_512 == NULL)
178 evaluate_error_queue();
179
180rsa_1024 = RSA_generate_key(1024, RSA_F4, NULL, NULL);
181if (rsa_1024 == NULL)
182 evaluate_error_queue();
183
184\&...
185
186RSA *
187tmp_rsa_callback(SSL *s, int is_export, int keylength)
188{
189 RSA *rsa_tmp = NULL;
190
191 switch (keylength) {
192 case 512:
193 if (rsa_512)
194 rsa_tmp = rsa_512;
195 else {
196 /*
197 * generate on the fly,
198 * should not happen in this example
199 */
200 rsa_tmp = RSA_generate_key(keylength, RSA_F4, NULL,
201 NULL);
202 rsa_512 = rsa_tmp; /* Remember for later reuse */
203 }
204 break;
205 case 1024:
206 if (rsa_1024)
207 rsa_tmp = rsa_1024;
208 else
209 should_not_happen_in_this_example();
210 break;
211 default:
212 /*
213 * Generating a key on the fly is very costly,
214 * so use what is there
215 */
216 if (rsa_1024)
217 rsa_tmp = rsa_1024;
218 else
219 /* Use at least a shorter key */
220 rsa_tmp = rsa_512;
221 }
222 return rsa_tmp;
223}
224.Ed
225.Sh SEE ALSO
226.Xr openssl 1 ,
227.Xr ssl 3 ,
228.Xr SSL_CTX_set_cipher_list 3 ,
229.Xr SSL_CTX_set_options 3 ,
230.Xr SSL_CTX_set_tmp_dh_callback 3 ,
231.Xr SSL_new 3
diff --git a/src/lib/libssl/man/SSL_CTX_set_verify.3 b/src/lib/libssl/man/SSL_CTX_set_verify.3
new file mode 100644
index 0000000000..d9821146e7
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_set_verify.3
@@ -0,0 +1,415 @@
1.\"
2.\" $OpenBSD: SSL_CTX_set_verify.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_SET_VERIFY 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_set_verify ,
9.Nm SSL_set_verify ,
10.Nm SSL_CTX_set_verify_depth ,
11.Nm SSL_set_verify_depth
12.Nd set peer certificate verification parameters
13.Sh SYNOPSIS
14.In openssl/ssl.h
15.Ft void
16.Fo SSL_CTX_set_verify
17.Fa "SSL_CTX *ctx"
18.Fa "int mode"
19.Fa "int (*verify_callback)(int, X509_STORE_CTX *)"
20.Fc
21.Ft void
22.Fo SSL_set_verify
23.Fa "SSL *s"
24.Fa "int mode"
25.Fa "int (*verify_callback)(int, X509_STORE_CTX *)"
26.Fc
27.Ft void
28.Fn SSL_CTX_set_verify_depth "SSL_CTX *ctx" "int depth"
29.Ft void
30.Fn SSL_set_verify_depth "SSL *s" "int depth"
31.Ft int
32.Fn verify_callback "int preverify_ok" "X509_STORE_CTX *x509_ctx"
33.Sh DESCRIPTION
34.Fn SSL_CTX_set_verify
35sets the verification flags for
36.Fa ctx
37to be
38.Fa mode
39and
40specifies the
41.Fa verify_callback
42function to be used.
43If no callback function shall be specified, the
44.Dv NULL
45pointer can be used for
46.Fa verify_callback .
47.Pp
48.Fn SSL_set_verify
49sets the verification flags for
50.Fa ssl
51to be
52.Fa mode
53and specifies the
54.Fa verify_callback
55function to be used.
56If no callback function shall be specified, the
57.Dv NULL
58pointer can be used for
59.Fa verify_callback .
60In this case last
61.Fa verify_callback
62set specifically for this
63.Fa ssl
64remains.
65If no special callback was set before, the default callback for the underlying
66.Fa ctx
67is used, that was valid at the time
68.Fa ssl
69was created with
70.Xr SSL_new 3 .
71.Pp
72.Fn SSL_CTX_set_verify_depth
73sets the maximum
74.Fa depth
75for the certificate chain verification that shall be allowed for
76.Fa ctx .
77(See the
78.Sx BUGS
79section.)
80.Pp
81.Fn SSL_set_verify_depth
82sets the maximum
83.Fa depth
84for the certificate chain verification that shall be allowed for
85.Fa ssl .
86(See the
87.Sx BUGS
88section.)
89.Sh NOTES
90The verification of certificates can be controlled by a set of bitwise ORed
91.Fa mode
92flags:
93.Bl -tag -width Ds
94.It Dv SSL_VERIFY_NONE
95.Em Server mode:
96the server will not send a client certificate request to the client,
97so the client will not send a certificate.
98.Pp
99.Em Client mode:
100if not using an anonymous cipher (by default disabled),
101the server will send a certificate which will be checked.
102The result of the certificate verification process can be checked after the
103TLS/SSL handshake using the
104.Xr SSL_get_verify_result 3
105function.
106The handshake will be continued regardless of the verification result.
107.It Dv SSL_VERIFY_PEER
108.Em Server mode:
109the server sends a client certificate request to the client.
110The certificate returned (if any) is checked.
111If the verification process fails,
112the TLS/SSL handshake is immediately terminated with an alert message
113containing the reason for the verification failure.
114The behaviour can be controlled by the additional
115.Dv SSL_VERIFY_FAIL_IF_NO_PEER_CERT
116and
117.Dv SSL_VERIFY_CLIENT_ONCE
118flags.
119.Pp
120.Em Client mode:
121the server certificate is verified.
122If the verification process fails,
123the TLS/SSL handshake is immediately terminated with an alert message
124containing the reason for the verification failure.
125If no server certificate is sent, because an anonymous cipher is used,
126.Dv SSL_VERIFY_PEER
127is ignored.
128.It Dv SSL_VERIFY_FAIL_IF_NO_PEER_CERT
129.Em Server mode:
130if the client did not return a certificate, the TLS/SSL
131handshake is immediately terminated with a
132.Dq handshake failure
133alert.
134This flag must be used together with
135.Dv SSL_VERIFY_PEER.
136.Pp
137.Em Client mode:
138ignored
139.It Dv SSL_VERIFY_CLIENT_ONCE
140.Em Server mode:
141only request a client certificate on the initial TLS/SSL handshake.
142Do not ask for a client certificate again in case of a renegotiation.
143This flag must be used together with
144.Dv SSL_VERIFY_PEER .
145.Pp
146.Em Client mode:
147ignored
148.El
149.Pp
150Exactly one of the
151.Fa mode
152flags
153.Dv SSL_VERIFY_NONE
154and
155.Dv SSL_VERIFY_PEER
156must be set at any time.
157.Pp
158The actual verification procedure is performed either using the built-in
159verification procedure or using another application provided verification
160function set with
161.Xr SSL_CTX_set_cert_verify_callback 3 .
162The following descriptions apply in the case of the built-in procedure.
163An application provided procedure also has access to the verify depth
164information and the
165.Fa verify_callback Ns ()
166function, but the way this information is used may be different.
167.Pp
168.Fn SSL_CTX_set_verify_depth
169and
170.Fn SSL_set_verify_depth
171set the limit up to which depth certificates in a chain are used during the
172verification procedure.
173If the certificate chain is longer than allowed,
174the certificates above the limit are ignored.
175Error messages are generated as if these certificates would not be present,
176most likely a
177.Dv X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY
178will be issued.
179The depth count is
180.Dq level 0: peer certificate ,
181.Dq level 1: CA certificate ,
182.Dq level 2: higher level CA certificate ,
183and so on.
184Setting the maximum depth to 2 allows the levels 0, 1, and 2.
185The default depth limit is 100,
186allowing for the peer certificate and an additional 100 CA certificates.
187.Pp
188The
189.Fa verify_callback
190function is used to control the behaviour when the
191.Dv SSL_VERIFY_PEER
192flag is set.
193It must be supplied by the application and receives two arguments:
194.Fa preverify_ok
195indicates whether the verification of the certificate in question was passed
196(preverify_ok=1) or not (preverify_ok=0).
197.Fa x509_ctx
198is a pointer to the complete context used
199for the certificate chain verification.
200.Pp
201The certificate chain is checked starting with the deepest nesting level
202(the root CA certificate) and worked upward to the peer's certificate.
203At each level signatures and issuer attributes are checked.
204Whenever a verification error is found, the error number is stored in
205.Fa x509_ctx
206and
207.Fa verify_callback
208is called with
209.Fa preverify_ok
210equal to 0.
211By applying
212.Fn X509_CTX_store_*
213functions
214.Fa verify_callback
215can locate the certificate in question and perform additional steps (see
216.Sx EXAMPLES ) .
217If no error is found for a certificate,
218.Fa verify_callback
219is called with
220.Fa preverify_ok
221equal to 1 before advancing to the next level.
222.Pp
223The return value of
224.Fa verify_callback
225controls the strategy of the further verification process.
226If
227.Fa verify_callback
228returns 0, the verification process is immediately stopped with
229.Dq verification failed
230state.
231If
232.Dv SSL_VERIFY_PEER
233is set, a verification failure alert is sent to the peer and the TLS/SSL
234handshake is terminated.
235If
236.Fa verify_callback
237returns 1, the verification process is continued.
238If
239.Fa verify_callback
240always returns 1,
241the TLS/SSL handshake will not be terminated with respect to verification
242failures and the connection will be established.
243The calling process can however retrieve the error code of the last
244verification error using
245.Xr SSL_get_verify_result 3
246or by maintaining its own error storage managed by
247.Fa verify_callback .
248.Pp
249If no
250.Fa verify_callback
251is specified, the default callback will be used.
252Its return value is identical to
253.Fa preverify_ok ,
254so that any verification
255failure will lead to a termination of the TLS/SSL handshake with an
256alert message, if
257.Dv SSL_VERIFY_PEER
258is set.
259.Sh RETURN VALUES
260The
261.Fn SSL*_set_verify*
262functions do not provide diagnostic information.
263.Sh EXAMPLES
264The following code sequence realizes an example
265.Fa verify_callback
266function that will always continue the TLS/SSL handshake regardless of
267verification failure, if wished.
268The callback realizes a verification depth limit with more informational output.
269.Pp
270All verification errors are printed;
271information about the certificate chain is printed on request.
272The example is realized for a server that does allow but not require client
273certificates.
274.Pp
275The example makes use of the ex_data technique to store application data
276into/retrieve application data from the
277.Vt SSL
278structure (see
279.Xr SSL_get_ex_new_index 3 ,
280.Xr SSL_get_ex_data_X509_STORE_CTX_idx 3 ) .
281.Bd -literal
282\&...
283
284typedef struct {
285 int verbose_mode;
286 int verify_depth;
287 int always_continue;
288} mydata_t;
289int mydata_index;
290\&...
291static int
292verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
293{
294 char buf[256];
295 X509 *err_cert;
296 int err, depth;
297 SSL *ssl;
298 mydata_t *mydata;
299
300 err_cert = X509_STORE_CTX_get_current_cert(ctx);
301 err = X509_STORE_CTX_get_error(ctx);
302 depth = X509_STORE_CTX_get_error_depth(ctx);
303
304 /*
305 * Retrieve the pointer to the SSL of the connection currently
306 * treated * and the application specific data stored into the
307 * SSL object.
308 */
309 ssl = X509_STORE_CTX_get_ex_data(ctx,
310 SSL_get_ex_data_X509_STORE_CTX_idx());
311 mydata = SSL_get_ex_data(ssl, mydata_index);
312
313 X509_NAME_oneline(X509_get_subject_name(err_cert), buf, 256);
314
315 /*
316 * Catch a too long certificate chain. The depth limit set using
317 * SSL_CTX_set_verify_depth() is by purpose set to "limit+1" so
318 * that whenever the "depth>verify_depth" condition is met, we
319 * have violated the limit and want to log this error condition.
320 * We must do it here, because the CHAIN_TOO_LONG error would not
321 * be found explicitly; only errors introduced by cutting off the
322 * additional certificates would be logged.
323 */
324 if (depth > mydata->verify_depth) {
325 preverify_ok = 0;
326 err = X509_V_ERR_CERT_CHAIN_TOO_LONG;
327 X509_STORE_CTX_set_error(ctx, err);
328 }
329 if (!preverify_ok) {
330 printf("verify error:num=%d:%s:depth=%d:%s\en", err,
331 X509_verify_cert_error_string(err), depth, buf);
332 } else if (mydata->verbose_mode) {
333 printf("depth=%d:%s\en", depth, buf);
334 }
335
336 /*
337 * At this point, err contains the last verification error.
338 * We can use it for something special
339 */
340 if (!preverify_ok && (err ==
341 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT)) {
342 X509_NAME_oneline(X509_get_issuer_name(ctx->current_cert),
343 buf, 256);
344 printf("issuer= %s\en", buf);
345 }
346
347 if (mydata->always_continue)
348 return 1;
349 else
350 return preverify_ok;
351}
352\&...
353
354mydata_t mydata;
355
356\&...
357
358mydata_index = SSL_get_ex_new_index(0, "mydata index", NULL, NULL, NULL);
359
360\&...
361
362SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
363 verify_callback);
364
365/*
366 * Let the verify_callback catch the verify_depth error so that we get
367 * an appropriate error in the logfile.
368 */
369SSL_CTX_set_verify_depth(verify_depth + 1);
370
371/*
372 * Set up the SSL specific data into "mydata" and store it into the SSL
373 * structure.
374 */
375mydata.verify_depth = verify_depth; ...
376SSL_set_ex_data(ssl, mydata_index, &mydata);
377
378\&...
379
380SSL_accept(ssl); /* check of success left out for clarity */
381if (peer = SSL_get_peer_certificate(ssl)) {
382 if (SSL_get_verify_result(ssl) == X509_V_OK) {
383 /* The client sent a certificate which verified OK */
384 }
385}
386.Ed
387.Sh SEE ALSO
388.Xr ssl 3 ,
389.Xr SSL_CTX_get_verify_mode 3 ,
390.Xr SSL_CTX_load_verify_locations 3 ,
391.Xr SSL_CTX_set_cert_verify_callback 3 ,
392.Xr SSL_get_ex_data_X509_STORE_CTX_idx 3 ,
393.Xr SSL_get_ex_new_index 3 ,
394.Xr SSL_get_peer_certificate 3 ,
395.Xr SSL_get_verify_result 3 ,
396.Xr SSL_new 3
397.Sh BUGS
398In client mode, it is not checked whether the
399.Dv SSL_VERIFY_PEER
400flag is set, but whether
401.Dv SSL_VERIFY_NONE
402is not set.
403This can lead to unexpected behaviour, if the
404.Dv SSL_VERIFY_PEER
405and
406.Dv SSL_VERIFY_NONE
407are not used as required (exactly one must be set at any time).
408.Pp
409The certificate verification depth set with
410.Fn SSL[_CTX]_verify_depth
411stops the verification at a certain depth.
412The error message produced will be that of an incomplete certificate chain and
413not
414.Dv X509_V_ERR_CERT_CHAIN_TOO_LONG
415as may be expected.
diff --git a/src/lib/libssl/man/SSL_CTX_use_certificate.3 b/src/lib/libssl/man/SSL_CTX_use_certificate.3
new file mode 100644
index 0000000000..58a9310533
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_use_certificate.3
@@ -0,0 +1,336 @@
1.\"
2.\" $OpenBSD: SSL_CTX_use_certificate.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_USE_CERTIFICATE 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_use_certificate ,
9.Nm SSL_CTX_use_certificate_ASN1 ,
10.Nm SSL_CTX_use_certificate_file ,
11.Nm SSL_use_certificate ,
12.Nm SSL_use_certificate_ASN1 ,
13.Nm SSL_use_certificate_file ,
14.Nm SSL_CTX_use_certificate_chain_file ,
15.Nm SSL_CTX_use_certificate_chain_mem ,
16.Nm SSL_CTX_use_PrivateKey ,
17.Nm SSL_CTX_use_PrivateKey_ASN1 ,
18.Nm SSL_CTX_use_PrivateKey_file ,
19.Nm SSL_CTX_use_RSAPrivateKey ,
20.Nm SSL_CTX_use_RSAPrivateKey_ASN1 ,
21.Nm SSL_CTX_use_RSAPrivateKey_file ,
22.Nm SSL_use_PrivateKey_file ,
23.Nm SSL_use_PrivateKey_ASN1 ,
24.Nm SSL_use_PrivateKey ,
25.Nm SSL_use_RSAPrivateKey ,
26.Nm SSL_use_RSAPrivateKey_ASN1 ,
27.Nm SSL_use_RSAPrivateKey_file ,
28.Nm SSL_CTX_check_private_key ,
29.Nm SSL_check_private_key
30.Nd load certificate and key data
31.Sh SYNOPSIS
32.In openssl/ssl.h
33.Ft int
34.Fn SSL_CTX_use_certificate "SSL_CTX *ctx" "X509 *x"
35.Ft int
36.Fn SSL_CTX_use_certificate_ASN1 "SSL_CTX *ctx" "int len" "unsigned char *d"
37.Ft int
38.Fn SSL_CTX_use_certificate_file "SSL_CTX *ctx" "const char *file" "int type"
39.Ft int
40.Fn SSL_use_certificate "SSL *ssl" "X509 *x"
41.Ft int
42.Fn SSL_use_certificate_ASN1 "SSL *ssl" "unsigned char *d" "int len"
43.Ft int
44.Fn SSL_use_certificate_file "SSL *ssl" "const char *file" "int type"
45.Ft int
46.Fn SSL_CTX_use_certificate_chain_file "SSL_CTX *ctx" "const char *file"
47.Ft int
48.Fn SSL_CTX_use_certificate_chain_mem "SSL_CTX *ctx" "void *buf" "int len"
49.Ft int
50.Fn SSL_CTX_use_PrivateKey "SSL_CTX *ctx" "EVP_PKEY *pkey"
51.Ft int
52.Fo SSL_CTX_use_PrivateKey_ASN1
53.Fa "int pk" "SSL_CTX *ctx" "unsigned char *d" "long len"
54.Fc
55.Ft int
56.Fn SSL_CTX_use_PrivateKey_file "SSL_CTX *ctx" "const char *file" "int type"
57.Ft int
58.Fn SSL_CTX_use_RSAPrivateKey "SSL_CTX *ctx" "RSA *rsa"
59.Ft int
60.Fn SSL_CTX_use_RSAPrivateKey_ASN1 "SSL_CTX *ctx" "unsigned char *d" "long len"
61.Ft int
62.Fn SSL_CTX_use_RSAPrivateKey_file "SSL_CTX *ctx" "const char *file" "int type"
63.Ft int
64.Fn SSL_use_PrivateKey "SSL *ssl" "EVP_PKEY *pkey"
65.Ft int
66.Fn SSL_use_PrivateKey_ASN1 "int pk" "SSL *ssl" "unsigned char *d" "long len"
67.Ft int
68.Fn SSL_use_PrivateKey_file "SSL *ssl" "const char *file" "int type"
69.Ft int
70.Fn SSL_use_RSAPrivateKey "SSL *ssl" "RSA *rsa"
71.Ft int
72.Fn SSL_use_RSAPrivateKey_ASN1 "SSL *ssl" "unsigned char *d" "long len"
73.Ft int
74.Fn SSL_use_RSAPrivateKey_file "SSL *ssl" "const char *file" "int type"
75.Ft int
76.Fn SSL_CTX_check_private_key "const SSL_CTX *ctx"
77.Ft int
78.Fn SSL_check_private_key "const SSL *ssl"
79.Sh DESCRIPTION
80These functions load the certificates and private keys into the
81.Vt SSL_CTX
82or
83.Vt SSL
84object, respectively.
85.Pp
86The
87.Fn SSL_CTX_*
88class of functions loads the certificates and keys into the
89.Vt SSL_CTX
90object
91.Fa ctx .
92The information is passed to
93.Vt SSL
94objects
95.Fa ssl
96created from
97.Fa ctx
98with
99.Xr SSL_new 3
100by copying, so that changes applied to
101.Fa ctx
102do not propagate to already existing
103.Vt SSL
104objects.
105.Pp
106The
107.Fn SSL_*
108class of functions only loads certificates and keys into a specific
109.Vt SSL
110object.
111The specific information is kept when
112.Xr SSL_clear 3
113is called for this
114.Vt SSL
115object.
116.Pp
117.Fn SSL_CTX_use_certificate
118loads the certificate
119.Fa x
120into
121.Fa ctx ;
122.Fn SSL_use_certificate
123loads
124.Fa x
125into
126.Fa ssl .
127The rest of the certificates needed to form the complete certificate chain can
128be specified using the
129.Xr SSL_CTX_add_extra_chain_cert 3
130function.
131.Pp
132.Fn SSL_CTX_use_certificate_ASN1
133loads the ASN1 encoded certificate from the memory location
134.Fa d
135(with length
136.Fa len )
137into
138.Fa ctx ;
139.Fn SSL_use_certificate_ASN1
140loads the ASN1 encoded certificate into
141.Fa ssl .
142.Pp
143.Fn SSL_CTX_use_certificate_file
144loads the first certificate stored in
145.Fa file
146into
147.Fa ctx .
148The formatting
149.Fa type
150of the certificate must be specified from the known types
151.Dv SSL_FILETYPE_PEM
152and
153.Dv SSL_FILETYPE_ASN1 .
154.Fn SSL_use_certificate_file
155loads the certificate from
156.Fa file
157into
158.Fa ssl .
159See the
160.Sx NOTES
161section on why
162.Fn SSL_CTX_use_certificate_chain_file
163should be preferred.
164.Pp
165The
166.Fn SSL_CTX_use_certificate_chain*
167functions load a certificate chain into
168.Fa ctx .
169The certificates must be in PEM format and must be sorted starting with the
170subject's certificate (actual client or server certificate),
171followed by intermediate CA certificates if applicable,
172and ending at the highest level (root) CA.
173There is no corresponding function working on a single
174.Vt SSL
175object.
176.Pp
177.Fn SSL_CTX_use_PrivateKey
178adds
179.Fa pkey
180as private key to
181.Fa ctx .
182.Fn SSL_CTX_use_RSAPrivateKey
183adds the private key
184.Fa rsa
185of type RSA to
186.Fa ctx .
187.Fn SSL_use_PrivateKey
188adds
189.Fa pkey
190as private key to
191.Fa ssl ;
192.Fn SSL_use_RSAPrivateKey
193adds
194.Fa rsa
195as private key of type RSA to
196.Fa ssl .
197If a certificate has already been set and the private does not belong to the
198certificate, an error is returned.
199To change a certificate private key pair,
200the new certificate needs to be set with
201.Fn SSL_use_certificate
202or
203.Fn SSL_CTX_use_certificate
204before setting the private key with
205.Fn SSL_CTX_use_PrivateKey
206or
207.Fn SSL_use_PrivateKey .
208.Pp
209.Fn SSL_CTX_use_PrivateKey_ASN1
210adds the private key of type
211.Fa pk
212stored at memory location
213.Fa d
214(length
215.Fa len )
216to
217.Fa ctx .
218.Fn SSL_CTX_use_RSAPrivateKey_ASN1
219adds the private key of type RSA stored at memory location
220.Fa d
221(length
222.Fa len )
223to
224.Fa ctx .
225.Fn SSL_use_PrivateKey_ASN1
226and
227.Fn SSL_use_RSAPrivateKey_ASN1
228add the private key to
229.Fa ssl .
230.Pp
231.Fn SSL_CTX_use_PrivateKey_file
232adds the first private key found in
233.Fa file
234to
235.Fa ctx .
236The formatting
237.Fa type
238of the certificate must be specified from the known types
239.Dv SSL_FILETYPE_PEM
240and
241.Dv SSL_FILETYPE_ASN1 .
242.Fn SSL_CTX_use_RSAPrivateKey_file
243adds the first private RSA key found in
244.Fa file
245to
246.Fa ctx .
247.Fn SSL_use_PrivateKey_file
248adds the first private key found in
249.Fa file
250to
251.Fa ssl ;
252.Fn SSL_use_RSAPrivateKey_file
253adds the first private RSA key found to
254.Fa ssl .
255.Pp
256.Fn SSL_CTX_check_private_key
257checks the consistency of a private key with the corresponding certificate
258loaded into
259.Fa ctx .
260If more than one key/certificate pair (RSA/DSA) is installed,
261the last item installed will be checked.
262If, e.g., the last item was a RSA certificate or key,
263the RSA key/certificate pair will be checked.
264.Fn SSL_check_private_key
265performs the same check for
266.Fa ssl .
267If no key/certificate was explicitly added for this
268.Fa ssl ,
269the last item added into
270.Fa ctx
271will be checked.
272.Sh NOTES
273The internal certificate store of OpenSSL can hold two private key/certificate
274pairs at a time:
275one key/certificate of type RSA and one key/certificate of type DSA.
276The certificate used depends on the cipher select, see also
277.Xr SSL_CTX_set_cipher_list 3 .
278.Pp
279When reading certificates and private keys from file, files of type
280.Dv SSL_FILETYPE_ASN1
281(also known as
282.Em DER ,
283binary encoding) can only contain one certificate or private key; consequently,
284.Fn SSL_CTX_use_certificate_chain_file
285is only applicable to PEM formatting.
286Files of type
287.Dv SSL_FILETYPE_PEM
288can contain more than one item.
289.Pp
290.Fn SSL_CTX_use_certificate_chain_file
291adds the first certificate found in the file to the certificate store.
292The other certificates are added to the store of chain certificates using
293.Xr SSL_CTX_add_extra_chain_cert 3 .
294There exists only one extra chain store, so that the same chain is appended
295to both types of certificates, RSA and DSA!
296If it is not intended to use both type of certificate at the same time,
297it is recommended to use the
298.Fn SSL_CTX_use_certificate_chain_file
299instead of the
300.Fn SSL_CTX_use_certificate_file
301function in order to allow the use of complete certificate chains even when no
302trusted CA storage is used or when the CA issuing the certificate shall not be
303added to the trusted CA storage.
304.Pp
305If additional certificates are needed to complete the chain during the TLS
306negotiation, CA certificates are additionally looked up in the locations of
307trusted CA certificates (see
308.Xr SSL_CTX_load_verify_locations 3 ) .
309.Pp
310The private keys loaded from file can be encrypted.
311In order to successfully load encrypted keys,
312a function returning the passphrase must have been supplied (see
313.Xr SSL_CTX_set_default_passwd_cb 3 ) .
314(Certificate files might be encrypted as well from the technical point of view,
315it however does not make sense as the data in the certificate is considered
316public anyway.)
317.Sh RETURN VALUES
318On success, the functions return 1.
319Otherwise check out the error stack to find out the reason.
320.Sh SEE ALSO
321.Xr ssl 3 ,
322.Xr SSL_clear 3 ,
323.Xr SSL_CTX_add_extra_chain_cert 3 ,
324.Xr SSL_CTX_load_verify_locations 3 ,
325.Xr SSL_CTX_set_cipher_list 3 ,
326.Xr SSL_CTX_set_client_cert_cb 3 ,
327.Xr SSL_CTX_set_default_passwd_cb 3 ,
328.Xr SSL_new 3
329.Sh HISTORY
330Support for DER encoded private keys
331.Pq Dv SSL_FILETYPE_ASN1
332in
333.Fn SSL_CTX_use_PrivateKey_file
334and
335.Fn SSL_use_PrivateKey_file
336was added in 0.9.8.
diff --git a/src/lib/libssl/man/SSL_CTX_use_psk_identity_hint.3 b/src/lib/libssl/man/SSL_CTX_use_psk_identity_hint.3
new file mode 100644
index 0000000000..7d5d6b1dfd
--- /dev/null
+++ b/src/lib/libssl/man/SSL_CTX_use_psk_identity_hint.3
@@ -0,0 +1,110 @@
1.\"
2.\" $OpenBSD: SSL_CTX_use_psk_identity_hint.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CTX_USE_PSK_IDENTITY_HINT 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_use_psk_identity_hint ,
9.Nm SSL_use_psk_identity_hint ,
10.Nm SSL_CTX_set_psk_server_callback ,
11.Nm SSL_set_psk_server_callback
12.Nd set PSK identity hint to use
13.Sh SYNOPSIS
14.In openssl/ssl.h
15.Ft int
16.Fn SSL_CTX_use_psk_identity_hint "SSL_CTX *ctx" "const char *hint"
17.Ft int
18.Fn SSL_use_psk_identity_hint "SSL *ssl" "const char *hint"
19.Ft void
20.Fo SSL_CTX_set_psk_server_callback
21.Fa "SSL_CTX *ctx"
22.Fa "unsigned int (*callback)(SSL *ssl, const char *identity, unsigned char *psk, int max_psk_len)"
23.Fc
24.Ft void
25.Fo SSL_set_psk_server_callback
26.Fa "SSL *ssl"
27.Fa "unsigned int (*callback)(SSL *ssl, const char *identity, unsigned char *psk, int max_psk_len)"
28.Fc
29.Sh DESCRIPTION
30.Fn SSL_CTX_use_psk_identity_hint
31sets the given
32.Dv NULL Ns
33-terminated PSK identity hint
34.Fa hint
35to SSL context object
36.Fa ctx .
37.Fn SSL_use_psk_identity_hint
38sets the given
39.Dv NULL Ns
40-terminated
41PSK identity hint
42.Fa hint
43to SSL connection object
44.Fa ssl .
45If
46.Fa hint
47is
48.Dv NULL
49the current hint from
50.Fa ctx
51or
52.Fa ssl
53is deleted.
54.Pp
55In the case where PSK identity hint is
56.Dv NULL ,
57the server does not send the
58.Em ServerKeyExchange
59message to the client.
60.Pp
61A server application must provide a callback function which is called when the
62server receives the
63.Em ClientKeyExchange
64message from the client.
65The purpose of the callback function is to validate the received PSK identity
66and to fetch the pre-shared key used during the connection setup phase.
67The callback is set using functions
68.Fn SSL_CTX_set_psk_server_callback
69or
70.Fn SSL_set_psk_server_callback .
71The callback function is given the connection in parameter
72.Fa ssl ,
73.Dv NULL Ns
74-terminated PSK identity sent by the client in parameter
75.Fa identity ,
76and a buffer
77.Fa psk
78of length
79.Fa max_psk_len
80bytes where the pre-shared key is to be stored.
81.Sh RETURN VALUES
82.Fn SSL_CTX_use_psk_identity_hint
83and
84.Fn SSL_use_psk_identity_hint
85return 1 on success, 0 otherwise.
86.Pp
87Return values from the server callback are interpreted as follows:
88.Bl -tag -width Ds
89.It >0
90PSK identity was found and the server callback has provided the PSK
91successfully in parameter
92.Fa psk .
93Return value is the length of
94.Fa psk
95in bytes.
96It is an error to return a value greater than
97.Fa max_psk_len .
98.Pp
99If the PSK identity was not found but the callback instructs the protocol to
100continue anyway, the callback must provide some random data to
101.Fa psk
102and return the length of the random data, so the connection will fail with
103.Dq decryption_error
104before it will be finished completely.
105.It 0
106PSK identity was not found.
107An
108.Dq unknown_psk_identity
109alert message will be sent and the connection setup fails.
110.El
diff --git a/src/lib/libssl/man/SSL_SESSION_free.3 b/src/lib/libssl/man/SSL_SESSION_free.3
new file mode 100644
index 0000000000..8eabe8da80
--- /dev/null
+++ b/src/lib/libssl/man/SSL_SESSION_free.3
@@ -0,0 +1,84 @@
1.\"
2.\" $OpenBSD: SSL_SESSION_free.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_SESSION_FREE 3
6.Os
7.Sh NAME
8.Nm SSL_SESSION_free
9.Nd free an allocated SSL_SESSION structure
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft void
13.Fn SSL_SESSION_free "SSL_SESSION *session"
14.Sh DESCRIPTION
15.Fn SSL_SESSION_free
16decrements the reference count of
17.Fa session
18and removes the
19.Vt SSL_SESSION
20structure pointed to by
21.Fa session
22and frees up the allocated memory, if the reference count has reached 0.
23If
24.Fa session
25is a
26.Dv NULL
27pointer, no action occurs.
28.Sh NOTES
29.Vt SSL_SESSION
30objects are allocated when a TLS/SSL handshake operation is successfully
31completed.
32Depending on the settings, see
33.Xr SSL_CTX_set_session_cache_mode 3 ,
34the
35.Vt SSL_SESSION
36objects are internally referenced by the
37.Vt SSL_CTX
38and linked into its session cache.
39.Vt SSL
40objects may be using the
41.Vt SSL_SESSION
42object; as a session may be reused, several
43.Vt SSL
44objects may be using one
45.Vt SSL_SESSION
46object at the same time.
47It is therefore crucial to keep the reference count (usage information) correct
48and not delete a
49.Vt SSL_SESSION
50object that is still used, as this may lead to program failures due to dangling
51pointers.
52These failures may also appear delayed, e.g., when an
53.Vt SSL_SESSION
54object is completely freed as the reference count incorrectly becomes 0, but it
55is still referenced in the internal session cache and the cache list is
56processed during a
57.Xr SSL_CTX_flush_sessions 3
58operation.
59.Pp
60.Fn SSL_SESSION_free
61must only be called for
62.Vt SSL_SESSION
63objects, for which the reference count was explicitly incremented (e.g., by
64calling
65.Xr SSL_get1_session 3 ;
66see
67.Xr SSL_get_session 3 )
68or when the
69.Vt SSL_SESSION
70object was generated outside a TLS handshake operation, e.g., by using
71.Xr d2i_SSL_SESSION 3 .
72It must not be called on other
73.Vt SSL_SESSION
74objects, as this would cause incorrect reference counts and therefore program
75failures.
76.Sh RETURN VALUES
77.Fn SSL_SESSION_free
78does not provide diagnostic information.
79.Sh SEE ALSO
80.Xr d2i_SSL_SESSION 3 ,
81.Xr ssl 3 ,
82.Xr SSL_CTX_flush_sessions 3 ,
83.Xr SSL_CTX_set_session_cache_mode 3 ,
84.Xr SSL_get_session 3
diff --git a/src/lib/libssl/man/SSL_SESSION_get_ex_new_index.3 b/src/lib/libssl/man/SSL_SESSION_get_ex_new_index.3
new file mode 100644
index 0000000000..0779db91b8
--- /dev/null
+++ b/src/lib/libssl/man/SSL_SESSION_get_ex_new_index.3
@@ -0,0 +1,80 @@
1.\"
2.\" $OpenBSD: SSL_SESSION_get_ex_new_index.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_SESSION_GET_EX_NEW_INDEX 3
6.Os
7.Sh NAME
8.Nm SSL_SESSION_get_ex_new_index ,
9.Nm SSL_SESSION_set_ex_data ,
10.Nm SSL_SESSION_get_ex_data
11.Nd internal application specific data functions
12.Sh SYNOPSIS
13.In openssl/ssl.h
14.Ft int
15.Fo SSL_SESSION_get_ex_new_index
16.Fa "long argl"
17.Fa "void *argp"
18.Fa "CRYPTO_EX_new *new_func"
19.Fa "CRYPTO_EX_dup *dup_func"
20.Fa "CRYPTO_EX_free *free_func"
21.Fc
22.Ft int
23.Fn SSL_SESSION_set_ex_data "SSL_SESSION *session" "int idx" "void *arg"
24.Ft void *
25.Fn SSL_SESSION_get_ex_data "const SSL_SESSION *session" "int idx"
26.Bd -literal
27 typedef int new_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
28 int idx, long argl, void *argp);
29 typedef void free_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
30 int idx, long argl, void *argp);
31 typedef int dup_func(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
32 int idx, long argl, void *argp);
33.Ed
34.Sh DESCRIPTION
35Several OpenSSL structures can have application specific data attached to them.
36These functions are used internally by OpenSSL to manipulate
37application-specific data attached to a specific structure.
38.Pp
39.Fn SSL_SESSION_get_ex_new_index
40is used to register a new index for application-specific data.
41.Pp
42.Fn SSL_SESSION_set_ex_data
43is used to store application data at
44.Fa arg
45for
46.Fa idx
47into the
48.Fa session
49object.
50.Pp
51.Fn SSL_SESSION_get_ex_data
52is used to retrieve the information for
53.Fa idx
54from
55.Fa session .
56.Pp
57A detailed description for the
58.Fn *_get_ex_new_index
59functionality
60can be found in
61.Xr RSA_get_ex_new_index 3 .
62The
63.Fn *_get_ex_data
64and
65.Fn *_set_ex_data
66functionality is described in
67.Xr CRYPTO_set_ex_data 3 .
68.Sh WARNINGS
69The application data is only maintained for sessions held in memory.
70The application data is not included when dumping the session with
71.Xr i2d_SSL_SESSION 3
72(and all functions indirectly calling the dump functions like
73.Xr PEM_write_SSL_SESSION 3
74and
75.Xr PEM_write_bio_SSL_SESSION 3 )
76and can therefore not be restored.
77.Sh SEE ALSO
78.Xr CRYPTO_set_ex_data 3 ,
79.Xr RSA_get_ex_new_index 3 ,
80.Xr ssl 3
diff --git a/src/lib/libssl/man/SSL_SESSION_get_time.3 b/src/lib/libssl/man/SSL_SESSION_get_time.3
new file mode 100644
index 0000000000..9641290e71
--- /dev/null
+++ b/src/lib/libssl/man/SSL_SESSION_get_time.3
@@ -0,0 +1,98 @@
1.\"
2.\" $OpenBSD: SSL_SESSION_get_time.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_SESSION_GET_TIME 3
6.Os
7.Sh NAME
8.Nm SSL_SESSION_get_time ,
9.Nm SSL_SESSION_set_time ,
10.Nm SSL_SESSION_get_timeout ,
11.Nm SSL_SESSION_set_timeout ,
12.Nm SSL_get_time ,
13.Nm SSL_set_time ,
14.Nm SSL_get_timeout ,
15.Nm SSL_set_timeout
16.Nd retrieve and manipulate session time and timeout settings
17.Sh SYNOPSIS
18.In openssl/ssl.h
19.Ft long
20.Fn SSL_SESSION_get_time "const SSL_SESSION *s"
21.Ft long
22.Fn SSL_SESSION_set_time "SSL_SESSION *s" "long tm"
23.Ft long
24.Fn SSL_SESSION_get_timeout "const SSL_SESSION *s"
25.Ft long
26.Fn SSL_SESSION_set_timeout "SSL_SESSION *s" "long tm"
27.Ft long
28.Fn SSL_get_time "const SSL_SESSION *s"
29.Ft long
30.Fn SSL_set_time "SSL_SESSION *s" "long tm"
31.Ft long
32.Fn SSL_get_timeout "const SSL_SESSION *s"
33.Ft long
34.Fn SSL_set_timeout "SSL_SESSION *s" "long tm"
35.Sh DESCRIPTION
36.Fn SSL_SESSION_get_time
37returns the time at which the session
38.Fa s
39was established.
40The time is given in seconds since the Epoch and therefore compatible to the
41time delivered by the
42.Xr time 3
43call.
44.Pp
45.Fn SSL_SESSION_set_time
46replaces the creation time of the session
47.Fa s
48with
49the chosen value
50.Fa tm .
51.Pp
52.Fn SSL_SESSION_get_timeout
53returns the timeout value set for session
54.Fa s
55in seconds.
56.Pp
57.Fn SSL_SESSION_set_timeout
58sets the timeout value for session
59.Fa s
60in seconds to
61.Fa tm .
62.Pp
63The
64.Fn SSL_get_time ,
65.Fn SSL_set_time ,
66.Fn SSL_get_timeout ,
67and
68.Fn SSL_set_timeout
69functions are synonyms for the
70.Fn SSL_SESSION_*
71counterparts.
72.Sh NOTES
73Sessions are expired by examining the creation time and the timeout value.
74Both are set at creation time of the session to the actual time and the default
75timeout value at creation, respectively, as set by
76.Xr SSL_CTX_set_timeout 3 .
77Using these functions it is possible to extend or shorten the lifetime of the
78session.
79.Sh RETURN VALUES
80.Fn SSL_SESSION_get_time
81and
82.Fn SSL_SESSION_get_timeout
83return the currently valid values.
84.Pp
85.Fn SSL_SESSION_set_time
86and
87.Fn SSL_SESSION_set_timeout
88return 1 on success.
89.Pp
90If any of the function is passed the
91.Dv NULL
92pointer for the session
93.Fa s ,
940 is returned.
95.Sh SEE ALSO
96.Xr ssl 3 ,
97.Xr SSL_CTX_set_timeout 3 ,
98.Xr SSL_get_default_timeout 3
diff --git a/src/lib/libssl/man/SSL_accept.3 b/src/lib/libssl/man/SSL_accept.3
new file mode 100644
index 0000000000..944fb50c28
--- /dev/null
+++ b/src/lib/libssl/man/SSL_accept.3
@@ -0,0 +1,103 @@
1.\"
2.\" $OpenBSD: SSL_accept.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_ACCEPT 3
6.Os
7.Sh NAME
8.Nm SSL_accept
9.Nd wait for a TLS/SSL client to initiate a TLS/SSL handshake
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft int
13.Fn SSL_accept "SSL *ssl"
14.Sh DESCRIPTION
15.Fn SSL_accept
16waits for a TLS/SSL client to initiate the TLS/SSL handshake.
17The communication channel must already have been set and assigned to the
18.Fa ssl
19object by setting an underlying
20.Vt BIO .
21.Sh NOTES
22The behaviour of
23.Fn SSL_accept
24depends on the underlying
25.Vt BIO .
26.Pp
27If the underlying
28.Vt BIO
29is
30.Em blocking ,
31.Fn SSL_accept
32will only return once the handshake has been finished or an error occurred.
33.Pp
34If the underlying
35.Vt BIO
36is
37.Em non-blocking ,
38.Fn SSL_accept
39will also return when the underlying
40.Vt BIO
41could not satisfy the needs of
42.Fn SSL_accept
43to continue the handshake, indicating the problem by the return value \(mi1.
44In this case a call to
45.Xr SSL_get_error 3
46with the
47return value of
48.Fn SSL_accept
49will yield
50.Dv SSL_ERROR_WANT_READ
51or
52.Dv SSL_ERROR_WANT_WRITE .
53The calling process then must repeat the call after taking appropriate action
54to satisfy the needs of
55.Fn SSL_accept .
56The action depends on the underlying
57.Dv BIO .
58When using a non-blocking socket, nothing is to be done, but
59.Xr select 2
60can be used to check for the required condition.
61When using a buffering
62.Vt BIO ,
63like a
64.Vt BIO
65pair, data must be written into or retrieved out of the
66.Vt BIO
67before being able to continue.
68.Sh RETURN VALUES
69The following return values can occur:
70.Bl -tag -width Ds
71.It 0
72The TLS/SSL handshake was not successful but was shut down controlled and by
73the specifications of the TLS/SSL protocol.
74Call
75.Xr SSL_get_error 3
76with the return value
77.Fa ret
78to find out the reason.
79.It 1
80The TLS/SSL handshake was successfully completed,
81and a TLS/SSL connection has been established.
82.It <0
83The TLS/SSL handshake was not successful because a fatal error occurred either
84at the protocol level or a connection failure occurred.
85The shutdown was not clean.
86It can also occur of action is need to continue the operation for non-blocking
87.Vt BIO Ns
88s.
89Call
90.Xr SSL_get_error 3
91with the return value
92.Fa ret
93to find out the reason.
94.El
95.Sh SEE ALSO
96.Xr bio 3 ,
97.Xr ssl 3 ,
98.Xr SSL_connect 3 ,
99.Xr SSL_CTX_new 3 ,
100.Xr SSL_do_handshake 3 ,
101.Xr SSL_get_error 3 ,
102.Xr SSL_set_connect_state 3 ,
103.Xr SSL_shutdown 3
diff --git a/src/lib/libssl/man/SSL_alert_type_string.3 b/src/lib/libssl/man/SSL_alert_type_string.3
new file mode 100644
index 0000000000..ff68ba5858
--- /dev/null
+++ b/src/lib/libssl/man/SSL_alert_type_string.3
@@ -0,0 +1,193 @@
1.\"
2.\" $OpenBSD: SSL_alert_type_string.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_ALERT_TYPE_STRING.POD 3
6.Os
7.Sh NAME
8.Nm SSL_alert_type_string ,
9.Nm SSL_alert_type_string_long ,
10.Nm SSL_alert_desc_string ,
11.Nm SSL_alert_desc_string_long
12.Nd get textual description of alert information
13.Sh SYNOPSIS
14.In openssl/ssl.h
15.Ft const char *
16.Fn SSL_alert_type_string "int value"
17.Ft const char *
18.Fn SSL_alert_type_string_long "int value"
19.Ft const char *
20.Fn SSL_alert_desc_string "int value"
21.Ft const char *
22.Fn SSL_alert_desc_string_long "int value"
23.Sh DESCRIPTION
24.Fn SSL_alert_type_string
25returns a one letter string indicating the type of the alert specified by
26.Fa value .
27.Pp
28.Fn SSL_alert_type_string_long
29returns a string indicating the type of the alert specified by
30.Fa value .
31.Pp
32.Fn SSL_alert_desc_string
33returns a two letter string as a short form describing the reason of the alert
34specified by
35.Fa value .
36.Pp
37.Fn SSL_alert_desc_string_long
38returns a string describing the reason of the alert specified by
39.Fa value .
40.Sh NOTES
41When one side of an SSL/TLS communication wants to inform the peer about
42a special situation, it sends an alert.
43The alert is sent as a special message and does not influence the normal data
44stream (unless its contents results in the communication being canceled).
45.Pp
46A warning alert is sent, when a non-fatal error condition occurs.
47The
48.Dq close notify
49alert is sent as a warning alert.
50Other examples for non-fatal errors are certificate errors
51.Po
52.Dq certificate expired ,
53.Dq unsupported certificate
54.Pc ,
55for which a warning alert may be sent.
56(The sending party may, however, decide to send a fatal error.)
57The receiving side may cancel the connection on reception of a warning alert at
58its discretion.
59.Pp
60Several alert messages must be sent as fatal alert messages as specified
61by the TLS RFC.
62A fatal alert always leads to a connection abort.
63.Sh RETURN VALUES
64The following strings can occur for
65.Fn SSL_alert_type_string
66or
67.Fn SSL_alert_type_string_long :
68.Bl -tag -width Ds
69.It \(dqW\(dq/\(dqwarning\(dq
70.It \(dqF\(dq/\(dqfatal\(dq
71.It \(dqU\(dq/\(dqunknown\(dq
72This indicates that no support is available for this alert type.
73Probably
74.Fa value
75does not contain a correct alert message.
76.El
77.Pp
78The following strings can occur for
79.Fn SSL_alert_desc_string
80or
81.Fn SSL_alert_desc_string_long :
82.Bl -tag -width Ds
83.It \(dqCN\(dq/\(dqclose notify\(dq
84The connection shall be closed.
85This is a warning alert.
86.It \(dqUM\(dq/\(dqunexpected message\(dq
87An inappropriate message was received.
88This alert is always fatal and should never be observed in communication
89between proper implementations.
90.It \(dqBM\(dq/\(dqbad record mac\(dq
91This alert is returned if a record is received with an incorrect MAC.
92This message is always fatal.
93.It \(dqDF\(dq/\(dqdecompression failure\(dq
94The decompression function received improper input
95(e.g., data that would expand to excessive length).
96This message is always fatal.
97.It \(dqHF\(dq/\(dqhandshake failure\(dq
98Reception of a handshake_failure alert message indicates that the sender was
99unable to negotiate an acceptable set of security parameters given the options
100available.
101This is a fatal error.
102.It \(dqNC\(dq/\(dqno certificate\(dq
103A client, that was asked to send a certificate, does not send a certificate
104(SSLv3 only).
105.It \(dqBC\(dq/\(dqbad certificate\(dq
106A certificate was corrupt, contained signatures that did not verify correctly,
107etc.
108.It \(dqUC\(dq/\(dqunsupported certificate\(dq
109A certificate was of an unsupported type.
110.It \(dqCR\(dq/\(dqcertificate revoked\(dq
111A certificate was revoked by its signer.
112.It \(dqCE\(dq/\(dqcertificate expired\(dq
113A certificate has expired or is not currently valid.
114.It \(dqCU\(dq/\(dqcertificate unknown\(dq
115Some other (unspecified) issue arose in processing the certificate,
116rendering it unacceptable.
117.It \(dqIP\(dq/\(dqillegal parameter\(dq
118A field in the handshake was out of range or inconsistent with other fields.
119This is always fatal.
120.It \(dqDC\(dq/\(dqdecryption failed\(dq
121A TLSCiphertext decrypted in an invalid way: either it wasn't an even multiple
122of the block length or its padding values, when checked, weren't correct.
123This message is always fatal.
124.It \(dqRO\(dq/\(dqrecord overflow\(dq
125A TLSCiphertext record was received which had a length more than
1262^14+2048 bytes, or a record decrypted to a TLSCompressed record with more than
1272^14+1024 bytes.
128This message is always fatal.
129.It \(dqCA\(dq/\(dqunknown CA\(dq
130A valid certificate chain or partial chain was received,
131but the certificate was not accepted because the CA certificate could not be
132located or couldn't be matched with a known, trusted CA.
133This message is always fatal.
134.It \(dqAD\(dq/\(dqaccess denied\(dq
135A valid certificate was received, but when access control was applied,
136the sender decided not to proceed with negotiation.
137This message is always fatal.
138.It \(dqDE\(dq/\(dqdecode error\(dq
139A message could not be decoded because some field was out of the specified
140range or the length of the message was incorrect.
141This message is always fatal.
142.It \(dqCY\(dq/\(dqdecrypt error\(dq
143A handshake cryptographic operation failed, including being unable to correctly
144verify a signature, decrypt a key exchange, or validate a finished message.
145.It \(dqER\(dq/\(dqexport restriction\(dq
146A negotiation not in compliance with export restrictions was detected;
147for example, attempting to transfer a 1024 bit ephemeral RSA key for the
148RSA_EXPORT handshake method.
149This message is always fatal.
150.It \(dqPV\(dq/\(dqprotocol version\(dq
151The protocol version the client has attempted to negotiate is recognized,
152but not supported.
153(For example, old protocol versions might be avoided for security reasons.)
154This message is always fatal.
155.It \(dqIS\(dq/\(dqinsufficient security\(dq
156Returned instead of handshake_failure when a negotiation has failed
157specifically because the server requires ciphers more secure than those
158supported by the client.
159This message is always fatal.
160.It \(dqIE\(dq/\(dqinternal error\(dq
161An internal error unrelated to the peer or the correctness of the protocol
162makes it impossible to continue (such as a memory allocation failure).
163This message is always fatal.
164.It \(dqUS\(dq/\(dquser canceled\(dq
165This handshake is being canceled for some reason unrelated to a protocol
166failure.
167If the user cancels an operation after the handshake is complete,
168just closing the connection by sending a close_notify is more appropriate.
169This alert should be followed by a close_notify.
170This message is generally a warning.
171.It \(dqNR\(dq/\(dqno renegotiation\(dq
172Sent by the client in response to a hello request or by the server in response
173to a client hello after initial handshaking.
174Either of these would normally lead to renegotiation; when that is not
175appropriate, the recipient should respond with this alert; at that point,
176the original requester can decide whether to proceed with the connection.
177One case where this would be appropriate would be where a server has spawned a
178process to satisfy a request; the process might receive security parameters
179(key length, authentication, etc.) at startup and it might be difficult to
180communicate changes to these parameters after that point.
181This message is always a warning.
182.It \(dqUP\(dq/\(dqunknown PSK identity\(dq
183Sent by the server to indicate that it does not recognize a PSK identity or an
184SRP identity.
185.It \(dqUK\(dq/\(dqunknown\(dq
186This indicates that no description is available for this alert type.
187Probably
188.Fa value
189does not contain a correct alert message.
190.El
191.Sh SEE ALSO
192.Xr ssl 3 ,
193.Xr SSL_CTX_set_info_callback 3
diff --git a/src/lib/libssl/man/SSL_clear.3 b/src/lib/libssl/man/SSL_clear.3
new file mode 100644
index 0000000000..a9e318320f
--- /dev/null
+++ b/src/lib/libssl/man/SSL_clear.3
@@ -0,0 +1,92 @@
1.\"
2.\" $OpenBSD: SSL_clear.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CLEAR 3
6.Os
7.Sh NAME
8.Nm SSL_clear
9.Nd reset SSL object to allow another connection
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft int
13.Fn SSL_clear "SSL *ssl"
14.Sh DESCRIPTION
15Reset
16.Fa ssl
17to allow another connection.
18All settings (method, ciphers, BIOs) are kept.
19.Sh NOTES
20.Fn SSL_clear
21is used to prepare an
22.Vt SSL
23object for a new connection.
24While all settings are kept,
25a side effect is the handling of the current SSL session.
26If a session is still
27.Em open ,
28it is considered bad and will be removed from the session cache,
29as required by RFC2246.
30A session is considered open if
31.Xr SSL_shutdown 3
32was not called for the connection or at least
33.Xr SSL_set_shutdown 3
34was used to
35set the
36.Dv SSL_SENT_SHUTDOWN
37state.
38.Pp
39If a session was closed cleanly,
40the session object will be kept and all settings corresponding.
41This explicitly means that for example the special method used during the
42session will be kept for the next handshake.
43So if the session was a TLSv1 session, a
44.Vt SSL
45client object will use a TLSv1 client method for the next handshake and a
46.Vt SSL
47server object will use a TLSv1 server method, even if
48.Fn SSLv23_*_method Ns s
49were chosen on startup.
50This might lead to connection failures (see
51.Xr SSL_new 3 )
52for a description of the method's properties.
53.Sh WARNINGS
54.Fn SSL_clear
55resets the
56.Vt SSL
57object to allow for another connection.
58The reset operation however keeps several settings of the last sessions
59(some of these settings were made automatically during the last handshake).
60It only makes sense for a new connection with the exact same peer that shares
61these settings,
62and may fail if that peer changes its settings between connections.
63Use the sequence
64.Xr SSL_get_session 3 ;
65.Xr SSL_new 3 ;
66.Xr SSL_set_session 3 ;
67.Xr SSL_free 3
68instead to avoid such failures (or simply
69.Xr SSL_free 3 ;
70.Xr SSL_new 3
71if session reuse is not desired).
72.Sh RETURN VALUES
73The following return values can occur:
74.Bl -tag -width Ds
75.It 0
76The
77.Fn SSL_clear
78operation could not be performed.
79Check the error stack to find out the reason.
80.It 1
81The
82.Fn SSL_clear
83operation was successful.
84.El
85.Sh SEE ALSO
86.Xr ssl 3 ,
87.Xr SSL_CTX_set_client_cert_cb 3 ,
88.Xr SSL_CTX_set_options 3 ,
89.Xr SSL_free 3 ,
90.Xr SSL_new 3 ,
91.Xr SSL_set_shutdown 3 ,
92.Xr SSL_shutdown 3
diff --git a/src/lib/libssl/man/SSL_connect.3 b/src/lib/libssl/man/SSL_connect.3
new file mode 100644
index 0000000000..761fde3548
--- /dev/null
+++ b/src/lib/libssl/man/SSL_connect.3
@@ -0,0 +1,102 @@
1.\"
2.\" $OpenBSD: SSL_connect.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_CONNECT 3
6.Os
7.Sh NAME
8.Nm SSL_connect
9.Nd initiate the TLS/SSL handshake with a TLS/SSL server
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft int
13.Fn SSL_connect "SSL *ssl"
14.Sh DESCRIPTION
15.Fn SSL_connect
16initiates the TLS/SSL handshake with a server.
17The communication channel must already have been set and assigned to the
18.Fa ssl
19by setting an underlying
20.Vt BIO .
21.Sh NOTES
22The behaviour of
23.Fn SSL_connect
24depends on the underlying
25.Vt BIO .
26.Pp
27If the underlying
28.Vt BIO
29is
30.Em blocking ,
31.Fn SSL_connect
32will only return once the handshake has been finished or an error occurred.
33.Pp
34If the underlying
35.Vt BIO
36is
37.Em non-blocking ,
38.Fn SSL_connect
39will also return when the underlying
40.Vt BIO
41could not satisfy the needs of
42.Fn SSL_connect
43to continue the handshake, indicating the problem with the return value \(mi1.
44In this case a call to
45.Xr SSL_get_error 3
46with the return value of
47.Fn SSL_connect
48will yield
49.Dv SSL_ERROR_WANT_READ
50or
51.Dv SSL_ERROR_WANT_WRITE .
52The calling process then must repeat the call after taking appropriate action
53to satisfy the needs of
54.Fn SSL_connect .
55The action depends on the underlying
56.Vt BIO .
57When using a non-blocking socket, nothing is to be done, but
58.Xr select 2
59can be used to check for the required condition.
60When using a buffering
61.Vt BIO ,
62like a
63.Vt BIO
64pair, data must be written into or retrieved out of the
65.Vt BIO
66before being able to continue.
67.Sh RETURN VALUES
68The following return values can occur:
69.Bl -tag -width Ds
70.It 0
71The TLS/SSL handshake was not successful but was shut down controlled and
72by the specifications of the TLS/SSL protocol.
73Call
74.Xr SSL_get_error 3
75with the return value
76.Fa ret
77to find out the reason.
78.It 1
79The TLS/SSL handshake was successfully completed,
80and a TLS/SSL connection has been established.
81.It <0
82The TLS/SSL handshake was not successful, because either a fatal error occurred
83at the protocol level or a connection failure occurred.
84The shutdown was not clean.
85It can also occur if action is needed to continue the operation for
86non-blocking
87.Vt BIO Ns s.
88Call
89.Xr SSL_get_error 3
90with the return value
91.Fa ret
92to find out the reason.
93.El
94.Sh SEE ALSO
95.Xr bio 3 ,
96.Xr ssl 3 ,
97.Xr SSL_accept 3 ,
98.Xr SSL_CTX_new 3 ,
99.Xr SSL_do_handshake 3 ,
100.Xr SSL_get_error 3 ,
101.Xr SSL_set_connect_state 3 ,
102.Xr SSL_shutdown 3
diff --git a/src/lib/libssl/man/SSL_do_handshake.3 b/src/lib/libssl/man/SSL_do_handshake.3
new file mode 100644
index 0000000000..7f8a9a4509
--- /dev/null
+++ b/src/lib/libssl/man/SSL_do_handshake.3
@@ -0,0 +1,101 @@
1.\"
2.\" $OpenBSD: SSL_do_handshake.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_DO_HANDSHAKE 3
6.Os
7.Sh NAME
8.Nm SSL_do_handshake
9.Nd perform a TLS/SSL handshake
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft int
13.Fn SSL_do_handshake "SSL *ssl"
14.Sh DESCRIPTION
15.Fn SSL_do_handshake
16will wait for a SSL/TLS handshake to take place.
17If the connection is in client mode, the handshake will be started.
18The handshake routines may have to be explicitly set in advance using either
19.Xr SSL_set_connect_state 3
20or
21.Xr SSL_set_accept_state 3 .
22.Sh NOTES
23The behaviour of
24.Fn SSL_do_handshake
25depends on the underlying
26.Vt BIO .
27.Pp
28If the underlying
29.Vt BIO
30is
31.Em blocking ,
32.Fn SSL_do_handshake
33will only return once the handshake has been finished or an error occurred.
34.Pp
35If the underlying
36.Vt BIO
37is
38.Em non-blocking ,
39.Fn SSL_do_handshake
40will also return when the underlying
41.Vt BIO
42could not satisfy the needs of
43.Fn SSL_do_handshake
44to continue the handshake.
45In this case a call to
46.Xr SSL_get_error 3
47with the return value of
48.Fn SSL_do_handshake
49will yield
50.Dv SSL_ERROR_WANT_READ
51or
52.Dv SSL_ERROR_WANT_WRITE .
53The calling process then must repeat the call after taking appropriate action
54to satisfy the needs of
55.Fn SSL_do_handshake .
56The action depends on the underlying
57.Vt BIO .
58When using a non-blocking socket, nothing is to be done, but
59.Xr select 2
60can be used to check for the required condition.
61When using a buffering
62.Vt BIO ,
63like a
64.Vt BIO
65pair, data must be written into or retrieved out of the
66.Vt BIO
67before being able to continue.
68.Sh RETURN VALUES
69The following return values can occur:
70.Bl -tag -width Ds
71.It 0
72The TLS/SSL handshake was not successful but was shut down controlled and
73by the specifications of the TLS/SSL protocol.
74Call
75.Xr SSL_get_error 3
76with the return value
77.Fa ret
78to find out the reason.
79.It 1
80The TLS/SSL handshake was successfully completed,
81and a TLS/SSL connection has been established.
82.It <0
83The TLS/SSL handshake was not successful because either a fatal error occurred
84at the protocol level or a connection failure occurred.
85The shutdown was not clean.
86It can also occur if action is needed to continue the operation for
87non-blocking
88.Vt BIO Ns s.
89Call
90.Xr SSL_get_error 3
91with the return value
92.Fa ret
93to find out the reason.
94.El
95.Sh SEE ALSO
96.Xr bio 3 ,
97.Xr ssl 3 ,
98.Xr SSL_accept 3 ,
99.Xr SSL_connect 3 ,
100.Xr SSL_get_error 3 ,
101.Xr SSL_set_connect_state 3
diff --git a/src/lib/libssl/man/SSL_free.3 b/src/lib/libssl/man/SSL_free.3
new file mode 100644
index 0000000000..fe1e6b8aa5
--- /dev/null
+++ b/src/lib/libssl/man/SSL_free.3
@@ -0,0 +1,67 @@
1.\"
2.\" $OpenBSD: SSL_free.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_FREE 3
6.Os
7.Sh NAME
8.Nm SSL_free
9.Nd free an allocated SSL structure
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft void
13.Fn SSL_free "SSL *ssl"
14.Sh DESCRIPTION
15.Fn SSL_free
16decrements the reference count of
17.Fa ssl ,
18and removes the
19.Vt SSL
20structure pointed to by
21.Fa ssl
22and frees up the allocated memory if the reference count has reached 0.
23If
24.Fa ssl
25is a
26.Dv NULL
27pointer, no action occurs.
28.Sh NOTES
29.Fn SSL_free
30also calls the
31.Xr free 3 Ns
32ing procedures for indirectly affected items, if applicable: the buffering
33.Vt BIO ,
34the read and write
35.Vt BIOs ,
36cipher lists specially created for this
37.Fa ssl ,
38the
39.Sy SSL_SESSION .
40Do not explicitly free these indirectly freed up items before or after calling
41.Fn SSL_free ,
42as trying to free things twice may lead to program failure.
43.Pp
44The
45.Fa ssl
46session has reference counts from two users: the
47.Vt SSL
48object, for which the reference count is removed by
49.Fn SSL_free
50and the internal session cache.
51If the session is considered bad, because
52.Xr SSL_shutdown 3
53was not called for the connection and
54.Xr SSL_set_shutdown 3
55was not used to set the
56.Vt SSL_SENT_SHUTDOWN
57state, the session will also be removed from the session cache as required by
58RFC2246.
59.Sh RETURN VALUES
60.Fn SSL_free
61does not provide diagnostic information.
62.Sh SEE ALSO
63.Xr ssl 3 ,
64.Xr SSL_clear 3 ,
65.Xr SSL_new 3 ,
66.Xr SSL_set_shutdown 3 ,
67.Xr SSL_shutdown 3
diff --git a/src/lib/libssl/man/SSL_get_SSL_CTX.3 b/src/lib/libssl/man/SSL_get_SSL_CTX.3
new file mode 100644
index 0000000000..ee211f8fdc
--- /dev/null
+++ b/src/lib/libssl/man/SSL_get_SSL_CTX.3
@@ -0,0 +1,28 @@
1.\"
2.\" $OpenBSD: SSL_get_SSL_CTX.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_GET_SSL_CTX 3
6.Os
7.Sh NAME
8.Nm SSL_get_SSL_CTX
9.Nd get the SSL_CTX from which an SSL is created
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft SSL_CTX *
13.Fn SSL_get_SSL_CTX "const SSL *ssl"
14.Sh DESCRIPTION
15.Fn SSL_get_SSL_CTX
16returns a pointer to the
17.Vt SSL_CTX
18object from which
19.Fa ssl
20was created with
21.Xr SSL_new 3 .
22.Sh RETURN VALUES
23The pointer to the
24.Vt SSL_CTX
25object is returned.
26.Sh SEE ALSO
27.Xr ssl 3 ,
28.Xr SSL_new 3
diff --git a/src/lib/libssl/man/SSL_get_ciphers.3 b/src/lib/libssl/man/SSL_get_ciphers.3
new file mode 100644
index 0000000000..4469b73f92
--- /dev/null
+++ b/src/lib/libssl/man/SSL_get_ciphers.3
@@ -0,0 +1,68 @@
1.\"
2.\" $OpenBSD: SSL_get_ciphers.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_GET_CIPHERS 3
6.Os
7.Sh NAME
8.Nm SSL_get_ciphers ,
9.Nm SSL_get_cipher_list
10.Nd get list of available SSL_CIPHERs
11.Sh SYNOPSIS
12.In openssl/ssl.h
13.Ft STACK_OF(SSL_CIPHER) *
14.Fn SSL_get_ciphers "const SSL *ssl"
15.Ft const char *
16.Fn SSL_get_cipher_list "const SSL *ssl" "int priority"
17.Sh DESCRIPTION
18.Fn SSL_get_ciphers
19returns the stack of available
20.Vt SSL_CIPHER Ns s
21for
22.Fa ssl ,
23sorted by preference.
24If
25.Fa ssl
26is
27.Dv NULL
28or no ciphers are available,
29.Dv NULL
30is returned.
31.Pp
32.Fn SSL_get_cipher_list
33returns a pointer to the name of the
34.Vt SSL_CIPHER
35listed for
36.Fa ssl
37with
38.Fa priority .
39If
40.Fa ssl
41is
42.Dv NULL ,
43no ciphers are available, or there are fewer ciphers than
44.Fa priority
45available,
46.Dv NULL
47is returned.
48.Sh NOTES
49The details of the ciphers obtained by
50.Fn SSL_get_ciphers
51can be obtained using the
52.Xr SSL_CIPHER_get_name 3
53family of functions.
54.Pp
55Call
56.Fn SSL_get_cipher_list
57with
58.Fa priority
59starting from 0 to obtain the sorted list of available ciphers, until
60.Dv NULL
61is returned.
62.Sh RETURN VALUES
63See
64.Sx DESCRIPTION .
65.Sh SEE ALSO
66.Xr ssl 3 ,
67.Xr SSL_CIPHER_get_name 3 ,
68.Xr SSL_CTX_set_cipher_list 3
diff --git a/src/lib/libssl/man/SSL_get_client_CA_list.3 b/src/lib/libssl/man/SSL_get_client_CA_list.3
new file mode 100644
index 0000000000..6675bc3793
--- /dev/null
+++ b/src/lib/libssl/man/SSL_get_client_CA_list.3
@@ -0,0 +1,61 @@
1.\"
2.\" $OpenBSD: SSL_get_client_CA_list.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_GET_CLIENT_CA_LIST 3
6.Os
7.Sh NAME
8.Nm SSL_get_client_CA_list ,
9.Nm SSL_CTX_get_client_CA_list
10.Nd get list of client CAs
11.Sh SYNOPSIS
12.In openssl/ssl.h
13.Ft STACK_OF(X509_NAME) *
14.Fn SSL_get_client_CA_list "const SSL *s"
15.Ft STACK_OF(X509_NAME) *
16.Fn SSL_CTX_get_client_CA_list "const SSL_CTX *ctx"
17.Sh DESCRIPTION
18.Fn SSL_CTX_get_client_CA_list
19returns the list of client CAs explicitly set for
20.Fa ctx
21using
22.Xr SSL_CTX_set_client_CA_list 3 .
23.Pp
24.Fn SSL_get_client_CA_list
25returns the list of client CAs explicitly set for
26.Fa ssl
27using
28.Fn SSL_set_client_CA_list
29or
30.Fa ssl Ns 's
31.Vt SSL_CTX
32object with
33.Xr SSL_CTX_set_client_CA_list 3 ,
34when in server mode.
35In client mode,
36.Fn SSL_get_client_CA_list
37returns the list of client CAs sent from the server, if any.
38.Sh RETURN VALUES
39.Fn SSL_CTX_set_client_CA_list
40and
41.Fn SSL_set_client_CA_list
42do not return diagnostic information.
43.Pp
44.Fn SSL_CTX_add_client_CA
45and
46.Fn SSL_add_client_CA
47have the following return values:
48.Bl -tag -width Ds
49.It Dv STACK_OF Ns Po Vt X509_NAMES Pc
50List of CA names explicitly set (for
51.Fa ctx
52or in server mode) or sent by the server (client mode).
53.It Dv NULL
54No client CA list was explicitly set (for
55.Fa ctx
56or in server mode) or the server did not send a list of CAs (client mode).
57.El
58.Sh SEE ALSO
59.Xr ssl 3 ,
60.Xr SSL_CTX_set_client_CA_list 3 ,
61.Xr SSL_CTX_set_client_cert_cb 3
diff --git a/src/lib/libssl/man/SSL_get_current_cipher.3 b/src/lib/libssl/man/SSL_get_current_cipher.3
new file mode 100644
index 0000000000..de46f3d21c
--- /dev/null
+++ b/src/lib/libssl/man/SSL_get_current_cipher.3
@@ -0,0 +1,52 @@
1.\"
2.\" $OpenBSD: SSL_get_current_cipher.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_GET_CURRENT_CIPHER 3
6.Os
7.Sh NAME
8.Nm SSL_get_current_cipher ,
9.Nm SSL_get_cipher ,
10.Nm SSL_get_cipher_name ,
11.Nm SSL_get_cipher_bits ,
12.Nm SSL_get_cipher_version
13.Nd get SSL_CIPHER of a connection
14.Sh SYNOPSIS
15.In openssl/ssl.h
16.Ft SSL_CIPHER *
17.Fn SSL_get_current_cipher "const SSL *ssl"
18.Fd #define SSL_get_cipher(s) SSL_CIPHER_get_name(SSL_get_current_cipher(s))
19.Fd #define SSL_get_cipher_name(s) \
20SSL_CIPHER_get_name(SSL_get_current_cipher(s))
21.Fd #define SSL_get_cipher_bits(s,np) \
22SSL_CIPHER_get_bits(SSL_get_current_cipher(s),np)
23.Fd #define SSL_get_cipher_version(s) \
24SSL_CIPHER_get_version(SSL_get_current_cipher(s))
25.Sh DESCRIPTION
26.Fn SSL_get_current_cipher
27returns a pointer to an
28.Vt SSL_CIPHER
29object containing the description of the actually used cipher of a connection
30established with the
31.Fa ssl
32object.
33.Pp
34.Fn SSL_get_cipher
35and
36.Fn SSL_get_cipher_name
37are identical macros to obtain the name of the currently used cipher.
38.Fn SSL_get_cipher_bits
39is a macro to obtain the number of secret/algorithm bits used and
40.Fn SSL_get_cipher_version
41returns the protocol name.
42See
43.Xr SSL_CIPHER_get_name 3
44for more details.
45.Sh RETURN VALUES
46.Fn SSL_get_current_cipher
47returns the cipher actually used or
48.Dv NULL ,
49when no session has been established.
50.Sh SEE ALSO
51.Xr ssl 3 ,
52.Xr SSL_CIPHER_get_name 3
diff --git a/src/lib/libssl/man/SSL_get_default_timeout.3 b/src/lib/libssl/man/SSL_get_default_timeout.3
new file mode 100644
index 0000000000..a14d8041e2
--- /dev/null
+++ b/src/lib/libssl/man/SSL_get_default_timeout.3
@@ -0,0 +1,36 @@
1.\"
2.\" $OpenBSD: SSL_get_default_timeout.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_GET_DEFAULT_TIMEOUT 3
6.Os
7.Sh NAME
8.Nm SSL_get_default_timeout
9.Nd get default session timeout value
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft long
13.Fn SSL_get_default_timeout "const SSL *ssl"
14.Sh DESCRIPTION
15.Fn SSL_get_default_timeout
16returns the default timeout value assigned to
17.Vt SSL_SESSION
18objects negotiated for the protocol valid for
19.Fa ssl .
20.Sh NOTES
21Whenever a new session is negotiated, it is assigned a timeout value,
22after which it will not be accepted for session reuse.
23If the timeout value was not explicitly set using
24.Xr SSL_CTX_set_timeout 3 ,
25the hardcoded default timeout for the protocol will be used.
26.Pp
27.Fn SSL_get_default_timeout
28return this hardcoded value, which is 300 seconds for all currently supported
29protocols (SSLv2, SSLv3, and TLSv1).
30.Sh RETURN VALUES
31See description.
32.Sh SEE ALSO
33.Xr ssl 3 ,
34.Xr SSL_CTX_flush_sessions 3 ,
35.Xr SSL_CTX_set_session_cache_mode 3 ,
36.Xr SSL_SESSION_get_time 3
diff --git a/src/lib/libssl/man/SSL_get_error.3 b/src/lib/libssl/man/SSL_get_error.3
new file mode 100644
index 0000000000..b3e7c9e491
--- /dev/null
+++ b/src/lib/libssl/man/SSL_get_error.3
@@ -0,0 +1,169 @@
1.\"
2.\" $OpenBSD: SSL_get_error.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_GET_ERROR 3
6.Os
7.Sh NAME
8.Nm SSL_get_error
9.Nd obtain result code for TLS/SSL I/O operation
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft int
13.Fn SSL_get_error "const SSL *ssl" "int ret"
14.Sh DESCRIPTION
15.Fn SSL_get_error
16returns a result code (suitable for the C
17.Dq switch
18statement) for a preceding call to
19.Xr SSL_connect 3 ,
20.Xr SSL_accept 3 ,
21.Xr SSL_do_handshake 3 ,
22.Xr SSL_read 3 ,
23.Xr SSL_peek 3 ,
24or
25.Xr SSL_write 3
26on
27.Fa ssl .
28The value returned by that TLS/SSL I/O function must be passed to
29.Fn SSL_get_error
30in parameter
31.Fa ret .
32.Pp
33In addition to
34.Fa ssl
35and
36.Fa ret ,
37.Fn SSL_get_error
38inspects the current thread's OpenSSL error queue.
39Thus,
40.Fn SSL_get_error
41must be used in the same thread that performed the TLS/SSL I/O operation,
42and no other OpenSSL function calls should appear in between.
43The current thread's error queue must be empty before the TLS/SSL I/O operation
44is attempted, or
45.Fn SSL_get_error
46will not work reliably.
47.Sh RETURN VALUES
48The following return values can currently occur:
49.Bl -tag -width Ds
50.It Dv SSL_ERROR_NONE
51The TLS/SSL I/O operation completed.
52This result code is returned if and only if
53.Fa ret
54< 0.
55.It Dv SSL_ERROR_ZERO_RETURN
56The TLS/SSL connection has been closed.
57If the protocol version is SSL 3.0 or TLS 1.0, this result code is returned
58only if a closure alert has occurred in the protocol, i.e., if the connection
59has been closed cleanly.
60Note that in this case
61.Dv SSL_ERROR_ZERO_RETURN
62does not necessarily indicate that the underlying transport has been closed.
63.It Dv SSL_ERROR_WANT_READ , Dv SSL_ERROR_WANT_WRITE
64The operation did not complete;
65the same TLS/SSL I/O function should be called again later.
66If, by then, the underlying
67.Vt BIO
68has data available for reading (if the result code is
69.Dv SSL_ERROR_WANT_READ )
70or allows writing data
71.Pq Dv SSL_ERROR_WANT_WRITE ,
72then some TLS/SSL protocol progress will take place,
73i.e., at least part of a TLS/SSL record will be read or written.
74Note that the retry may again lead to a
75.Dv SSL_ERROR_WANT_READ
76or
77.Dv SSL_ERROR_WANT_WRITE
78condition.
79There is no fixed upper limit for the number of iterations that may be
80necessary until progress becomes visible at application protocol level.
81.Pp
82For socket
83.Fa BIO Ns
84s (e.g., when
85.Fn SSL_set_fd
86was used),
87.Xr select 2
88or
89.Xr poll 2
90on the underlying socket can be used to find out when the TLS/SSL I/O function
91should be retried.
92.Pp
93Caveat: Any TLS/SSL I/O function can lead to either of
94.Dv SSL_ERROR_WANT_READ
95and
96.Dv SSL_ERROR_WANT_WRITE .
97In particular,
98.Xr SSL_read 3
99or
100.Xr SSL_peek 3
101may want to write data and
102.Xr SSL_write 3
103may want
104to read data.
105This is mainly because TLS/SSL handshakes may occur at any time during the
106protocol (initiated by either the client or the server);
107.Xr SSL_read 3 ,
108.Xr SSL_peek 3 ,
109and
110.Xr SSL_write 3
111will handle any pending handshakes.
112.It Dv SSL_ERROR_WANT_CONNECT , Dv SSL_ERROR_WANT_ACCEPT
113The operation did not complete; the same TLS/SSL I/O function should be
114called again later.
115The underlying BIO was not connected yet to the peer and the call would block
116in
117.Xr connect 2 Ns / Ns
118.Xr accept 2 .
119The SSL function should be
120called again when the connection is established.
121These messages can only appear with a
122.Xr BIO_s_connect 3
123or
124.Xr BIO_s_accept 3
125.Vt BIO ,
126respectively.
127In order to find out when the connection has been successfully established,
128on many platforms
129.Xr select 2
130or
131.Xr poll 2
132for writing on the socket file descriptor can be used.
133.It Dv SSL_ERROR_WANT_X509_LOOKUP
134The operation did not complete because an application callback set by
135.Xr SSL_CTX_set_client_cert_cb 3
136has asked to be called again.
137The TLS/SSL I/O function should be called again later.
138Details depend on the application.
139.It Dv SSL_ERROR_SYSCALL
140Some I/O error occurred.
141The OpenSSL error queue may contain more information on the error.
142If the error queue is empty (i.e.,
143.Fn ERR_get_error
144returns 0),
145.Fa ret
146can be used to find out more about the error:
147If
148.Fa ret
149== 0, an
150.Dv EOF
151was observed that violates the protocol.
152If
153.Fa ret
154== \(mi1, the underlying
155.Vt BIO
156reported an
157I/O error (for socket I/O on Unix systems, consult
158.Dv errno
159for details).
160.It Dv SSL_ERROR_SSL
161A failure in the SSL library occurred, usually a protocol error.
162The OpenSSL error queue contains more information on the error.
163.El
164.Sh SEE ALSO
165.Xr err 3 ,
166.Xr ssl 3
167.Sh HISTORY
168.Fn SSL_get_error
169was added in SSLeay 0.8.
diff --git a/src/lib/libssl/man/SSL_get_ex_data_X509_STORE_CTX_idx.3 b/src/lib/libssl/man/SSL_get_ex_data_X509_STORE_CTX_idx.3
new file mode 100644
index 0000000000..ab9b7ae376
--- /dev/null
+++ b/src/lib/libssl/man/SSL_get_ex_data_X509_STORE_CTX_idx.3
@@ -0,0 +1,65 @@
1.\"
2.\" $OpenBSD: SSL_get_ex_data_X509_STORE_CTX_idx.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_GET_EX_DATA_X509_STORE_CTX_IDX 3
6.Os
7.Sh NAME
8.Nm SSL_get_ex_data_X509_STORE_CTX_idx
9.Nd get ex_data index to access SSL structure from X509_STORE_CTX
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft int
13.Fn SSL_get_ex_data_X509_STORE_CTX_idx void
14.Sh DESCRIPTION
15.Fn SSL_get_ex_data_X509_STORE_CTX_idx
16returns the index number under which the pointer to the
17.Vt SSL
18object is stored into the
19.Vt X509_STORE_CTX
20object.
21.Sh NOTES
22Whenever a
23.Vt X509_STORE_CTX
24object is created for the verification of the peer's certificate during a
25handshake, a pointer to the
26.Vt SSL
27object is stored into the
28.Vt X509_STORE_CTX
29object to identify the connection affected.
30To retrieve this pointer the
31.Xr X509_STORE_CTX_get_ex_data 3
32function can be used with the correct index.
33This index is globally the same for all
34.Vt X509_STORE_CTX
35objects and can be retrieved using
36.Fn SSL_get_ex_data_X509_STORE_CTX_idx .
37The index value is set when
38.Fn SSL_get_ex_data_X509_STORE_CTX_idx
39is first called either by the application program directly or indirectly during
40other SSL setup functions or during the handshake.
41.Pp
42The value depends on other index values defined for
43.Vt X509_STORE_CTX
44objects before the SSL index is created.
45.Sh RETURN VALUES
46.Bl -tag -width Ds
47.It \(>=0
48The index value to access the pointer.
49.It <0
50An error occurred, check the error stack for a detailed error message.
51.El
52.Sh EXAMPLES
53The index returned from
54.Fn SSL_get_ex_data_X509_STORE_CTX_idx
55provides access to
56.Vt SSL
57object for the connection during the
58.Fn verify_callback
59when checking the peer's certificate.
60Please check the example in
61.Xr SSL_CTX_set_verify 3 .
62.Sh SEE ALSO
63.Xr CRYPTO_set_ex_data 3 ,
64.Xr ssl 3 ,
65.Xr SSL_CTX_set_verify 3
diff --git a/src/lib/libssl/man/SSL_get_ex_new_index.3 b/src/lib/libssl/man/SSL_get_ex_new_index.3
new file mode 100644
index 0000000000..87cb281560
--- /dev/null
+++ b/src/lib/libssl/man/SSL_get_ex_new_index.3
@@ -0,0 +1,76 @@
1.\"
2.\" $OpenBSD: SSL_get_ex_new_index.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_GET_EX_NEW_INDEX 3
6.Os
7.Sh NAME
8.Nm SSL_get_ex_new_index ,
9.Nm SSL_set_ex_data ,
10.Nm SSL_get_ex_data
11.Nd internal application specific data functions
12.Sh SYNOPSIS
13.In openssl/ssl.h
14.Ft int
15.Fo SSL_get_ex_new_index
16.Fa "long argl"
17.Fa "void *argp"
18.Fa "CRYPTO_EX_new *new_func"
19.Fa "CRYPTO_EX_dup *dup_func"
20.Fa "CRYPTO_EX_free *free_func"
21.Fc
22.Ft int
23.Fn SSL_set_ex_data "SSL *ssl" "int idx" "void *arg"
24.Ft void *
25.Fn SSL_get_ex_data "const SSL *ssl" "int idx"
26.Bd -literal
27typedef int new_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
28 int idx, long argl, void *argp);
29typedef void free_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
30 int idx, long argl, void *argp);
31typedef int dup_func(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
32 int idx, long argl, void *argp);
33.Ed
34.Sh DESCRIPTION
35Several OpenSSL structures can have application specific data attached to them.
36These functions are used internally by OpenSSL to manipulate application
37specific data attached to a specific structure.
38.Pp
39.Fn SSL_get_ex_new_index
40is used to register a new index for application specific data.
41.Pp
42.Fn SSL_set_ex_data
43is used to store application data at
44.Fa arg
45for
46.Fa idx
47into the
48.Fa ssl
49object.
50.Pp
51.Fn SSL_get_ex_data
52is used to retrieve the information for
53.Fa idx
54from
55.Fa ssl .
56.Pp
57A detailed description for the
58.Fn *_get_ex_new_index
59functionality can be found in
60.Xr RSA_get_ex_new_index 3 .
61The
62.Fn *_get_ex_data
63and
64.Fn *_set_ex_data
65functionality is described in
66.Xr CRYPTO_set_ex_data 3 .
67.Sh EXAMPLES
68An example of how to use the functionality is included in the example
69.Fn verify_callback
70in
71.Xr SSL_CTX_set_verify 3 .
72.Sh SEE ALSO
73.Xr CRYPTO_set_ex_data 3 ,
74.Xr RSA_get_ex_new_index 3 ,
75.Xr ssl 3 ,
76.Xr SSL_CTX_set_verify 3
diff --git a/src/lib/libssl/man/SSL_get_fd.3 b/src/lib/libssl/man/SSL_get_fd.3
new file mode 100644
index 0000000000..e21e75f978
--- /dev/null
+++ b/src/lib/libssl/man/SSL_get_fd.3
@@ -0,0 +1,46 @@
1.\"
2.\" $OpenBSD: SSL_get_fd.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_GET_FD 3
6.Os
7.Sh NAME
8.Nm SSL_get_fd ,
9.Nm SSL_get_rfd ,
10.Nm SSL_get_wfd
11.Nd get file descriptor linked to an SSL object
12.Sh SYNOPSIS
13.In openssl/ssl.h
14.Ft int
15.Fn SSL_get_fd "const SSL *ssl"
16.Ft int
17.Fn SSL_get_rfd "const SSL *ssl"
18.Ft int
19.Fn SSL_get_wfd "const SSL *ssl"
20.Sh DESCRIPTION
21.Fn SSL_get_fd
22returns the file descriptor which is linked to
23.Fa ssl .
24.Fn SSL_get_rfd
25and
26.Fn SSL_get_wfd
27return the file descriptors for the read or the write channel,
28which can be different.
29If the read and the write channel are different,
30.Fn SSL_get_fd
31will return the file descriptor of the read channel.
32.Sh RETURN VALUES
33The following return values can occur:
34.Bl -tag -width Ds
35.It \(mi1
36The operation failed, because the underlying
37.Vt BIO
38is not of the correct type (suitable for file descriptors).
39.It \(>=0
40The file descriptor linked to
41.Fa ssl .
42.El
43.Sh SEE ALSO
44.Xr bio 3 ,
45.Xr ssl 3 ,
46.Xr SSL_set_fd 3
diff --git a/src/lib/libssl/man/SSL_get_peer_cert_chain.3 b/src/lib/libssl/man/SSL_get_peer_cert_chain.3
new file mode 100644
index 0000000000..bf5d04f3cf
--- /dev/null
+++ b/src/lib/libssl/man/SSL_get_peer_cert_chain.3
@@ -0,0 +1,47 @@
1.\"
2.\" $OpenBSD: SSL_get_peer_cert_chain.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_GET_PEER_CERT_CHAIN 3
6.Os
7.Sh NAME
8.Nm SSL_get_peer_cert_chain
9.Nd get the X509 certificate chain of the peer
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft STACK_OF(X509) *
13.Fn SSL_get_peer_cert_chain "const SSL *ssl"
14.Sh DESCRIPTION
15.Fn SSL_get_peer_cert_chain
16returns a pointer to
17.Dv STACK_OF Ns Po Vt X509 Pc
18certificates forming the certificate chain of the peer.
19If called on the client side, the stack also contains the peer's certificate;
20if called on the server side, the peer's certificate must be obtained
21separately using
22.Xr SSL_get_peer_certificate 3 .
23If the peer did not present a certificate,
24.Dv NULL
25is returned.
26.Sh NOTES
27The peer certificate chain is not necessarily available after reusing a
28session, in which case a
29.Dv NULL
30pointer is returned.
31.Pp
32The reference count of the
33.Dv STACK_OF Ns Po Vt X509 Pc
34object is not incremented.
35If the corresponding session is freed, the pointer must not be used any longer.
36.Sh RETURN VALUES
37The following return values can occur:
38.Bl -tag -width Ds
39.It Dv NULL
40No certificate was presented by the peer or no connection was established or
41the certificate chain is no longer available when a session is reused.
42.It Pointer to a Dv STACK_OF Ns Po X509 Pc
43The return value points to the certificate chain presented by the peer.
44.El
45.Sh SEE ALSO
46.Xr ssl 3 ,
47.Xr SSL_get_peer_certificate 3
diff --git a/src/lib/libssl/man/SSL_get_peer_certificate.3 b/src/lib/libssl/man/SSL_get_peer_certificate.3
new file mode 100644
index 0000000000..f1b34dfa08
--- /dev/null
+++ b/src/lib/libssl/man/SSL_get_peer_certificate.3
@@ -0,0 +1,53 @@
1.\"
2.\" $OpenBSD: SSL_get_peer_certificate.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_GET_PEER_CERTIFICATE 3
6.Os
7.Sh NAME
8.Nm SSL_get_peer_certificate
9.Nd get the X509 certificate of the peer
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft X509 *
13.Fn SSL_get_peer_certificate "const SSL *ssl"
14.Sh DESCRIPTION
15.Fn SSL_get_peer_certificate
16returns a pointer to the X509 certificate the peer presented.
17If the peer did not present a certificate,
18.Dv NULL
19is returned.
20.Sh NOTES
21Due to the protocol definition, a TLS/SSL server will always send a
22certificate, if present.
23A client will only send a certificate when explicitly requested to do so by the
24server (see
25.Xr SSL_CTX_set_verify 3 ) .
26If an anonymous cipher is used, no certificates are sent.
27.Pp
28That a certificate is returned does not indicate information about the
29verification state.
30Use
31.Xr SSL_get_verify_result 3
32to check the verification state.
33.Pp
34The reference count of the
35.Vt X509
36object is incremented by one, so that it will not be destroyed when the session
37containing the peer certificate is freed.
38The
39.Vt X509
40object must be explicitly freed using
41.Xr X509_free 3 .
42.Sh RETURN VALUES
43The following return values can occur:
44.Bl -tag -width Ds
45.It Dv NULL
46No certificate was presented by the peer or no connection was established.
47.It Pointer to an X509 certificate
48The return value points to the certificate presented by the peer.
49.El
50.Sh SEE ALSO
51.Xr ssl 3 ,
52.Xr SSL_CTX_set_verify 3 ,
53.Xr SSL_get_verify_result 3
diff --git a/src/lib/libssl/man/SSL_get_psk_identity.3 b/src/lib/libssl/man/SSL_get_psk_identity.3
new file mode 100644
index 0000000000..a2f91ee1c7
--- /dev/null
+++ b/src/lib/libssl/man/SSL_get_psk_identity.3
@@ -0,0 +1,44 @@
1.\"
2.\" $OpenBSD: SSL_get_psk_identity.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_GET_PSK_IDENTITY 3
6.Os
7.Sh NAME
8.Nm SSL_get_psk_identity ,
9.Nm SSL_get_psk_identity_hint
10.Nd get PSK client identity and hint
11.Sh SYNOPSIS
12.In openssl/ssl.h
13.Ft const char *
14.Fn SSL_get_psk_identity_hint "const SSL *ssl"
15.Ft const char *
16.Fn SSL_get_psk_identity "const SSL *ssl"
17.Sh DESCRIPTION
18.Fn SSL_get_psk_identity_hint
19is used to retrieve the PSK identity hint used during the connection setup
20related to
21.Vt SSL
22object
23.Fa ssl .
24Similarly,
25.Fn SSL_get_psk_identity
26is used to retrieve the PSK identity used during the connection setup.
27.Sh RETURN VALUES
28If
29.Pf non- Dv NULL ,
30.Fn SSL_get_psk_identity_hint
31returns the PSK identity hint and
32.Fn SSL_get_psk_identity
33returns the PSK identity.
34Both are
35.Dv NULL Ns -terminated.
36.Fn SSL_get_psk_identity_hint
37may return
38.Dv NULL
39if no PSK identity hint was used during the connection setup.
40.Pp
41Note that the return value is valid only during the lifetime of the
42.Vt SSL
43object
44.Fa ssl .
diff --git a/src/lib/libssl/man/SSL_get_rbio.3 b/src/lib/libssl/man/SSL_get_rbio.3
new file mode 100644
index 0000000000..adef98ec6a
--- /dev/null
+++ b/src/lib/libssl/man/SSL_get_rbio.3
@@ -0,0 +1,45 @@
1.\"
2.\" $OpenBSD: SSL_get_rbio.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_GET_RBIO 3
6.Os
7.Sh NAME
8.Nm SSL_get_rbio ,
9.Nm SSL_get_wbio
10.Nd get BIO linked to an SSL object
11.Sh SYNOPSIS
12.In openssl/ssl.h
13.Ft BIO *
14.Fn SSL_get_rbio "SSL *ssl"
15.Ft BIO *
16.Fn SSL_get_wbio "SSL *ssl"
17.Sh DESCRIPTION
18.Fn SSL_get_rbio
19and
20.Fn SSL_get_wbio
21return pointers to the
22.Vt BIO Ns s
23for the read or the write channel, which can be different.
24The reference count of the
25.Vt BIO
26is not incremented.
27.Sh RETURN VALUES
28The following return values can occur:
29.Bl -tag -width Ds
30.It Dv NULL
31No
32.Vt BIO
33was connected to the
34.Vt SSL
35object.
36.It Any other pointer
37The
38.Vt BIO
39linked to
40.Fa ssl .
41.El
42.Sh SEE ALSO
43.Xr bio 3 ,
44.Xr ssl 3 ,
45.Xr SSL_set_bio 3
diff --git a/src/lib/libssl/man/SSL_get_session.3 b/src/lib/libssl/man/SSL_get_session.3
new file mode 100644
index 0000000000..03e47c59c2
--- /dev/null
+++ b/src/lib/libssl/man/SSL_get_session.3
@@ -0,0 +1,97 @@
1.\"
2.\" $OpenBSD: SSL_get_session.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_GET_SESSION 3
6.Os
7.Sh NAME
8.Nm SSL_get_session ,
9.Nm SSL_get0_session ,
10.Nm SSL_get1_session
11.Nd retrieve TLS/SSL session data
12.Sh SYNOPSIS
13.In openssl/ssl.h
14.Ft SSL_SESSION *
15.Fn SSL_get_session "const SSL *ssl"
16.Ft SSL_SESSION *
17.Fn SSL_get0_session "const SSL *ssl"
18.Ft SSL_SESSION *
19.Fn SSL_get1_session "SSL *ssl"
20.Sh DESCRIPTION
21.Fn SSL_get_session
22returns a pointer to the
23.Vt SSL_SESSION
24actually used in
25.Fa ssl .
26The reference count of the
27.Vt SSL_SESSION
28is not incremented, so that the pointer can become invalid by other operations.
29.Pp
30.Fn SSL_get0_session
31is the same as
32.Fn SSL_get_session .
33.Pp
34.Fn SSL_get1_session
35is the same as
36.Fn SSL_get_session ,
37but the reference count of the
38.Vt SSL_SESSION
39is incremented by one.
40.Sh NOTES
41The
42Fa ssl
43session contains all information required to re-establish the connection
44without a new handshake.
45.Pp
46.Fn SSL_get0_session
47returns a pointer to the actual session.
48As the reference counter is not incremented,
49the pointer is only valid while the connection is in use.
50If
51.Xr SSL_clear 3
52or
53.Xr SSL_free 3
54is called, the session may be removed completely (if considered bad),
55and the pointer obtained will become invalid.
56Even if the session is valid,
57it can be removed at any time due to timeout during
58.Xr SSL_CTX_flush_sessions 3 .
59.Pp
60If the data is to be kept,
61.Fn SSL_get1_session
62will increment the reference count, so that the session will not be implicitly
63removed by other operations but stays in memory.
64In order to remove the session
65.Xr SSL_SESSION_free 3
66must be explicitly called once to decrement the reference count again.
67.Pp
68.Vt SSL_SESSION
69objects keep internal link information about the session cache list when being
70inserted into one
71.Vt SSL_CTX
72object's session cache.
73One
74.Vt SSL_SESSION
75object, regardless of its reference count, must therefore only be used with one
76.Vt SSL_CTX
77object (and the
78.Vt SSL
79objects created from this
80.Vt SSL_CTX
81object).
82.Sh RETURN VALUES
83The following return values can occur:
84.Bl -tag -width Ds
85.It Dv NULL
86There is no session available in
87.Fa ssl .
88.It Pointer to an Vt SSL
89The return value points to the data of an
90.Vt SSL
91session.
92.El
93.Sh SEE ALSO
94.Xr ssl 3 ,
95.Xr SSL_clear 3 ,
96.Xr SSL_free 3 ,
97.Xr SSL_SESSION_free 3
diff --git a/src/lib/libssl/man/SSL_get_verify_result.3 b/src/lib/libssl/man/SSL_get_verify_result.3
new file mode 100644
index 0000000000..d93feee3be
--- /dev/null
+++ b/src/lib/libssl/man/SSL_get_verify_result.3
@@ -0,0 +1,49 @@
1.\"
2.\" $OpenBSD: SSL_get_verify_result.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_GET_VERIFY_RESULT 3
6.Os
7.Sh NAME
8.Nm SSL_get_verify_result
9.Nd get result of peer certificate verification
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft long
13.Fn SSL_get_verify_result "const SSL *ssl"
14.Sh DESCRIPTION
15.Fn SSL_get_verify_result
16returns the result of the verification of the X509 certificate presented by the
17peer, if any.
18.Sh NOTES
19.Fn SSL_get_verify_result
20can only return one error code while the verification of a certificate can fail
21because of many reasons at the same time.
22Only the last verification error that occurred during the processing is
23available from
24.Fn SSL_get_verify_result .
25.Pp
26The verification result is part of the established session and is restored when
27a session is reused.
28.Sh RETURN VALUES
29The following return values can currently occur:
30.Bl -tag -width Ds
31.It Dv X509_V_OK
32The verification succeeded or no peer certificate was presented.
33.It Any other value
34Documented in
35.Xr openssl 1 .
36.El
37.Sh SEE ALSO
38.Xr openssl 1 ,
39.Xr ssl 3 ,
40.Xr SSL_get_peer_certificate 3 ,
41.Xr SSL_set_verify_result 3
42.Sh BUGS
43If no peer certificate was presented, the returned result code is
44.Dv X509_V_OK .
45This is because no verification error occurred;
46however, it does not indicate success.
47.Fn SSL_get_verify_result
48is only useful in connection with
49.Xr SSL_get_peer_certificate 3 .
diff --git a/src/lib/libssl/man/SSL_get_version.3 b/src/lib/libssl/man/SSL_get_version.3
new file mode 100644
index 0000000000..ebbee0cb15
--- /dev/null
+++ b/src/lib/libssl/man/SSL_get_version.3
@@ -0,0 +1,35 @@
1.\"
2.\" $OpenBSD: SSL_get_version.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_GET_VERSION 3
6.Os
7.Sh NAME
8.Nm SSL_get_version
9.Nd get the protocol version of a connection
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft const char *
13.Fn SSL_get_version "const SSL *ssl"
14.Sh DESCRIPTION
15.Fn SSL_get_version
16returns the name of the protocol used for the connection
17.Fa ssl .
18.Sh RETURN VALUES
19The following strings can be returned:
20.Bl -tag -width Ds
21.It Qq SSLv2
22The connection uses the SSLv2 protocol.
23.It Qq SSLv3
24The connection uses the SSLv3 protocol.
25.It Qq TLSv1
26The connection uses the TLSv1.0 protocol.
27.It Qq TLSv1.1
28The connection uses the TLSv1.1 protocol.
29.It Qq TLSv1.2
30The connection uses the TLSv1.2 protocol.
31.It Qq unknown
32This indicates that no version has been set (no connection established).
33.El
34.Sh SEE ALSO
35.Xr ssl 3
diff --git a/src/lib/libssl/man/SSL_library_init.3 b/src/lib/libssl/man/SSL_library_init.3
new file mode 100644
index 0000000000..ab5326bc4d
--- /dev/null
+++ b/src/lib/libssl/man/SSL_library_init.3
@@ -0,0 +1,54 @@
1.\"
2.\" $OpenBSD: SSL_library_init.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_LIBRARY_INIT 3
6.Os
7.Sh NAME
8.Nm SSL_library_init ,
9.Nm OpenSSL_add_ssl_algorithms ,
10.Nm SSLeay_add_ssl_algorithms
11.Nd initialize SSL library by registering algorithms
12.Sh SYNOPSIS
13.In openssl/ssl.h
14.Ft int
15.Fn SSL_library_init void
16.Fd #define OpenSSL_add_ssl_algorithms() SSL_library_init()
17.Fd #define SSLeay_add_ssl_algorithms() SSL_library_init()
18.Sh DESCRIPTION
19.Fn SSL_library_init
20registers the available SSL/TLS ciphers and digests.
21.Pp
22.Fn OpenSSL_add_ssl_algorithms
23and
24.Fn SSLeay_add_ssl_algorithms
25are synonyms for
26.Fn SSL_library_init .
27.Sh NOTES
28.Fn SSL_library_init
29must be called before any other action takes place.
30.Fn SSL_library_init
31is not reentrant.
32.Sh WARNING
33.Fn SSL_library_init
34adds ciphers and digests used directly and indirectly by SSL/TLS.
35.Sh RETURN VALUES
36.Fn SSL_library_init
37always returns 1, so it is safe to discard the return value.
38.Sh EXAMPLES
39A typical TLS/SSL application will start with the library initialization, and
40provide readable error messages.
41.Bd -literal
42SSL_load_error_strings(); /* readable error messages */
43SSL_library_init(); /* initialize library */
44.Ed
45.Sh NOTES
46OpenSSL 0.9.8o and 1.0.0a and later added SHA2 algorithms to
47.Fn SSL_library_init .
48Applications which need to use SHA2 in earlier versions of OpenSSL should call
49.Fn OpenSSL_add_all_algorithms
50as well.
51.Sh SEE ALSO
52.Xr RAND_add 3 ,
53.Xr ssl 3 ,
54.Xr SSL_load_error_strings 3
diff --git a/src/lib/libssl/man/SSL_load_client_CA_file.3 b/src/lib/libssl/man/SSL_load_client_CA_file.3
new file mode 100644
index 0000000000..21d8054fd4
--- /dev/null
+++ b/src/lib/libssl/man/SSL_load_client_CA_file.3
@@ -0,0 +1,53 @@
1.\"
2.\" $OpenBSD: SSL_load_client_CA_file.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_LOAD_CLIENT_CA_FILE 3
6.Os
7.Sh NAME
8.Nm SSL_load_client_CA_file
9.Nd load certificate names from file
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft STACK_OF(X509_NAME) *
13.Fn SSL_load_client_CA_file "const char *file"
14.Sh DESCRIPTION
15.Fn SSL_load_client_CA_file
16reads certificates from
17.Fa file
18and returns a
19.Dv STACK_OF Ns
20.Pq Vt X509_NAME
21with the subject names found.
22.Sh NOTES
23.Fn SSL_load_client_CA_file
24reads a file of PEM formatted certificates and extracts the
25.Vt X509_NAME Ns s
26of the certificates found.
27While the name suggests the specific usage as support function for
28.Xr SSL_CTX_set_client_CA_list 3 ,
29it is not limited to CA certificates.
30.Sh RETURN VALUES
31The following return values can occur:
32.Bl -tag -width Ds
33.It Dv NULL
34The operation failed, check out the error stack for the reason.
35.It Pointer to Dv STACK_OF Ns Po Vt X509_NAME Pc
36Pointer to the subject names of the successfully read certificates.
37.El
38.Sh EXAMPLES
39Load names of CAs from file and use it as a client CA list:
40.Bd -literal
41SSL_CTX *ctx;
42STACK_OF(X509_NAME) *cert_names;
43\&...
44cert_names = SSL_load_client_CA_file("/path/to/CAfile.pem");
45if (cert_names != NULL)
46 SSL_CTX_set_client_CA_list(ctx, cert_names);
47else
48 error_handling();
49\&...
50.Ed
51.Sh SEE ALSO
52.Xr ssl 3 ,
53.Xr SSL_CTX_set_client_CA_list 3
diff --git a/src/lib/libssl/man/SSL_new.3 b/src/lib/libssl/man/SSL_new.3
new file mode 100644
index 0000000000..14883f46ad
--- /dev/null
+++ b/src/lib/libssl/man/SSL_new.3
@@ -0,0 +1,41 @@
1.\"
2.\" $OpenBSD: SSL_new.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_NEW 3
6.Os
7.Sh NAME
8.Nm SSL_new
9.Nd create a new SSL structure for a connection
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft SSL *
13.Fn SSL_new "SSL_CTX *ctx"
14.Sh DESCRIPTION
15.Fn SSL_new
16creates a new
17.Vt SSL
18structure which is needed to hold the data for a TLS/SSL connection.
19The new structure inherits the settings of the underlying context
20.Fa ctx :
21connection method (SSLv2/v3/TLSv1), options, verification settings,
22timeout settings.
23.Sh RETURN VALUES
24The following return values can occur:
25.Bl -tag -width Ds
26.It Dv NULL
27The creation of a new
28.Vt SSL
29structure failed.
30Check the error stack to find out the reason.
31.It Pointer to an Vt SSL No structure
32The return value points to an allocated
33.Vt SSL
34structure.
35.El
36.Sh SEE ALSO
37.Xr ssl 3 ,
38.Xr SSL_clear 3 ,
39.Xr SSL_CTX_set_options 3 ,
40.Xr SSL_free 3 ,
41.Xr SSL_get_SSL_CTX 3
diff --git a/src/lib/libssl/man/SSL_pending.3 b/src/lib/libssl/man/SSL_pending.3
new file mode 100644
index 0000000000..dadeec4b92
--- /dev/null
+++ b/src/lib/libssl/man/SSL_pending.3
@@ -0,0 +1,44 @@
1.\"
2.\" $OpenBSD: SSL_pending.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_PENDING 3
6.Os
7.Sh NAME
8.Nm SSL_pending
9.Nd obtain number of readable bytes buffered in an SSL object
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft int
13.Fn SSL_pending "const SSL *ssl"
14.Sh DESCRIPTION
15.Fn SSL_pending
16returns the number of bytes which are available inside
17.Fa ssl
18for immediate read.
19.Sh NOTES
20Data are received in blocks from the peer.
21Therefore data can be buffered inside
22.Fa ssl
23and are ready for immediate retrieval with
24.Xr SSL_read 3 .
25.Sh RETURN VALUES
26The number of bytes pending is returned.
27.Sh SEE ALSO
28.Xr ssl 3 ,
29.Xr SSL_read 3
30.Sh BUGS
31.Fn SSL_pending
32takes into account only bytes from the TLS/SSL record that is currently being
33processed (if any).
34If the
35.Vt SSL
36object's
37.Em read_ahead
38flag is set, additional protocol bytes may have been read containing more
39TLS/SSL records; these are ignored by
40.Fn SSL_pending .
41.Pp
42Up to OpenSSL 0.9.6,
43.Fn SSL_pending
44does not check if the record type of pending data is application data.
diff --git a/src/lib/libssl/man/SSL_read.3 b/src/lib/libssl/man/SSL_read.3
new file mode 100644
index 0000000000..662aed4daa
--- /dev/null
+++ b/src/lib/libssl/man/SSL_read.3
@@ -0,0 +1,193 @@
1.\"
2.\" $OpenBSD: SSL_read.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_READ 3
6.Os
7.Sh NAME
8.Nm SSL_read
9.Nd read bytes from a TLS/SSL connection
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft int
13.Fn SSL_read "SSL *ssl" "void *buf" "int num"
14.Sh DESCRIPTION
15.Fn SSL_read
16tries to read
17.Fa num
18bytes from the specified
19.Fa ssl
20into the buffer
21.Fa buf .
22.Sh NOTES
23If necessary,
24.Fn SSL_read
25will negotiate a TLS/SSL session, if not already explicitly performed by
26.Xr SSL_connect 3
27or
28.Xr SSL_accept 3 .
29If the peer requests a re-negotiation,
30it will be performed transparently during the
31.Fn SSL_read
32operation.
33The behaviour of
34.Fn SSL_read
35depends on the underlying
36.Vt BIO .
37.Pp
38For the transparent negotiation to succeed, the
39.Fa ssl
40must have been initialized to client or server mode.
41This is being done by calling
42.Xr SSL_set_connect_state 3
43or
44.Xr SSL_set_accept_state 3
45before the first call to
46.Fn SSL_read
47or
48.Xr SSL_write 3 .
49.Pp
50.Fn SSL_read
51works based on the SSL/TLS records.
52The data are received in records (with a maximum record size of 16kB for
53SSLv3/TLSv1).
54Only after a record has been completely received can it be processed
55(decrypted and checked for integrity).
56Therefore data not retrieved at the last call of
57.Fn SSL_read
58can still be buffered inside the SSL layer and will be retrieved on the next
59call to
60.Fn SSL_read .
61If
62.Fa num
63is higher than the number of bytes buffered,
64.Fn SSL_read
65will return with the bytes buffered.
66If no more bytes are in the buffer,
67.Fn SSL_read
68will trigger the processing of the next record.
69Only when the record has been received and processed completely will
70.Fn SSL_read
71return reporting success.
72At most the contents of the record will be returned.
73As the size of an SSL/TLS record may exceed the maximum packet size of the
74underlying transport (e.g., TCP), it may be necessary to read several packets
75from the transport layer before the record is complete and
76.Fn SSL_read
77can succeed.
78.Pp
79If the underlying
80.Vt BIO
81is
82.Em blocking ,
83.Fn SSL_read
84will only return once the read operation has been finished or an error
85has occurred, except when a renegotiation take place, in which case a
86.Dv SSL_ERROR_WANT_READ
87may occur.
88This behavior can be controlled with the
89.Dv SSL_MODE_AUTO_RETRY
90flag of the
91.Xr SSL_CTX_set_mode 3
92call.
93.Pp
94If the underlying
95.Vt BIO
96is
97.Em non-blocking ,
98.Fn SSL_read
99will also return when the underlying
100.Vt BIO
101could not satisfy the needs of
102.Fn SSL_read
103to continue the operation.
104In this case a call to
105.Xr SSL_get_error 3
106with the return value of
107.Fn SSL_read
108will yield
109.Dv SSL_ERROR_WANT_READ
110or
111.Dv SSL_ERROR_WANT_WRITE .
112As at any time a re-negotiation is possible, a call to
113.Fn SSL_read
114can also cause write operations!
115The calling process then must repeat the call after taking appropriate action
116to satisfy the needs of
117.Fn SSL_read .
118The action depends on the underlying
119.Vt BIO .
120When using a non-blocking socket, nothing is to be done, but
121.Xr select 2
122can be used to check for the required condition.
123When using a buffering
124.Vt BIO ,
125like a
126.Vt BIO
127pair, data must be written into or retrieved out of the
128.Vt BIO
129before being able to continue.
130.Pp
131.Xr SSL_pending 3
132can be used to find out whether there are buffered bytes available for
133immediate retrieval.
134In this case
135.Fn SSL_read
136can be called without blocking or actually receiving new data from the
137underlying socket.
138.Sh WARNING
139When an
140.Fn SSL_read
141operation has to be repeated because of
142.Dv SSL_ERROR_WANT_READ
143or
144.Dv SSL_ERROR_WANT_WRITE ,
145it must be repeated with the same arguments.
146.Sh RETURN VALUES
147The following return values can occur:
148.Bl -tag -width Ds
149.It >0
150The read operation was successful; the return value is the number of bytes
151actually read from the TLS/SSL connection.
152.It 0
153The read operation was not successful.
154The reason may either be a clean shutdown due to a
155.Dq close notify
156alert sent by the peer (in which case the
157.Dv SSL_RECEIVED_SHUTDOWN
158flag in the ssl shutdown state is set (see
159.Xr SSL_shutdown 3
160and
161.Xr SSL_set_shutdown 3 ) .
162It is also possible that the peer simply shut down the underlying transport and
163the shutdown is incomplete.
164Call
165.Fn SSL_get_error
166with the return value to find out whether an error occurred or the connection
167was shut down cleanly
168.Pq Dv SSL_ERROR_ZERO_RETURN .
169.Pp
170SSLv2 (deprecated) does not support a shutdown alert protocol, so it can only
171be detected whether the underlying connection was closed.
172It cannot be checked whether the closure was initiated by the peer or by
173something else.
174.It <0
175The read operation was not successful, because either an error occurred or
176action must be taken by the calling process.
177Call
178.Fn SSL_get_error
179with the return value to find out the reason.
180.El
181.Sh SEE ALSO
182.Xr bio 3 ,
183.Xr ssl 3 ,
184.Xr SSL_accept 3 ,
185.Xr SSL_connect 3 ,
186.Xr SSL_CTX_new 3 ,
187.Xr SSL_CTX_set_mode 3 ,
188.Xr SSL_get_error 3 ,
189.Xr SSL_pending 3 ,
190.Xr SSL_set_connect_state 3 ,
191.Xr SSL_set_shutdown 3 ,
192.Xr SSL_shutdown 3 ,
193.Xr SSL_write 3
diff --git a/src/lib/libssl/man/SSL_rstate_string.3 b/src/lib/libssl/man/SSL_rstate_string.3
new file mode 100644
index 0000000000..4b29fed86e
--- /dev/null
+++ b/src/lib/libssl/man/SSL_rstate_string.3
@@ -0,0 +1,55 @@
1.\"
2.\" $OpenBSD: SSL_rstate_string.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_RSTATE_STRING 3
6.Os
7.Sh NAME
8.Nm SSL_rstate_string ,
9.Nm SSL_rstate_string_long
10.Nd get textual description of state of an SSL object during read operation
11.Sh SYNOPSIS
12.In openssl/ssl.h
13.Ft const char *
14.Fn SSL_rstate_string "SSL *ssl"
15.Ft const char *
16.Fn SSL_rstate_string_long "SSL *ssl"
17.Sh DESCRIPTION
18.Fn SSL_rstate_string
19returns a 2-letter string indicating the current read state of the
20.Vt SSL
21object
22.Fa ssl .
23.Pp
24.Fn SSL_rstate_string_long
25returns a string indicating the current read state of the
26.Vt SSL
27object
28.Fa ssl .
29.Sh NOTES
30When performing a read operation, the SSL/TLS engine must parse the record,
31consisting of header and body.
32When working in a blocking environment,
33.Fn SSL_rstate_string[_long]
34should always return
35.Qo RD Qc Ns / Ns Qo read done Qc .
36.Pp
37This function should only seldom be needed in applications.
38.Sh RETURN VALUES
39.Fn SSL_rstate_string
40and
41.Fn SSL_rstate_string_long
42can return the following values:
43.Bl -tag -width Ds
44.It Qo RH Qc Ns / Ns Qo read header Qc
45The header of the record is being evaluated.
46.It Qo RB Qc Ns / Ns Qo read body Qc
47The body of the record is being evaluated.
48.It Qo RD Qc Ns / Ns Qo read done Qc
49The record has been completely processed.
50.It Qo unknown Qc Ns / Ns Qo unknown Qc
51The read state is unknown.
52This should never happen.
53.El
54.Sh SEE ALSO
55.Xr ssl 3
diff --git a/src/lib/libssl/man/SSL_session_reused.3 b/src/lib/libssl/man/SSL_session_reused.3
new file mode 100644
index 0000000000..6d592a8d55
--- /dev/null
+++ b/src/lib/libssl/man/SSL_session_reused.3
@@ -0,0 +1,32 @@
1.\"
2.\" $OpenBSD: SSL_session_reused.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_SESSION_REUSED 3
6.Os
7.Sh NAME
8.Nm SSL_session_reused
9.Nd query whether a reused session was negotiated during handshake
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft int
13.Fn SSL_session_reused "SSL *ssl"
14.Sh DESCRIPTION
15Query whether a reused session was negotiated during the handshake.
16.Sh NOTES
17During the negotiation, a client can propose to reuse a session.
18The server then looks up the session in its cache.
19If both client and server agree on the session,
20it will be reused and a flag is set that can be queried by the application.
21.Sh RETURN VALUES
22The following return values can occur:
23.Bl -tag -width Ds
24.It 0
25A new session was negotiated.
26.It 1
27A session was reused.
28.El
29.Sh SEE ALSO
30.Xr ssl 3 ,
31.Xr SSL_CTX_set_session_cache_mode 3 ,
32.Xr SSL_set_session 3
diff --git a/src/lib/libssl/man/SSL_set_bio.3 b/src/lib/libssl/man/SSL_set_bio.3
new file mode 100644
index 0000000000..21750fd66c
--- /dev/null
+++ b/src/lib/libssl/man/SSL_set_bio.3
@@ -0,0 +1,51 @@
1.\"
2.\" $OpenBSD: SSL_set_bio.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_SET_BIO 3
6.Os
7.Sh NAME
8.Nm SSL_set_bio
9.Nd connect the SSL object with a BIO
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft void
13.Fn SSL_set_bio "SSL *ssl" "BIO *rbio" "BIO *wbio"
14.Sh DESCRIPTION
15.Fn SSL_set_bio
16connects the
17.Vt BIO Ns
18s
19.Fa rbio
20and
21.Fa wbio
22for the read and write operations of the TLS/SSL (encrypted) side of
23.Fa ssl .
24.Pp
25The SSL engine inherits the behaviour of
26.Fa rbio
27and
28.Fa wbio ,
29respectively.
30If a
31.Vt BIO
32is non-blocking, the
33.Fa ssl
34will also have non-blocking behaviour.
35.Pp
36If there was already a
37.Vt BIO
38connected to
39.Fa ssl ,
40.Xr BIO_free 3
41will be called (for both the reading and writing side, if different).
42.Sh RETURN VALUES
43.Fn SSL_set_bio
44cannot fail.
45.Sh SEE ALSO
46.Xr bio 3 ,
47.Xr ssl 3 ,
48.Xr SSL_accept 3 ,
49.Xr SSL_connect 3 ,
50.Xr SSL_get_rbio 3 ,
51.Xr SSL_shutdown 3
diff --git a/src/lib/libssl/man/SSL_set_connect_state.3 b/src/lib/libssl/man/SSL_set_connect_state.3
new file mode 100644
index 0000000000..8def2ecde5
--- /dev/null
+++ b/src/lib/libssl/man/SSL_set_connect_state.3
@@ -0,0 +1,71 @@
1.\"
2.\" $OpenBSD: SSL_set_connect_state.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_SET_CONNECT_STATE 3
6.Os
7.Sh NAME
8.Nm SSL_set_connect_state ,
9.Nm SSL_set_accept_state
10.Nd prepare SSL object to work in client or server mode
11.Sh SYNOPSIS
12.In openssl/ssl.h
13.Ft void
14.Fn SSL_set_connect_state "SSL *ssl"
15.Ft void
16.Fn SSL_set_accept_state "SSL *ssl"
17.Sh DESCRIPTION
18.Fn SSL_set_connect_state
19sets
20.Fa ssl
21to work in client mode.
22.Pp
23.Fn SSL_set_accept_state
24sets
25.Fa ssl
26to work in server mode.
27.Sh NOTES
28When the
29.Vt SSL_CTX
30object was created with
31.Xr SSL_CTX_new 3 ,
32it was either assigned a dedicated client method, a dedicated server method, or
33a generic method, that can be used for both client and server connections.
34(The method might have been changed with
35.Xr SSL_CTX_set_ssl_version 3
36or
37.Xr SSL_set_ssl_method 3 . )
38.Pp
39When beginning a new handshake, the SSL engine must know whether it must call
40the connect (client) or accept (server) routines.
41Even though it may be clear from the method chosen whether client or server
42mode was requested, the handshake routines must be explicitly set.
43.Pp
44When using the
45.Xr SSL_connect 3
46or
47.Xr SSL_accept 3
48routines, the correct handshake routines are automatically set.
49When performing a transparent negotiation using
50.Xr SSL_write 3
51or
52.Xr SSL_read 3 ,
53the handshake routines must be explicitly set in advance using either
54.Fn SSL_set_connect_state
55or
56.Fn SSL_set_accept_state .
57.Sh RETURN VALUES
58.Fn SSL_set_connect_state
59and
60.Fn SSL_set_accept_state
61do not return diagnostic information.
62.Sh SEE ALSO
63.Xr ssl 3 ,
64.Xr SSL_accept 3 ,
65.Xr SSL_connect 3 ,
66.Xr SSL_CTX_new 3 ,
67.Xr SSL_CTX_set_ssl_version 3 ,
68.Xr SSL_do_handshake 3 ,
69.Xr SSL_new 3 ,
70.Xr SSL_read 3 ,
71.Xr SSL_write 3
diff --git a/src/lib/libssl/man/SSL_set_fd.3 b/src/lib/libssl/man/SSL_set_fd.3
new file mode 100644
index 0000000000..0e9d272913
--- /dev/null
+++ b/src/lib/libssl/man/SSL_set_fd.3
@@ -0,0 +1,73 @@
1.\"
2.\" $OpenBSD: SSL_set_fd.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_SET_FD 3
6.Os
7.Sh NAME
8.Nm SSL_set_fd ,
9.Nm SSL_set_rfd ,
10.Nm SSL_set_wfd
11.Nd connect the SSL object with a file descriptor
12.Sh SYNOPSIS
13.In openssl/ssl.h
14.Ft int
15.Fn SSL_set_fd "SSL *ssl" "int fd"
16.Ft int
17.Fn SSL_set_rfd "SSL *ssl" "int fd"
18.Ft int
19.Fn SSL_set_wfd "SSL *ssl" "int fd"
20.Sh DESCRIPTION
21.Fn SSL_set_fd
22sets the file descriptor
23.Fa fd
24as the input/output facility for the TLS/SSL (encrypted) side of
25.Fa ssl .
26.Fa fd
27will typically be the socket file descriptor of a network connection.
28.Pp
29When performing the operation, a socket
30.Vt BIO
31is automatically created to interface between the
32.Fa ssl
33and
34.Fa fd .
35The
36.Vt BIO
37and hence the SSL engine inherit the behaviour of
38.Fa fd .
39If
40.Fa fd
41is non-blocking, the
42.Fa ssl
43will also have non-blocking behaviour.
44.Pp
45If there was already a
46.Vt BIO
47connected to
48.Fa ssl ,
49.Xr BIO_free 3
50will be called (for both the reading and writing side, if different).
51.Pp
52.Fn SSL_set_rfd
53and
54.Fn SSL_set_wfd
55perform the respective action, but only for the read channel or the write
56channel, which can be set independently.
57.Sh RETURN VALUES
58The following return values can occur:
59.Bl -tag -width Ds
60.It 0
61The operation failed.
62Check the error stack to find out why.
63.It 1
64The operation succeeded.
65.El
66.Sh SEE ALSO
67.Xr bio 3 ,
68.Xr ssl 3 ,
69.Xr SSL_accept 3 ,
70.Xr SSL_connect 3 ,
71.Xr SSL_get_fd 3 ,
72.Xr SSL_set_bio 3 ,
73.Xr SSL_shutdown 3
diff --git a/src/lib/libssl/man/SSL_set_session.3 b/src/lib/libssl/man/SSL_set_session.3
new file mode 100644
index 0000000000..28f1aa667a
--- /dev/null
+++ b/src/lib/libssl/man/SSL_set_session.3
@@ -0,0 +1,68 @@
1.\"
2.\" $OpenBSD: SSL_set_session.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_SET_SESSION 3
6.Os
7.Sh NAME
8.Nm SSL_set_session
9.Nd set a TLS/SSL session to be used during TLS/SSL connect
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft int
13.Fn SSL_set_session "SSL *ssl" "SSL_SESSION *session"
14.Sh DESCRIPTION
15.Fn SSL_set_session
16sets
17.Fa session
18to be used when the TLS/SSL connection is to be established.
19.Fn SSL_set_session
20is only useful for TLS/SSL clients.
21When the session is set, the reference count of
22.Fa session
23is incremented
24by 1.
25If the session is not reused, the reference count is decremented again during
26.Fn SSL_connect .
27Whether the session was reused can be queried with the
28.Xr SSL_session_reused 3
29call.
30.Pp
31If there is already a session set inside
32.Fa ssl
33(because it was set with
34.Fn SSL_set_session
35before or because the same
36.Fa ssl
37was already used for a connection),
38.Xr SSL_SESSION_free 3
39will be called for that session.
40.Sh NOTES
41.Vt SSL_SESSION
42objects keep internal link information about the session cache list when being
43inserted into one
44.Vt SSL_CTX
45object's session cache.
46One
47.Vt SSL_SESSION
48object, regardless of its reference count, must therefore only be used with one
49.Vt SSL_CTX
50object (and the
51.Vt SSL
52objects created from this
53.Vt SSL_CTX
54object).
55.Sh RETURN VALUES
56The following return values can occur:
57.Bl -tag -width Ds
58.It 0
59The operation failed; check the error stack to find out the reason.
60.It 1
61The operation succeeded.
62.El
63.Sh SEE ALSO
64.Xr ssl 3 ,
65.Xr SSL_CTX_set_session_cache_mode 3 ,
66.Xr SSL_get_session 3 ,
67.Xr SSL_SESSION_free 3 ,
68.Xr SSL_session_reused 3
diff --git a/src/lib/libssl/man/SSL_set_shutdown.3 b/src/lib/libssl/man/SSL_set_shutdown.3
new file mode 100644
index 0000000000..81eb703c67
--- /dev/null
+++ b/src/lib/libssl/man/SSL_set_shutdown.3
@@ -0,0 +1,88 @@
1.\"
2.\" $OpenBSD: SSL_set_shutdown.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_SET_SHUTDOWN 3
6.Os
7.Sh NAME
8.Nm SSL_set_shutdown ,
9.Nm SSL_get_shutdown
10.Nd manipulate shutdown state of an SSL connection
11.Sh SYNOPSIS
12.In openssl/ssl.h
13.Ft void
14.Fn SSL_set_shutdown "SSL *ssl" "int mode"
15.Ft int
16.Fn SSL_get_shutdown "const SSL *ssl"
17.Sh DESCRIPTION
18.Fn SSL_set_shutdown
19sets the shutdown state of
20.Fa ssl
21to
22.Fa mode .
23.Pp
24.Fn SSL_get_shutdown
25returns the shutdown mode of
26.Fa ssl .
27.Sh NOTES
28The shutdown state of an ssl connection is a bitmask of:
29.Bl -tag -width Ds
30.It 0
31No shutdown setting, yet.
32.It Dv SSL_SENT_SHUTDOWN
33A
34.Dq close notify
35shutdown alert was sent to the peer; the connection is being considered closed
36and the session is closed and correct.
37.It Dv SSL_RECEIVED_SHUTDOWN
38A shutdown alert was received form the peer, either a normal
39.Dq close notify
40or a fatal error.
41.El
42.Pp
43.Dv SSL_SENT_SHUTDOWN
44and
45.Dv SSL_RECEIVED_SHUTDOWN
46can be set at the same time.
47.Pp
48The shutdown state of the connection is used to determine the state of the
49.Fa ssl
50session.
51If the session is still open when
52.Xr SSL_clear 3
53or
54.Xr SSL_free 3
55is called, it is considered bad and removed according to RFC2246.
56The actual condition for a correctly closed session is
57.Dv SSL_SENT_SHUTDOWN
58(according to the TLS RFC, it is acceptable to only send the
59.Dq close notify
60alert but to not wait for the peer's answer when the underlying connection is
61closed).
62.Fn SSL_set_shutdown
63can be used to set this state without sending a close alert to the peer (see
64.Xr SSL_shutdown 3 ) .
65.Pp
66If a
67.Dq close notify
68was received,
69.Dv SSL_RECEIVED_SHUTDOWN
70will be set, but to set
71.Dv SSL_SENT_SHUTDOWN
72the application must still call
73.Xr SSL_shutdown 3
74or
75.Fn SSL_set_shutdown
76itself.
77.Sh RETURN VALUES
78.Fn SSL_set_shutdown
79does not return diagnostic information.
80.Pp
81.Fn SSL_get_shutdown
82returns the current setting.
83.Sh SEE ALSO
84.Xr ssl 3 ,
85.Xr SSL_clear 3 ,
86.Xr SSL_CTX_set_quiet_shutdown 3 ,
87.Xr SSL_free 3 ,
88.Xr SSL_shutdown 3
diff --git a/src/lib/libssl/man/SSL_set_verify_result.3 b/src/lib/libssl/man/SSL_set_verify_result.3
new file mode 100644
index 0000000000..298b6b28c6
--- /dev/null
+++ b/src/lib/libssl/man/SSL_set_verify_result.3
@@ -0,0 +1,42 @@
1.\"
2.\" $OpenBSD: SSL_set_verify_result.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_SET_VERIFY_RESULT 3
6.Os
7.Sh NAME
8.Nm SSL_set_verify_result
9.Nd override result of peer certificate verification
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft void
13.Fn SSL_set_verify_result "SSL *ssl" "long verify_result"
14.Sh DESCRIPTION
15.Fn SSL_set_verify_result
16sets
17.Fa verify_result
18of the object
19.Fa ssl
20to be the result of the verification of the X509 certificate presented by the
21peer, if any.
22.Sh NOTES
23.Fn SSL_set_verify_result
24overrides the verification result.
25It only changes the verification result of the
26.Fa ssl
27object.
28It does not become part of the established session, so if the session is to be
29reused later, the original value will reappear.
30.Pp
31The valid codes for
32.Fa verify_result
33are documented in
34.Xr openssl 1 .
35.Sh RETURN VALUES
36.Fn SSL_set_verify_result
37does not provide a return value.
38.Sh SEE ALSO
39.Xr openssl 1 ,
40.Xr ssl 3 ,
41.Xr SSL_get_peer_certificate 3 ,
42.Xr SSL_get_verify_result 3
diff --git a/src/lib/libssl/man/SSL_shutdown.3 b/src/lib/libssl/man/SSL_shutdown.3
new file mode 100644
index 0000000000..1dfcb54bfe
--- /dev/null
+++ b/src/lib/libssl/man/SSL_shutdown.3
@@ -0,0 +1,204 @@
1.\"
2.\" $OpenBSD: SSL_shutdown.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_SHUTDOWN 3
6.Os
7.Sh NAME
8.Nm SSL_shutdown
9.Nd shut down a TLS/SSL connection
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft int
13.Fn SSL_shutdown "SSL *ssl"
14.Sh DESCRIPTION
15.Fn SSL_shutdown
16shuts down an active TLS/SSL connection.
17It sends the
18.Dq close notify
19shutdown alert to the peer.
20.Sh NOTES
21.Fn SSL_shutdown
22tries to send the
23.Dq close notify
24shutdown alert to the peer.
25Whether the operation succeeds or not, the
26.Dv SSL_SENT_SHUTDOWN
27flag is set and a currently open session is considered closed and good and will
28be kept in the session cache for further reuse.
29.Pp
30The shutdown procedure consists of 2 steps: the sending of the
31.Dq close notify
32shutdown alert and the reception of the peer's
33.Dq close notify
34shutdown alert.
35According to the TLS standard, it is acceptable for an application to only send
36its shutdown alert and then close the underlying connection without waiting for
37the peer's response (this way resources can be saved, as the process can
38already terminate or serve another connection).
39When the underlying connection shall be used for more communications,
40the complete shutdown procedure (bidirectional
41.Dq close notify
42alerts) must be performed, so that the peers stay synchronized.
43.Pp
44.Fn SSL_shutdown
45supports both uni- and bidirectional shutdown by its 2 step behavior.
46.Pp
47When the application is the first party to send the
48.Dq close notify
49alert,
50.Fn SSL_shutdown
51will only send the alert and then set the
52.Dv SSL_SENT_SHUTDOWN
53flag (so that the session is considered good and will be kept in cache).
54.Fn SSL_shutdown
55will then return 0.
56If a unidirectional shutdown is enough
57(the underlying connection shall be closed anyway), this first call to
58.Fn SSL_shutdown
59is sufficient.
60In order to complete the bidirectional shutdown handshake,
61.Fn SSL_shutdown
62must be called again.
63The second call will make
64.Fn SSL_shutdown
65wait for the peer's
66.Dq close notify
67shutdown alert.
68On success, the second call to
69.Fn SSL_shutdown
70will return 1.
71.Pp
72If the peer already sent the
73.Dq close notify
74alert and it was already processed implicitly inside another function
75.Pq Xr SSL_read 3 ,
76the
77.Dv SSL_RECEIVED_SHUTDOWN
78flag is set.
79.Fn SSL_shutdown
80will send the
81.Dq close notify
82alert, set the
83.Dv SSL_SENT_SHUTDOWN
84flag and will immediately return with 1.
85Whether
86.Dv SSL_RECEIVED_SHUTDOWN
87is already set can be checked using the
88.Fn SSL_get_shutdown
89(see also the
90.Xr SSL_set_shutdown 3
91call).
92.Pp
93It is therefore recommended to check the return value of
94.Fn SSL_shutdown
95and call
96.Fn SSL_shutdown
97again, if the bidirectional shutdown is not yet complete (return value of the
98first call is 0).
99As the shutdown is not specially handled in the SSLv2 protocol,
100.Fn SSL_shutdown
101will succeed on the first call.
102.Pp
103The behaviour of
104.Fn SSL_shutdown
105additionally depends on the underlying
106.Vt BIO .
107.Pp
108If the underlying
109.Vt BIO
110is
111.Em blocking ,
112.Fn SSL_shutdown
113will only return once the
114handshake step has been finished or an error occurred.
115.Pp
116If the underlying
117.Vt BIO
118is
119.Em non-blocking ,
120.Fn SSL_shutdown
121will also return when the underlying
122.Vt BIO
123could not satisfy the needs of
124.Fn SSL_shutdown
125to continue the handshake.
126In this case a call to
127.Xr SSL_get_error 3
128with the
129return value of
130.Fn SSL_shutdown
131will yield
132.Dv SSL_ERROR_WANT_READ
133or
134.Dv SSL_ERROR_WANT_WRITE .
135The calling process then must repeat the call after taking appropriate action
136to satisfy the needs of
137.Fn SSL_shutdown .
138The action depends on the underlying
139.Vt BIO .
140When using a non-blocking socket, nothing is to be done, but
141.Xr select 2
142can be used to check for the required condition.
143When using a buffering
144.Vt BIO ,
145like a
146.Vt BIO
147pair, data must be written into or retrieved out of the
148.Vt BIO
149before being able to continue.
150.Pp
151.Fn SSL_shutdown
152can be modified to only set the connection to
153.Dq shutdown
154state but not actually send the
155.Dq close notify
156alert messages; see
157.Xr SSL_CTX_set_quiet_shutdown 3 .
158When
159.Dq quiet shutdown
160is enabled,
161.Fn SSL_shutdown
162will always succeed and return 1.
163.Sh RETURN VALUES
164The following return values can occur:
165.Bl -tag -width Ds
166.It 0
167The shutdown is not yet finished.
168Call
169.Fn SSL_shutdown
170for a second time, if a bidirectional shutdown shall be performed.
171The output of
172.Xr SSL_get_error 3
173may be misleading, as an erroneous
174.Dv SSL_ERROR_SYSCALL
175may be flagged even though no error occurred.
176.It 1
177The shutdown was successfully completed.
178The
179.Dq close notify
180alert was sent and the peer's
181.Dq close notify
182alert was received.
183.It \(mi1
184The shutdown was not successful because a fatal error occurred either
185at the protocol level or a connection failure occurred.
186It can also occur if action is need to continue the operation for non-blocking
187.Vt BIO Ns
188s.
189Call
190.Xr SSL_get_error 3
191with the return value
192.Fa ret
193to find out the reason.
194.El
195.Sh SEE ALSO
196.Xr bio 3 ,
197.Xr ssl 3 ,
198.Xr SSL_accept 3 ,
199.Xr SSL_clear 3 ,
200.Xr SSL_connect 3 ,
201.Xr SSL_CTX_set_quiet_shutdown 3 ,
202.Xr SSL_free 3 ,
203.Xr SSL_get_error 3 ,
204.Xr SSL_set_shutdown 3
diff --git a/src/lib/libssl/man/SSL_state_string.3 b/src/lib/libssl/man/SSL_state_string.3
new file mode 100644
index 0000000000..bde359243e
--- /dev/null
+++ b/src/lib/libssl/man/SSL_state_string.3
@@ -0,0 +1,57 @@
1.\"
2.\" $OpenBSD: SSL_state_string.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_STATE_STRING 3
6.Os
7.Sh NAME
8.Nm SSL_state_string ,
9.Nm SSL_state_string_long
10.Nd get textual description of state of an SSL object
11.Sh SYNOPSIS
12.In openssl/ssl.h
13.Ft const char *
14.Fn SSL_state_string "const SSL *ssl"
15.Ft const char *
16.Fn SSL_state_string_long "const SSL *ssl"
17.Sh DESCRIPTION
18.Fn SSL_state_string
19returns a 6 letter string indicating the current state of the
20.Vt SSL
21object
22.Fa ssl .
23.Pp
24.Fn SSL_state_string_long
25returns a string indicating the current state of the
26.Vt SSL
27object
28.Fa ssl .
29.Sh NOTES
30During its use, an
31.Vt SSL
32object passes several states.
33The state is internally maintained.
34Querying the state information is not very informative before or when a
35connection has been established.
36It however can be of significant interest during the handshake.
37.Pp
38When using non-blocking sockets,
39the function call performing the handshake may return with
40.Dv SSL_ERROR_WANT_READ
41or
42.Dv SSL_ERROR_WANT_WRITE
43condition, so that
44.Fn SSL_state_string[_long]
45may be called.
46.Pp
47For both blocking or non-blocking sockets,
48the details state information can be used within the
49.Fn info_callback
50function set with the
51.Xr SSL_set_info_callback 3
52call.
53.Sh RETURN VALUES
54Detailed description of possible states to be included later.
55.Sh SEE ALSO
56.Xr ssl 3 ,
57.Xr SSL_CTX_set_info_callback 3
diff --git a/src/lib/libssl/man/SSL_want.3 b/src/lib/libssl/man/SSL_want.3
new file mode 100644
index 0000000000..456d0728dc
--- /dev/null
+++ b/src/lib/libssl/man/SSL_want.3
@@ -0,0 +1,103 @@
1.\"
2.\" $OpenBSD: SSL_want.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_WANT 3
6.Os
7.Sh NAME
8.Nm SSL_want ,
9.Nm SSL_want_nothing ,
10.Nm SSL_want_read ,
11.Nm SSL_want_write ,
12.Nm SSL_want_x509_lookup
13.Nd obtain state information TLS/SSL I/O operation
14.Sh SYNOPSIS
15.In openssl/ssl.h
16.Ft int
17.Fn SSL_want "const SSL *ssl"
18.Ft int
19.Fn SSL_want_nothing "const SSL *ssl"
20.Ft int
21.Fn SSL_want_read "const SSL *ssl"
22.Ft int
23.Fn SSL_want_write "const SSL *ssl"
24.Ft int
25.Fn SSL_want_x509_lookup "const SSL *ssl"
26.Sh DESCRIPTION
27.Fn SSL_want
28returns state information for the
29.Vt SSL
30object
31.Fa ssl .
32.Pp
33The other
34.Fn SSL_want_*
35calls are shortcuts for the possible states returned by
36.Fn SSL_want .
37.Sh NOTES
38.Fn SSL_want
39examines the internal state information of the
40.Vt SSL
41object.
42Its return values are similar to those of
43.Xr SSL_get_error 3 .
44Unlike
45.Xr SSL_get_error 3 ,
46which also evaluates the error queue,
47the results are obtained by examining an internal state flag only.
48The information must therefore only be used for normal operation under
49non-blocking I/O.
50Error conditions are not handled and must be treated using
51.Xr SSL_get_error 3 .
52.Pp
53The result returned by
54.Fn SSL_want
55should always be consistent with the result of
56.Xr SSL_get_error 3 .
57.Sh RETURN VALUES
58The following return values can currently occur for
59.Fn SSL_want :
60.Bl -tag -width Ds
61.It .Dv SSL_NOTHING
62There is no data to be written or to be read.
63.It .Dv SSL_WRITING
64There are data in the SSL buffer that must be written to the underlying
65.Vt BIO
66layer in order to complete the actual
67.Fn SSL_*
68operation.
69A call to
70.Xr SSL_get_error 3
71should return
72.Dv SSL_ERROR_WANT_WRITE .
73.It Dv SSL_READING
74More data must be read from the underlying
75.Vt BIO
76layer in order to
77complete the actual
78.Fn SSL_*
79operation.
80A call to
81.Xr SSL_get_error 3
82should return
83.Dv SSL_ERROR_WANT_READ.
84.It Dv SSL_X509_LOOKUP
85The operation did not complete because an application callback set by
86.Xr SSL_CTX_set_client_cert_cb 3
87has asked to be called again.
88A call to
89.Xr SSL_get_error 3
90should return
91.Dv SSL_ERROR_WANT_X509_LOOKUP .
92.El
93.Pp
94.Fn SSL_want_nothing ,
95.Fn SSL_want_read ,
96.Fn SSL_want_write ,
97and
98.Fn SSL_want_x509_lookup
99return 1 when the corresponding condition is true or 0 otherwise.
100.Sh SEE ALSO
101.Xr err 3 ,
102.Xr ssl 3 ,
103.Xr SSL_get_error 3
diff --git a/src/lib/libssl/man/SSL_write.3 b/src/lib/libssl/man/SSL_write.3
new file mode 100644
index 0000000000..a4db3d37de
--- /dev/null
+++ b/src/lib/libssl/man/SSL_write.3
@@ -0,0 +1,175 @@
1.\"
2.\" $OpenBSD: SSL_write.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL_WRITE 3
6.Os
7.Sh NAME
8.Nm SSL_write
9.Nd write bytes to a TLS/SSL connection
10.Sh SYNOPSIS
11.In openssl/ssl.h
12.Ft int
13.Fn SSL_write "SSL *ssl" "const void *buf" "int num"
14.Sh DESCRIPTION
15.Fn SSL_write
16writes
17.Fa num
18bytes from the buffer
19.Fa buf
20into the specified
21.Fa ssl
22connection.
23.Sh NOTES
24If necessary,
25.Fn SSL_write
26will negotiate a TLS/SSL session, if not already explicitly performed by
27.Xr SSL_connect 3
28or
29.Xr SSL_accept 3 .
30If the peer requests a re-negotiation,
31it will be performed transparently during the
32.Fn SSL_write
33operation.
34The behaviour of
35.Fn SSL_write
36depends on the underlying
37.Vt BIO .
38.Pp
39For the transparent negotiation to succeed, the
40.Fa ssl
41must have been initialized to client or server mode.
42This is being done by calling
43.Xr SSL_set_connect_state 3
44or
45.Xr SSL_set_accept_state 3
46before the first call to an
47.Xr SSL_read 3
48or
49.Fn SSL_write
50function.
51.Pp
52If the underlying
53.Vt BIO
54is
55.Em blocking ,
56.Fn SSL_write
57will only return once the write operation has been finished or an error
58occurred, except when a renegotiation take place, in which case a
59.Dv SSL_ERROR_WANT_READ
60may occur.
61This behaviour can be controlled with the
62.Dv SSL_MODE_AUTO_RETRY
63flag of the
64.Xr SSL_CTX_set_mode 3
65call.
66.Pp
67If the underlying
68.Vt BIO
69is
70.Em non-blocking ,
71.Fn SSL_write
72will also return when the underlying
73.Vt BIO
74could not satisfy the needs of
75.Fn SSL_write
76to continue the operation.
77In this case a call to
78.Xr SSL_get_error 3
79with the return value of
80.Fn SSL_write
81will yield
82.Dv SSL_ERROR_WANT_READ
83or
84.Dv SSL_ERROR_WANT_WRITE .
85As at any time a re-negotiation is possible, a call to
86.Fn SSL_write
87can also cause read operations!
88The calling process then must repeat the call after taking appropriate action
89to satisfy the needs of
90.Fn SSL_write .
91The action depends on the underlying
92.Vt BIO .
93When using a non-blocking socket, nothing is to be done, but
94.Xr select 2
95can be used to check for the required condition.
96When using a buffering
97.Vt BIO ,
98like a
99.Vt BIO
100pair, data must be written into or retrieved out of the BIO before being able
101to continue.
102.Pp
103.Fn SSL_write
104will only return with success, when the complete contents of
105.Fa buf
106of length
107.Fa num
108have been written.
109This default behaviour can be changed with the
110.Dv SSL_MODE_ENABLE_PARTIAL_WRITE
111option of
112.Xr SSL_CTX_set_mode 3 .
113When this flag is set,
114.Fn SSL_write
115will also return with success when a partial write has been successfully
116completed.
117In this case the
118.Fn SSL_write
119operation is considered completed.
120The bytes are sent and a new
121.Fn SSL_write
122operation with a new buffer (with the already sent bytes removed) must be
123started.
124A partial write is performed with the size of a message block, which is 16kB
125for SSLv3/TLSv1.
126.Sh WARNING
127When an
128.Fn SSL_write
129operation has to be repeated because of
130.Dv SSL_ERROR_WANT_READ
131or
132.Dv SSL_ERROR_WANT_WRITE ,
133it must be repeated with the same arguments.
134.Pp
135When calling
136.Fn SSL_write
137with
138.Fa num Ns
139=0 bytes to be sent the behaviour is undefined.
140.Sh RETURN VALUES
141The following return values can occur:
142.Bl -tag -width Ds
143.It >0
144The write operation was successful.
145The return value is the number of bytes actually written to the TLS/SSL
146connection.
147.It 0
148The write operation was not successful.
149Probably the underlying connection was closed.
150Call
151.Xr SSL_get_error 3
152with the return value to find out whether an error occurred or the connection
153was shut down cleanly
154.Pq Dv SSL_ERROR_ZERO_RETURN .
155.Pp
156SSLv2 (deprecated) does not support a shutdown alert protocol, so it can only
157be detected whether the underlying connection was closed.
158It cannot be checked why the closure happened.
159.It <0
160The write operation was not successful, because either an error occurred or
161action must be taken by the calling process.
162Call
163.Xr SSL_get_error 3
164with the return value to find out the reason.
165.El
166.Sh SEE ALSO
167.Xr bio 3 ,
168.Xr ssl 3 ,
169.Xr SSL_accept 3 ,
170.Xr SSL_connect 3 ,
171.Xr SSL_CTX_new 3 ,
172.Xr SSL_CTX_set_mode 3 ,
173.Xr SSL_get_error 3 ,
174.Xr SSL_read 3 ,
175.Xr SSL_set_connect_state 3
diff --git a/src/lib/libssl/man/d2i_SSL_SESSION.3 b/src/lib/libssl/man/d2i_SSL_SESSION.3
new file mode 100644
index 0000000000..9a96a5b8ec
--- /dev/null
+++ b/src/lib/libssl/man/d2i_SSL_SESSION.3
@@ -0,0 +1,129 @@
1.\"
2.\" $OpenBSD: d2i_SSL_SESSION.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt D2I_SSL_SESSION 3
6.Os
7.Sh NAME
8.Nm d2i_SSL_SESSION ,
9.Nm i2d_SSL_SESSION
10.Nd convert SSL_SESSION object from/to ASN1 representation
11.Sh SYNOPSIS
12.In openssl/ssl.h
13.Ft SSL_SESSION *
14.Fn d2i_SSL_SESSION "SSL_SESSION **a" "const unsigned char **pp" "long length"
15.Ft int
16.Fn i2d_SSL_SESSION "SSL_SESSION *in" "unsigned char **pp"
17.Sh DESCRIPTION
18.Fn d2i_SSL_SESSION
19transforms the external ASN1 representation of an SSL/TLS session,
20stored as binary data at location
21.Fa pp
22with length
23.Fa length ,
24into
25an
26.Vt SSL_SESSION
27object.
28.Pp
29.Fn i2d_SSL_SESSION
30transforms the
31.Vt SSL_SESSION
32object
33.Fa in
34into the ASN1 representation and stores it into the memory location pointed to
35by
36.Fa pp .
37The length of the resulting ASN1 representation is returned.
38If
39.Fa pp
40is the
41.Dv NULL
42pointer, only the length is calculated and returned.
43.Sh NOTES
44The
45.Vt SSL_SESSION
46object is built from several
47.Xr malloc 3 Ns
48-ed parts; it can therefore not be moved, copied or stored directly.
49In order to store session data on disk or into a database,
50it must be transformed into a binary ASN1 representation.
51.Pp
52When using
53.Fn d2i_SSL_SESSION ,
54the
55.Vt SSL_SESSION
56object is automatically allocated.
57The reference count is 1, so that the session must be explicitly removed using
58.Xr SSL_SESSION_free 3 ,
59unless the
60.Vt SSL_SESSION
61object is completely taken over, when being called inside the
62.Xr get_session_cb 3
63(see
64.Xr SSL_CTX_sess_set_get_cb 3 ) .
65.Pp
66.Vt SSL_SESSION
67objects keep internal link information about the session cache list when being
68inserted into one
69.Vt SSL_CTX
70object's session cache.
71One
72.Vt SSL_SESSION
73object, regardless of its reference count, must therefore only be used with one
74.Vt SSL_CTX
75object (and the
76.Vt SSL
77objects created from this
78.Vt SSL_CTX
79object).
80.Pp
81When using
82.Fn i2d_SSL_SESSION ,
83the memory location pointed to by
84.Fa pp
85must be large enough to hold the binary representation of the session.
86There is no known limit on the size of the created ASN1 representation,
87so the necessary amount of space should be obtained by first calling
88.Fn i2d_SSL_SESSION
89with
90.Fa pp Ns
91= Ns
92.Dv NULL ,
93and obtain the size needed, then allocate the memory and call
94.Fn i2d_SSL_SESSION
95again.
96Note that this will advance the value contained in
97.Fa *pp
98so it is necessary to save a copy of the original allocation.
99For example:
100.Bd -literal
101int i, j;
102
103char *p, *temp;
104
105 i = i2d_SSL_SESSION(sess, NULL);
106 p = temp = malloc(i);
107 if (temp != NULL) {
108 j = i2d_SSL_SESSION(sess, &temp);
109 assert(i == j);
110 assert(p + i == temp);
111 }
112.Ed
113.Sh RETURN VALUES
114.Fn d2i_SSL_SESSION
115returns a pointer to the newly allocated
116.Vt SSL_SESSION
117object.
118In case of failure a
119.Dv NULL
120pointer is returned and the error message can be retrieved from the error
121stack.
122.Pp
123.Fn i2d_SSL_SESSION
124returns the size of the ASN1 representation in bytes.
125When the session is not valid, 0 is returned and no operation is performed.
126.Sh SEE ALSO
127.Xr ssl 3 ,
128.Xr SSL_CTX_sess_set_get_cb 3 ,
129.Xr SSL_SESSION_free 3
diff --git a/src/lib/libssl/man/ssl.3 b/src/lib/libssl/man/ssl.3
new file mode 100644
index 0000000000..004d71f9f2
--- /dev/null
+++ b/src/lib/libssl/man/ssl.3
@@ -0,0 +1,1319 @@
1.\"
2.\" $OpenBSD: ssl.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
3.\"
4.Dd $Mdocdate: November 5 2016 $
5.Dt SSL 3
6.Os
7.Sh NAME
8.Nm ssl
9.Nd OpenSSL SSL/TLS library
10.Sh DESCRIPTION
11The OpenSSL
12.Nm ssl
13library implements the Secure Sockets Layer (SSL v2/v3) and
14Transport Layer Security (TLS v1) protocols.
15It provides a rich API which is documented here.
16.Pp
17At first the library must be initialized; see
18.Xr SSL_library_init 3 .
19.Pp
20Then an
21.Vt SSL_CTX
22object is created as a framework to establish TLS/SSL enabled connections (see
23.Xr SSL_CTX_new 3 ) .
24Various options regarding certificates, algorithms, etc., can be set in this
25object.
26.Pp
27When a network connection has been created, it can be assigned to an
28.Vt SSL
29object.
30After the
31.Vt SSL
32object has been created using
33.Xr SSL_new 3 ,
34.Xr SSL_set_fd 3
35or
36.Xr SSL_set_bio 3
37can be used to associate the network connection with the object.
38.Pp
39Then the TLS/SSL handshake is performed using
40.Xr SSL_accept 3
41or
42.Xr SSL_connect 3
43respectively.
44.Xr SSL_read 3
45and
46.Xr SSL_write 3
47are used to read and write data on the TLS/SSL connection.
48.Xr SSL_shutdown 3
49can be used to shut down the TLS/SSL connection.
50.Sh DATA STRUCTURES
51Currently the OpenSSL
52.Nm ssl
53library functions deals with the following data structures:
54.Bl -tag -width Ds
55.It Vt SSL_METHOD No (SSL Method)
56That's a dispatch structure describing the internal
57.Nm ssl
58library methods/functions which implement the various protocol versions
59(SSLv1, SSLv2 and TLSv1).
60It's needed to create an
61.Vt SSL_CTX .
62.It Vt SSL_CIPHER No (SSL Cipher)
63This structure holds the algorithm information for a particular cipher which
64is a core part of the SSL/TLS protocol.
65The available ciphers are configured on an
66.Vt SSL_CTX
67basis and the actually used ones are then part of the
68.Vt SSL_SESSION .
69.It Vt SSL_CTX No (SSL Context)
70That's the global context structure which is created by a server or client
71once per program lifetime and which holds mainly default values for the
72.Vt SSL
73structures which are later created for the connections.
74.It Vt SSL_SESSION No (SSL Session)
75This is a structure containing the current TLS/SSL session details for a
76connection:
77.Vt SSL_CIPHER Ns s, client and server certificates, keys, etc.
78.It Vt SSL No (SSL Connection)
79That's the main SSL/TLS structure which is created by a server or client per
80established connection.
81This actually is the core structure in the SSL API.
82Under run-time the application usually deals with this structure which has
83links to mostly all other structures.
84.El
85.Sh HEADER FILES
86Currently the OpenSSL
87.Nm ssl
88library provides the following C header files containing the prototypes for the
89data structures and functions:
90.Bl -tag -width Ds
91.It Pa ssl.h
92That's the common header file for the SSL/TLS API.
93Include it into your program to make the API of the
94.Nm ssl
95library available.
96It internally includes both more private SSL headers and headers from the
97.Em crypto
98library.
99Whenever you need hardcore details on the internals of the SSL API, look inside
100this header file.
101.It Pa ssl2.h
102That's the sub header file dealing with the SSLv2 protocol only.
103.Bf Em
104 Usually you don't have to include it explicitly because it's already included
105by
106.Pa ssl.h .
107.Ef
108.It Pa ssl3.h
109That's the sub header file dealing with the SSLv3 protocol only.
110.Bf Em
111Usually you don't have to include it explicitly because it's already included
112by
113.Pa ssl.h .
114.Ef
115.It Pa ssl23.h
116That's the sub header file dealing with the combined use of the SSLv2 and SSLv3
117protocols.
118.Bf Em
119Usually you don't have to include it explicitly because it's already included
120by
121.Pa ssl.h .
122.Ef
123.It Pa tls1.h
124That's the sub header file dealing with the TLSv1 protocol only.
125.Bf Em
126Usually you don't have to include it explicitly because it's already included
127by
128.Pa ssl.h .
129.Ef
130.El
131.Sh API FUNCTIONS
132The functions that the OpenSSL
133.Nm ssl
134library exports are documented below:
135.Ss DEALING WITH PROTOCOL METHODS
136Here we document the various API functions which deal with the SSL/TLS protocol
137methods defined in
138.Vt SSL_METHOD
139structures.
140.Bl -tag -width Ds
141.It Xo
142.Ft const SSL_METHOD *
143.Fn SSLv2_client_method void
144.Xc
145Constructor for the SSLv2
146.Vt SSL_METHOD
147structure for a dedicated client.
148.It Xo
149.Ft const SSL_METHOD *
150.Fn SSLv2_server_method void
151.Xc
152Constructor for the SSLv2
153.Vt SSL_METHOD
154structure for a dedicated server.
155.It Xo
156.Ft const SSL_METHOD *
157.Fn SSLv2_method void
158.Xc
159Constructor for the SSLv2
160.Vt SSL_METHOD
161structure for combined client and server.
162.It Xo
163.Ft const SSL_METHOD *
164.Fn SSLv3_client_method void
165.Xc
166Constructor for the SSLv3
167.Vt SSL_METHOD
168structure for a dedicated client.
169.It Xo
170.Ft const SSL_METHOD *
171.Fn SSLv3_server_method void
172.Xc
173Constructor for the SSLv3
174.Vt SSL_METHOD
175structure for a dedicated server.
176.It Xo
177.Ft const SSL_METHOD *
178.Fn SSLv3_method void
179.Xc
180Constructor for the SSLv3
181.Vt SSL_METHOD
182structure for combined client and server.
183.It Xo
184.Ft const SSL_METHOD *
185.Fn TLSv1_client_method void
186.Xc
187Constructor for the TLSv1
188.Vt SSL_METHOD
189structure for a dedicated client.
190.It Xo
191.Ft const SSL_METHOD *
192.Fn TLSv1_server_method void
193.Xc
194Constructor for the TLSv1
195.Vt SSL_METHOD
196structure for a dedicated server.
197.It Xo
198.Ft const SSL_METHOD *
199.Fn TLSv1_method void
200.Xc
201Constructor for the TLSv1
202.Vt SSL_METHOD
203structure for combined client and server.
204.El
205.Ss DEALING WITH CIPHERS
206Here we document the various API functions which deal with the SSL/TLS ciphers
207defined in
208.Vt SSL_CIPHER
209structures.
210.Bl -tag -width Ds
211.It Xo
212.Ft char *
213.Fn SSL_CIPHER_description "SSL_CIPHER *cipher" "char *buf" "int len"
214.Xc
215Write a string to
216.Fa buf
217(with a maximum size of
218.Fa len )
219containing a human readable description of
220.Fa cipher .
221Returns
222.Fa buf .
223.It Xo
224.Ft int
225.Fn SSL_CIPHER_get_bits "SSL_CIPHER *cipher" "int *alg_bits"
226.Xc
227Determine the number of bits in
228.Fa cipher .
229Because of export crippled ciphers there are two bits:
230the bits the algorithm supports in general (stored to
231.Fa alg_bits )
232and the bits which are actually used (the return value).
233.It Xo
234.Ft const char *
235.Fn SSL_CIPHER_get_name "SSL_CIPHER *cipher"
236.Xc
237Return the internal name of
238.Fa cipher
239as a string.
240These are the various strings defined by the
241.Dv SSL2_TXT_xxx ,
242.Dv SSL3_TXT_xxx
243and
244.Dv TLS1_TXT_xxx
245definitions in the header files.
246.It Xo
247.Ft char *
248.Fn SSL_CIPHER_get_version "SSL_CIPHER *cipher"
249.Xc
250Returns a string like
251Qq TLSv1/SSLv3
252or
253Qq SSLv2
254which indicates the SSL/TLS protocol version to which
255.Fa cipher
256belongs (i.e., where it was defined in the specification the first time).
257.El
258.Ss DEALING WITH PROTOCOL CONTEXTS
259Here we document the various API functions which deal with the SSL/TLS
260protocol context defined in the
261.Vt SSL_CTX
262structure.
263.Bl -tag -width Ds
264.It Xo
265.Ft int
266.Fn SSL_CTX_add_client_CA "SSL_CTX *ctx" "X509 *x"
267.Xc
268.It Xo
269.Ft long
270.Fn SSL_CTX_add_extra_chain_cert "SSL_CTX *ctx" "X509 *x509"
271.Xc
272.It Xo
273.Ft int
274.Fn SSL_CTX_add_session "SSL_CTX *ctx" "SSL_SESSION *c"
275.Xc
276.It Xo
277.Ft int
278.Fn SSL_CTX_check_private_key "const SSL_CTX *ctx"
279.Xc
280.It Xo
281.Ft long
282.Fn SSL_CTX_ctrl "SSL_CTX *ctx" "int cmd" "long larg" "char *parg"
283.Xc
284.It Xo
285.Ft void
286.Fn SSL_CTX_flush_sessions "SSL_CTX *s" "long t"
287.Xc
288.It Xo
289.Ft void
290.Fn SSL_CTX_free "SSL_CTX *a"
291.Xc
292.It Xo
293.Ft char *
294.Fn SSL_CTX_get_app_data "SSL_CTX *ctx"
295.Xc
296.It Xo
297.Ft X509_STORE *
298.Fn SSL_CTX_get_cert_store "SSL_CTX *ctx"
299.Xc
300.It Xo
301.Ft STACK *
302.Fn SSL_CTX_get_client_CA_list "const SSL_CTX *ctx"
303.Xc
304.It Xo
305.Ft int
306.Fn "(*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx))"
307.Fa "SSL *ssl" "X509 **x509" "EVP_PKEY **pkey"
308.Xc
309.It Xo
310.Ft char *
311.Fn SSL_CTX_get_ex_data "const SSL_CTX *s" "int idx"
312.Xc
313.It Xo
314.Ft int
315.Fo SSL_CTX_get_ex_new_index
316.Fa "long argl"
317.Fa "void *argp"
318.Fa "CRYPTO_EX_new *new_func"
319.Fa "CRYPTO_EX_dup *dup_func"
320.Fa "CRYPTO_EX_free *free_func"
321.Fc
322.Xc
323.It Xo
324.Ft void
325.Fo "(*SSL_CTX_get_info_callback(const SSL_CTX *ctx))"
326.Fa "SSL *ssl"
327.Fa "int cb"
328.Fa "int ret"
329.Fc
330.Xc
331.It Xo
332.Ft int
333.Fn SSL_CTX_get_quiet_shutdown "const SSL_CTX *ctx"
334.Xc
335.It Xo
336.Ft int
337.Fn SSL_CTX_get_session_cache_mode "SSL_CTX *ctx"
338.Xc
339.It Xo
340.Ft long
341.Fn SSL_CTX_get_timeout "const SSL_CTX *ctx"
342.Xc
343.It Xo
344.Ft int
345.Fo "(*SSL_CTX_get_verify_callback(const SSL_CTX *ctx))"
346.Fa "int ok"
347.Fa "X509_STORE_CTX *ctx"
348.Fc
349.Xc
350.It Xo
351.Ft int
352.Fn SSL_CTX_get_verify_mode "SSL_CTX *ctx"
353.Xc
354.It Xo
355.Ft int
356.Fn SSL_CTX_load_verify_locations "SSL_CTX *ctx" "char *CAfile" "char *CApath"
357.Xc
358.It Xo
359.Ft long
360.Fn SSL_CTX_need_tmp_RSA "SSL_CTX *ctx"
361.Xc
362.It Xo
363.Ft SSL_CTX *
364.Fn SSL_CTX_new "const SSL_METHOD *meth"
365.Xc
366.It Xo
367.Ft int
368.Fn SSL_CTX_remove_session "SSL_CTX *ctx" "SSL_SESSION *c"
369.Xc
370.It Xo
371.Ft int
372.Fn SSL_CTX_sess_accept "SSL_CTX *ctx"
373.Xc
374.It Xo
375.Ft int
376.Fn SSL_CTX_sess_accept_good "SSL_CTX *ctx"
377.Xc
378.It Xo
379.Ft int
380.Fn SSL_CTX_sess_accept_renegotiate "SSL_CTX *ctx"
381.Xc
382.It Xo
383.Ft int
384.Fn SSL_CTX_sess_cache_full "SSL_CTX *ctx"
385.Xc
386.It Xo
387.Ft int
388.Fn SSL_CTX_sess_cb_hits "SSL_CTX *ctx"
389.Xc
390.It Xo
391.Ft int
392.Fn SSL_CTX_sess_connect "SSL_CTX *ctx"
393.Xc
394.It Xo
395.Ft int
396.Fn SSL_CTX_sess_connect_good "SSL_CTX *ctx"
397.Xc
398.It Xo
399.Ft int
400.Fn SSL_CTX_sess_connect_renegotiate "SSL_CTX *ctx"
401.Xc
402.It Xo
403.Ft int
404.Fn SSL_CTX_sess_get_cache_size "SSL_CTX *ctx"
405.Xc
406.It Xo
407.Ft SSL_SESSION *
408.Fo "(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx))"
409.Fa "SSL *ssl"
410.Fa "unsigned char *data"
411.Fa "int len"
412.Fa "int *copy"
413.Fc
414.Xc
415.It Xo
416.Ft int
417.Fn "(*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx))" "SSL *ssl" "SSL_SESSION *sess"
418.Xc
419.It Xo
420.Ft void
421.Fo "(*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx))"
422.Fa "SSL_CTX *ctx"
423.Fa "SSL_SESSION *sess"
424.Fc
425.Xc
426.It Xo
427.Ft int
428.Fn SSL_CTX_sess_hits "SSL_CTX *ctx"
429.Xc
430.It Xo
431.Ft int
432.Fn SSL_CTX_sess_misses "SSL_CTX *ctx"
433.Xc
434.It Xo
435.Ft int
436.Fn SSL_CTX_sess_number "SSL_CTX *ctx"
437.Xc
438.It Xo
439.Ft void
440.Fn SSL_CTX_sess_set_cache_size "SSL_CTX *ctx" "long t"
441.Xc
442.It Xo
443.Ft void
444.Fo SSL_CTX_sess_set_get_cb
445.Fa "SSL_CTX *ctx"
446.Fa "SSL_SESSION *(*cb)(SSL *ssl, unsigned char *data, int len, int *copy)"
447.Fc
448.Xc
449.It Xo
450.Ft void
451.Fo SSL_CTX_sess_set_new_cb
452.Fa "SSL_CTX *ctx"
453.Fa "int (*cb)(SSL *ssl, SSL_SESSION *sess)"
454.Fc
455.Xc
456.It Xo
457.Ft void
458.Fo SSL_CTX_sess_set_remove_cb
459.Fa "SSL_CTX *ctx"
460.Fa "void (*cb)(SSL_CTX *ctx, SSL_SESSION *sess)"
461.Fc
462.Xc
463.It Xo
464.Ft int
465.Fn SSL_CTX_sess_timeouts "SSL_CTX *ctx"
466.Xc
467.It Xo
468.Ft LHASH *
469.Fn SSL_CTX_sessions "SSL_CTX *ctx"
470.Xc
471.It Xo
472.Ft void
473.Fn SSL_CTX_set_app_data "SSL_CTX *ctx" "void *arg"
474.Xc
475.It Xo
476.Ft void
477.Fn SSL_CTX_set_cert_store "SSL_CTX *ctx" "X509_STORE *cs"
478.Xc
479.It Xo
480.Ft void
481.Fn SSL_CTX_set_cert_verify_cb "SSL_CTX *ctx" "int (*cb)()" "char *arg"
482.Xc
483.It Xo
484.Ft int
485.Fn SSL_CTX_set_cipher_list "SSL_CTX *ctx" "char *str"
486.Xc
487.It Xo
488.Ft void
489.Fn SSL_CTX_set_client_CA_list "SSL_CTX *ctx" "STACK *list"
490.Xc
491.It Xo
492.Ft void
493.Fo SSL_CTX_set_client_cert_cb
494.Fa "SSL_CTX *ctx"
495.Fa "int (*cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey)"
496.Fc
497.Xc
498.It Xo
499.Ft void
500.Fn SSL_CTX_set_default_passwd_cb "SSL_CTX *ctx" "pem_password_cb *cb"
501.Xc
502.It Xo
503.Ft void
504.Fn SSL_CTX_set_default_read_ahead "SSL_CTX *ctx" "int m"
505.Xc
506.It Xo
507.Ft int
508.Fn SSL_CTX_set_default_verify_paths "SSL_CTX *ctx"
509.Xc
510.It Xo
511.Ft int
512.Fn SSL_CTX_set_ex_data "SSL_CTX *s" "int idx" "char *arg"
513.Xc
514.It Xo
515.Ft void
516.Fo SSL_CTX_set_info_callback
517.Fa "SSL_CTX *ctx"
518.Fa "void (*cb)(SSL *ssl, int cb, int ret)"
519.Fc
520.Xc
521.It Xo
522.Ft void
523.Fo SSL_CTX_set_msg_callback
524.Fa "SSL_CTX *ctx"
525.Fa "void (*cb)(int write_p, int version, int content_type, const void *buf, \
526size_t len, SSL *ssl, void *arg)"
527.Fc
528.Xc
529.It Xo
530.Ft void
531.Fn SSL_CTX_set_msg_callback_arg "SSL_CTX *ctx" "void *arg"
532.Xc
533.It Xo
534.Ft void
535.Fn SSL_CTX_set_options "SSL_CTX *ctx" "unsigned long op"
536.Xc
537.It Xo
538.Ft void
539.Fn SSL_CTX_set_quiet_shutdown "SSL_CTX *ctx" "int mode"
540.Xc
541.It Xo
542.Ft void
543.Fn SSL_CTX_set_session_cache_mode "SSL_CTX *ctx" "int mode"
544.Xc
545.It Xo
546.Ft int
547.Fn SSL_CTX_set_ssl_version "SSL_CTX *ctx" "const SSL_METHOD *meth"
548.Xc
549.It Xo
550.Ft void
551.Fn SSL_CTX_set_timeout "SSL_CTX *ctx" "long t"
552.Xc
553.It Xo
554.Ft long
555.Fn SSL_CTX_set_tmp_dh "SSL_CTX* ctx" "DH *dh"
556.Xc
557.It Xo
558.Ft long
559.Fn SSL_CTX_set_tmp_dh_callback "SSL_CTX *ctx" "DH *(*cb)(void)"
560.Xc
561.It Xo
562.Ft long
563.Fn SSL_CTX_set_tmp_rsa "SSL_CTX *ctx" "RSA *rsa"
564.Xc
565.It Xo
566.Fn SSL_CTX_set_tmp_rsa_callback
567.Xc
568.Ft long
569.Fo SSL_CTX_set_tmp_rsa_callback
570.Fa "SSL_CTX *ctx"
571.Fa "RSA *(*cb)(SSL *ssl, int export, int keylength)"
572.Fc
573.Pp
574Sets the callback which will be called when a temporary private key is
575required.
576The
577.Fa export
578flag will be set if the reason for needing a temp key is that an export
579ciphersuite is in use, in which case,
580.Fa keylength
581will contain the required keylength in bits.
582.\" XXX using what?
583Generate a key of appropriate size (using ???) and return it.
584.It Xo
585.Fn SSL_set_tmp_rsa_callback
586.Xc
587.Ft long
588.Fo SSL_set_tmp_rsa_callback
589.Fa "SSL *ssl"
590.Fa "RSA *(*cb)(SSL *ssl, int export, int keylength)"
591.Fc
592.Pp
593The same as
594.Fn SSL_CTX_set_tmp_rsa_callback ,
595except it operates on an
596.Vt SSL
597session instead of a context.
598.It Xo
599.Ft void
600.Fn SSL_CTX_set_verify "SSL_CTX *ctx" "int mode" "int (*cb)(void)"
601.Xc
602.It Xo
603.Ft int
604.Fn SSL_CTX_use_PrivateKey "SSL_CTX *ctx" "EVP_PKEY *pkey"
605.Xc
606.It Xo
607.Ft int
608.Fo SSL_CTX_use_PrivateKey_ASN1
609.Fa "int type"
610.Fa "SSL_CTX *ctx"
611.Fa "unsigned char *d"
612.Fa "long len"
613.Fc
614.Xc
615.It Xo
616.Ft int
617.Fn SSL_CTX_use_PrivateKey_file "SSL_CTX *ctx" "char *file" "int type"
618.Xc
619.It Xo
620.Ft int
621.Fn SSL_CTX_use_RSAPrivateKey "SSL_CTX *ctx" "RSA *rsa"
622.Xc
623.It Xo
624.Ft int
625.Fn SSL_CTX_use_RSAPrivateKey_ASN1 "SSL_CTX *ctx" "unsigned char *d" "long len"
626.Xc
627.It Xo
628.Ft int
629.Fn SSL_CTX_use_RSAPrivateKey_file "SSL_CTX *ctx" "char *file" "int type"
630.Xc
631.It Xo
632.Ft int
633.Fn SSL_CTX_use_certificate "SSL_CTX *ctx" "X509 *x"
634.Xc
635.It Xo
636.Ft int
637.Fn SSL_CTX_use_certificate_ASN1 "SSL_CTX *ctx" "int len" "unsigned char *d"
638.Xc
639.It Xo
640.Ft int
641.Fn SSL_CTX_use_certificate_file "SSL_CTX *ctx" "char *file" "int type"
642.Xc
643.It Xo
644.Ft void
645.Fo SSL_CTX_set_psk_client_callback
646.Fa "SSL_CTX *ctx"
647.Fa "unsigned int (*callback)(SSL *ssl, const char *hint, char *identity, \
648unsigned int max_identity_len, unsigned char *psk, unsigned int max_psk_len)"
649.Fc
650.Xc
651.It Xo
652.Ft int
653.Fn SSL_CTX_use_psk_identity_hint "SSL_CTX *ctx" "const char *hint"
654.Xc
655.It Xo
656.Ft void
657.Fo SSL_CTX_set_psk_server_callback
658.Fa "SSL_CTX *ctx"
659.Fa "unsigned int (*callback)(SSL *ssl, const char *identity, \
660unsigned char *psk, int max_psk_len)"
661.Fc
662.Xc
663.El
664.Ss DEALING WITH SESSIONS
665Here we document the various API functions which deal with the SSL/TLS sessions
666defined in the
667.Vt SSL_SESSION
668structures.
669.Bl -tag -width Ds
670.It Xo
671.Ft int
672.Fn SSL_SESSION_cmp "const SSL_SESSION *a" "const SSL_SESSION *b"
673.Xc
674.It Xo
675.Ft void
676.Fn SSL_SESSION_free "SSL_SESSION *ss"
677.Xc
678.It Xo
679.Ft char *
680.Fn SSL_SESSION_get_app_data "SSL_SESSION *s"
681.Xc
682.It Xo
683.Ft char *
684.Fn SSL_SESSION_get_ex_data "const SSL_SESSION *s" "int idx"
685.Xc
686.It Xo
687.Ft int
688.Fo SSL_SESSION_get_ex_new_index
689.Fa "long argl"
690.Fa "char *argp"
691.Fa "int (*new_func)(void)"
692.Fa "int (*dup_func)(void), void (*free_func)(void)"
693.Fc
694.Xc
695.It Xo
696.Ft long
697.Fn SSL_SESSION_get_time "const SSL_SESSION *s"
698.Xc
699.It Xo
700.Ft long
701.Fn SSL_SESSION_get_timeout "const SSL_SESSION *s"
702.Xc
703.It Xo
704.Ft unsigned long
705.Fn SSL_SESSION_hash "const SSL_SESSION *a"
706.Xc
707.It Xo
708.Ft SSL_SESSION *
709.Fn SSL_SESSION_new void
710.Xc
711.It Xo
712.Ft int
713.Fn SSL_SESSION_print "BIO *bp" "const SSL_SESSION *x"
714.Xc
715.It Xo
716.Ft int
717.Fn SSL_SESSION_print_fp "FILE *fp" "const SSL_SESSION *x"
718.Xc
719.It Xo
720.Ft void
721.Fn SSL_SESSION_set_app_data "SSL_SESSION *s" "char *a"
722.Xc
723.It Xo
724.Ft int
725.Fn SSL_SESSION_set_ex_data "SSL_SESSION *s" "int idx" "char *arg"
726.Xc
727.It Xo
728.Ft long
729.Fn SSL_SESSION_set_time "SSL_SESSION *s" "long t"
730.Xc
731.It Xo
732.Ft long
733.Fn SSL_SESSION_set_timeout "SSL_SESSION *s" "long t"
734.Xc
735.El
736.Ss DEALING WITH CONNECTIONS
737Here we document the various API functions which deal with the SSL/TLS
738connection defined in the
739.Vt SSL
740structure.
741.Bl -tag -width Ds
742.It Xo
743.Ft int
744.Fn SSL_accept "SSL *ssl"
745.Xc
746.It Xo
747.Ft int
748.Fn SSL_add_dir_cert_subjects_to_stack "STACK *stack" "const char *dir"
749.Xc
750.It Xo
751.Ft int
752.Fn SSL_add_file_cert_subjects_to_stack "STACK *stack" "const char *file"
753.Xc
754.It Xo
755.Ft int
756.Fn SSL_add_client_CA "SSL *ssl" "X509 *x"
757.Xc
758.It Xo
759.Ft char *
760.Fn SSL_alert_desc_string "int value"
761.Xc
762.It Xo
763.Ft char *
764.Fn SSL_alert_desc_string_long "int value"
765.Xc
766.It Xo
767.Ft char *
768.Fn SSL_alert_type_string "int value"
769.Xc
770.It Xo
771.Ft char *
772.Fn SSL_alert_type_string_long "int value"
773.Xc
774.It Xo
775.Ft int
776.Fn SSL_check_private_key "const SSL *ssl"
777.Xc
778.It Xo
779.Ft void
780.Fn SSL_clear "SSL *ssl"
781.Xc
782.It Xo
783.Ft long
784.Fn SSL_clear_num_renegotiations "SSL *ssl"
785.Xc
786.It Xo
787.Ft int
788.Fn SSL_connect "SSL *ssl"
789.Xc
790.It Xo
791.Ft void
792.Fn SSL_copy_session_id "SSL *t" "const SSL *f"
793.Xc
794.It Xo
795.Ft long
796.Fn SSL_ctrl "SSL *ssl" "int cmd" "long larg" "char *parg"
797.Xc
798.It Xo
799.Ft int
800.Fn SSL_do_handshake "SSL *ssl"
801.Xc
802.It Xo
803.Ft SSL *
804.Fn SSL_dup "SSL *ssl"
805.Xc
806.It Xo
807.Ft STACK *
808.Fn SSL_dup_CA_list "STACK *sk"
809.Xc
810.It Xo
811.Ft void
812.Fn SSL_free "SSL *ssl"
813.Xc
814.It Xo
815.Ft SSL_CTX *
816.Fn SSL_get_SSL_CTX "const SSL *ssl"
817.Xc
818.It Xo
819.Ft char *
820.Fn SSL_get_app_data "SSL *ssl"
821.Xc
822.It Xo
823.Ft X509 *
824.Fn SSL_get_certificate "const SSL *ssl"
825.Xc
826.It Xo
827.Ft const char *
828.Fn SSL_get_cipher "const SSL *ssl"
829.Xc
830.It Xo
831.Ft int
832.Fn SSL_get_cipher_bits "const SSL *ssl" "int *alg_bits"
833.Xc
834.It Xo
835.Ft char *
836.Fn SSL_get_cipher_list "const SSL *ssl" "int n"
837.Xc
838.It Xo
839.Ft char *
840.Fn SSL_get_cipher_name "const SSL *ssl"
841.Xc
842.It Xo
843.Ft char *
844.Fn SSL_get_cipher_version "const SSL *ssl"
845.Xc
846.It Xo
847.Ft STACK *
848.Fn SSL_get_ciphers "const SSL *ssl"
849.Xc
850.It Xo
851.Ft STACK *
852.Fn SSL_get_client_CA_list "const SSL *ssl"
853.Xc
854.It Xo
855.Ft SSL_CIPHER *
856.Fn SSL_get_current_cipher "SSL *ssl"
857.Xc
858.It Xo
859.Ft long
860.Fn SSL_get_default_timeout "const SSL *ssl"
861.Xc
862.It Xo
863.Ft int
864.Fn SSL_get_error "const SSL *ssl" "int i"
865.Xc
866.It Xo
867.Ft char *
868.Fn SSL_get_ex_data "const SSL *ssl" "int idx"
869.Xc
870.It Xo
871.Ft int
872.Fn SSL_get_ex_data_X509_STORE_CTX_idx void
873.Xc
874.It Xo
875.Ft int
876.Fo SSL_get_ex_new_index
877.Fa "long argl"
878.Fa "char *argp"
879.Fa "int (*new_func)(void)"
880.Fa "int (*dup_func)(void)"
881.Fa "void (*free_func)(void)"
882.Fc
883.Xc
884.It Xo
885.Ft int
886.Fn SSL_get_fd "const SSL *ssl"
887.Xc
888.It Xo
889.Ft void
890.Fn "(*SSL_get_info_callback(const SSL *ssl))"
891.Xc
892.It Xo
893.Ft STACK *
894.Fn SSL_get_peer_cert_chain "const SSL *ssl"
895.Xc
896.It Xo
897.Ft X509 *
898.Fn SSL_get_peer_certificate "const SSL *ssl"
899.Xc
900.It Xo
901.Ft EVP_PKEY *
902.Fn SSL_get_privatekey "SSL *ssl"
903.Xc
904.It Xo
905.Ft int
906.Fn SSL_get_quiet_shutdown "const SSL *ssl"
907.Xc
908.It Xo
909.Ft BIO *
910.Fn SSL_get_rbio "const SSL *ssl"
911.Xc
912.It Xo
913.Ft int
914.Fn SSL_get_read_ahead "const SSL *ssl"
915.Xc
916.It Xo
917.Ft SSL_SESSION *
918.Fn SSL_get_session "const SSL *ssl"
919.Xc
920.It Xo
921.Ft char *
922.Fn SSL_get_shared_ciphers "const SSL *ssl" "char *buf" "int len"
923.Xc
924.It Xo
925.Ft int
926.Fn SSL_get_shutdown "const SSL *ssl"
927.Xc
928.It Xo
929.Ft const SSL_METHOD *
930.Fn SSL_get_ssl_method "SSL *ssl"
931.Xc
932.It Xo
933.Ft int
934.Fn SSL_get_state "const SSL *ssl"
935.Xc
936.It Xo
937.Ft long
938.Fn SSL_get_time "const SSL *ssl"
939.Xc
940.It Xo
941.Ft long
942.Fn SSL_get_timeout "const SSL *ssl"
943.Xc
944.It Xo
945.Ft int
946.Fn "(*SSL_get_verify_callback(const SSL *ssl))" int "X509_STORE_CTX *"
947.Xc
948.It Xo
949.Ft int
950.Fn SSL_get_verify_mode "const SSL *ssl"
951.Xc
952.It Xo
953.Ft long
954.Fn SSL_get_verify_result "const SSL *ssl"
955.Xc
956.It Xo
957.Ft char *
958.Fn SSL_get_version "const SSL *ssl"
959.Xc
960.It Xo
961.Ft BIO *
962.Fn SSL_get_wbio "const SSL *ssl"
963.Xc
964.It Xo
965.Ft int
966.Fn SSL_in_accept_init "SSL *ssl"
967.Xc
968.It Xo
969.Ft int
970.Fn SSL_in_before "SSL *ssl"
971.Xc
972.It Xo
973.Ft int
974.Fn SSL_in_connect_init "SSL *ssl"
975.Xc
976.It Xo
977.Ft int
978.Fn SSL_in_init "SSL *ssl"
979.Xc
980.It Xo
981.Ft int
982.Fn SSL_is_init_finished "SSL *ssl"
983.Xc
984.It Xo
985.Ft STACK *
986.Fn SSL_load_client_CA_file "char *file"
987.Xc
988.It Xo
989.Ft void
990.Fn SSL_load_error_strings "void"
991.Xc
992.It Xo
993.Ft SSL *
994.Fn SSL_new "SSL_CTX *ctx"
995.Xc
996.It Xo
997.Ft long
998.Fn SSL_num_renegotiations "SSL *ssl"
999.Xc
1000.It Xo
1001.Ft int
1002.Fn SSL_peek "SSL *ssl" "void *buf" "int num"
1003.Xc
1004.It Xo
1005.Ft int
1006.Fn SSL_pending "const SSL *ssl"
1007.Xc
1008.It Xo
1009.Ft int
1010.Fn SSL_read "SSL *ssl" "void *buf" "int num"
1011.Xc
1012.It Xo
1013.Ft int
1014.Fn SSL_renegotiate "SSL *ssl"
1015.Xc
1016.It Xo
1017.Ft char *
1018.Fn SSL_rstate_string "SSL *ssl"
1019.Xc
1020.It Xo
1021.Ft char *
1022.Fn SSL_rstate_string_long "SSL *ssl"
1023.Xc
1024.It Xo
1025.Ft long
1026.Fn SSL_session_reused "SSL *ssl"
1027.Xc
1028.It Xo
1029.Ft void
1030.Fn SSL_set_accept_state "SSL *ssl"
1031.Xc
1032.It Xo
1033.Ft void
1034.Fn SSL_set_app_data "SSL *ssl" "char *arg"
1035.Xc
1036.It Xo
1037.Ft void
1038.Fn SSL_set_bio "SSL *ssl" "BIO *rbio" "BIO *wbio"
1039.Xc
1040.It Xo
1041.Ft int
1042.Fn SSL_set_cipher_list "SSL *ssl" "char *str"
1043.Xc
1044.It Xo
1045.Ft void
1046.Fn SSL_set_client_CA_list "SSL *ssl" "STACK *list"
1047.Xc
1048.It Xo
1049.Ft void
1050.Fn SSL_set_connect_state "SSL *ssl"
1051.Xc
1052.It Xo
1053.Ft int
1054.Fn SSL_set_ex_data "SSL *ssl" "int idx" "char *arg"
1055.Xc
1056.It Xo
1057.Ft int
1058.Fn SSL_set_fd "SSL *ssl" "int fd"
1059.Xc
1060.It Xo
1061.Ft void
1062.Fn SSL_set_info_callback "SSL *ssl" "void (*cb)(void)"
1063.Xc
1064.It Xo
1065.Ft void
1066.Fo SSL_set_msg_callback
1067.Fa "SSL *ctx"
1068.Fa "void (*cb)(int write_p, int version, int content_type, const void *buf, \
1069size_t len, SSL *ssl, void *arg)"
1070.Fc
1071.Xc
1072.It Xo
1073.Ft void
1074.Fn SSL_set_msg_callback_arg "SSL *ctx" "void *arg"
1075.Xc
1076.It Xo
1077.Ft void
1078.Fn SSL_set_options "SSL *ssl" "unsigned long op"
1079.Xc
1080.It Xo
1081.Ft void
1082.Fn SSL_set_quiet_shutdown "SSL *ssl" "int mode"
1083.Xc
1084.It Xo
1085.Ft void
1086.Fn SSL_set_read_ahead "SSL *ssl" "int yes"
1087.Xc
1088.It Xo
1089.Ft int
1090.Fn SSL_set_rfd "SSL *ssl" "int fd"
1091.Xc
1092.It Xo
1093.Ft int
1094.Fn SSL_set_session "SSL *ssl" "SSL_SESSION *session"
1095.Xc
1096.It Xo
1097.Ft void
1098.Fn SSL_set_shutdown "SSL *ssl" "int mode"
1099.Xc
1100.It Xo
1101.Ft int
1102.Fn SSL_set_ssl_method "SSL *ssl" "const SSL_METHOD *meth"
1103.Xc
1104.It Xo
1105.Ft void
1106.Fn SSL_set_time "SSL *ssl" "long t"
1107.Xc
1108.It Xo
1109.Ft void
1110.Fn SSL_set_timeout "SSL *ssl" "long t"
1111.Xc
1112.It Xo
1113.Ft void
1114.Fn SSL_set_verify "SSL *ssl" "int mode" "int (*callback)(void)"
1115.Xc
1116.It Xo
1117.Ft void
1118.Fn SSL_set_verify_result "SSL *ssl" "long arg"
1119.Xc
1120.It Xo
1121.Ft int
1122.Fn SSL_set_wfd "SSL *ssl" "int fd"
1123.Xc
1124.It Xo
1125.Ft int
1126.Fn SSL_shutdown "SSL *ssl"
1127.Xc
1128.It Xo
1129.Ft int
1130.Fn SSL_state "const SSL *ssl"
1131.Xc
1132.It Xo
1133.Ft char *
1134.Fn SSL_state_string "const SSL *ssl"
1135.Xc
1136.It Xo
1137.Ft char *
1138.Fn SSL_state_string_long "const SSL *ssl"
1139.Xc
1140.It Xo
1141.Ft long
1142.Fn SSL_total_renegotiations "SSL *ssl"
1143.Xc
1144.It Xo
1145.Ft int
1146.Fn SSL_use_PrivateKey "SSL *ssl" "EVP_PKEY *pkey"
1147.Xc
1148.It Xo
1149.Ft int
1150.Fn SSL_use_PrivateKey_ASN1 "int type" "SSL *ssl" "unsigned char *d" "long len"
1151.Xc
1152.It Xo
1153.Ft int
1154.Fn SSL_use_PrivateKey_file "SSL *ssl" "char *file" "int type"
1155.Xc
1156.It Xo
1157.Ft int
1158.Fn SSL_use_RSAPrivateKey "SSL *ssl" "RSA *rsa"
1159.Xc
1160.It Xo
1161.Ft int
1162.Fn SSL_use_RSAPrivateKey_ASN1 "SSL *ssl" "unsigned char *d" "long len"
1163.Xc
1164.It Xo
1165.Ft int
1166.Fn SSL_use_RSAPrivateKey_file "SSL *ssl" "char *file" "int type"
1167.Xc
1168.It Xo
1169.Ft int
1170.Fn SSL_use_certificate "SSL *ssl" "X509 *x"
1171.Xc
1172.It Xo
1173.Ft int
1174.Fn SSL_use_certificate_ASN1 "SSL *ssl" "int len" "unsigned char *d"
1175.Xc
1176.It Xo
1177.Ft int
1178.Fn SSL_use_certificate_file "SSL *ssl" "char *file" "int type"
1179.Xc
1180.It Xo
1181.Ft int
1182.Fn SSL_version "const SSL *ssl"
1183.Xc
1184.It Xo
1185.Ft int
1186.Fn SSL_want "const SSL *ssl"
1187.Xc
1188.It Xo
1189.Ft int
1190.Fn SSL_want_nothing "const SSL *ssl"
1191.Xc
1192.It Xo
1193.Ft int
1194.Fn SSL_want_read "const SSL *ssl"
1195.Xc
1196.It Xo
1197.Ft int
1198.Fn SSL_want_write "const SSL *ssl"
1199.Xc
1200.It Xo
1201.Ft int
1202.Fn SSL_want_x509_lookup "const SSL *ssl"
1203.Xc
1204.It Xo
1205.Ft int
1206.Fn SSL_write "SSL *ssl" "const void *buf" "int num"
1207.Xc
1208.It Xo
1209.Ft void
1210.Fo SSL_set_psk_client_callback
1211.Fa "SSL *ssl"
1212.Fa "unsigned int (*callback)(SSL *ssl, const char *hint, char *identity, \
1213unsigned int max_identity_len, unsigned char *psk, unsigned int max_psk_len)"
1214.Fc
1215.Xc
1216.It Xo
1217.Ft int
1218.Fn SSL_use_psk_identity_hint "SSL *ssl" "const char *hint"
1219.Xc
1220.It Xo
1221.Ft void
1222.Fo SSL_set_psk_server_callback
1223.Fa "SSL *ssl"
1224.Fa "unsigned int (*callback)(SSL *ssl, const char *identity, \
1225unsigned char *psk, int max_psk_len)"
1226.Fc
1227.Xc
1228.It Xo
1229.Ft const char *
1230.Fn SSL_get_psk_identity_hint "SSL *ssl"
1231.Xc
1232.It Xo
1233.Ft const char *
1234.Fn SSL_get_psk_identity "SSL *ssl"
1235.Xc
1236.El
1237.Sh SEE ALSO
1238.Xr openssl 1 ,
1239.Xr crypto 3 ,
1240.Xr d2i_SSL_SESSION 3 ,
1241.Xr SSL_accept 3 ,
1242.Xr SSL_alert_type_string 3 ,
1243.Xr SSL_CIPHER_get_name 3 ,
1244.Xr SSL_clear 3 ,
1245.Xr SSL_COMP_add_compression_method 3 ,
1246.Xr SSL_connect 3 ,
1247.Xr SSL_CTX_add_extra_chain_cert 3 ,
1248.Xr SSL_CTX_add_session 3 ,
1249.Xr SSL_CTX_ctrl 3 ,
1250.Xr SSL_CTX_flush_sessions 3 ,
1251.Xr SSL_CTX_get_ex_new_index 3 ,
1252.Xr SSL_CTX_get_verify_mode 3 ,
1253.Xr SSL_CTX_load_verify_locations 3 ,
1254.Xr SSL_CTX_new 3 ,
1255.Xr SSL_CTX_sess_number 3 ,
1256.Xr SSL_CTX_sess_set_cache_size 3 ,
1257.Xr SSL_CTX_sess_set_get_cb 3 ,
1258.Xr SSL_CTX_sessions 3 ,
1259.Xr SSL_CTX_set_cert_store 3 ,
1260.Xr SSL_CTX_set_cert_verify_callback 3 ,
1261.Xr SSL_CTX_set_cipher_list 3 ,
1262.Xr SSL_CTX_set_client_CA_list 3 ,
1263.Xr SSL_CTX_set_client_cert_cb 3 ,
1264.Xr SSL_CTX_set_default_passwd_cb 3 ,
1265.Xr SSL_CTX_set_generate_session_id 3 ,
1266.Xr SSL_CTX_set_info_callback 3 ,
1267.Xr SSL_CTX_set_max_cert_list 3 ,
1268.Xr SSL_CTX_set_mode 3 ,
1269.Xr SSL_CTX_set_msg_callback 3 ,
1270.Xr SSL_CTX_set_options 3 ,
1271.Xr SSL_CTX_set_psk_client_callback 3 ,
1272.Xr SSL_CTX_set_quiet_shutdown 3 ,
1273.Xr SSL_CTX_set_session_cache_mode 3 ,
1274.Xr SSL_CTX_set_session_id_context 3 ,
1275.Xr SSL_CTX_set_ssl_version 3 ,
1276.Xr SSL_CTX_set_timeout 3 ,
1277.Xr SSL_CTX_set_tmp_dh_callback 3 ,
1278.Xr SSL_CTX_set_tmp_rsa_callback 3 ,
1279.Xr SSL_CTX_set_verify 3 ,
1280.Xr SSL_CTX_use_certificate 3 ,
1281.Xr SSL_CTX_use_psk_identity_hint 3 ,
1282.Xr SSL_do_handshake 3 ,
1283.Xr SSL_get_ciphers 3 ,
1284.Xr SSL_get_client_CA_list 3 ,
1285.Xr SSL_get_default_timeout 3 ,
1286.Xr SSL_get_error 3 ,
1287.Xr SSL_get_ex_data_X509_STORE_CTX_idx 3 ,
1288.Xr SSL_get_ex_new_index 3 ,
1289.Xr SSL_get_fd 3 ,
1290.Xr SSL_get_peer_cert_chain 3 ,
1291.Xr SSL_get_psk_identity 3 ,
1292.Xr SSL_get_rbio 3 ,
1293.Xr SSL_get_session 3 ,
1294.Xr SSL_get_SSL_CTX 3 ,
1295.Xr SSL_get_verify_result 3 ,
1296.Xr SSL_get_version 3 ,
1297.Xr SSL_library_init 3 ,
1298.Xr SSL_load_client_CA_file 3 ,
1299.Xr SSL_new 3 ,
1300.Xr SSL_pending 3 ,
1301.Xr SSL_read 3 ,
1302.Xr SSL_rstate_string 3 ,
1303.Xr SSL_SESSION_free 3 ,
1304.Xr SSL_SESSION_get_ex_new_index 3 ,
1305.Xr SSL_SESSION_get_time 3 ,
1306.Xr SSL_session_reused 3 ,
1307.Xr SSL_set_bio 3 ,
1308.Xr SSL_set_connect_state 3 ,
1309.Xr SSL_set_fd 3 ,
1310.Xr SSL_set_session 3 ,
1311.Xr SSL_set_shutdown 3 ,
1312.Xr SSL_shutdown 3 ,
1313.Xr SSL_state_string 3 ,
1314.Xr SSL_want 3 ,
1315.Xr SSL_write 3
1316.Sh HISTORY
1317The
1318.Nm
1319document appeared in OpenSSL 0.9.2.