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