summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbentley <>2014-10-12 09:33:04 +0000
committerbentley <>2014-10-12 09:33:04 +0000
commit82b7f378b6907ab315a6e50322d2a0a8794a0aa9 (patch)
treea5087bf8d016a6041c2b6822fbecfd8f6c5e70b1
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@
-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
-rw-r--r--src/lib/libssl/src/doc/ssl/BIO_f_ssl.3475
-rw-r--r--src/lib/libssl/src/doc/ssl/BIO_f_ssl.pod322
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CIPHER_get_name.3193
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CIPHER_get_name.pod122
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_COMP_add_compression_method.365
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_COMP_add_compression_method.pod70
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_add_extra_chain_cert.342
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_add_extra_chain_cert.pod43
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_add_session.387
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_add_session.pod74
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_ctrl.346
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_ctrl.pod35
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_flush_sessions.354
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_flush_sessions.pod49
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_free.344
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_free.pod41
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_get_ex_new_index.367
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_get_ex_new_index.pod54
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_get_verify_mode.370
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_get_verify_mode.pod52
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_load_verify_locations.3158
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_load_verify_locations.pod137
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_new.3108
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_new.pod93
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_sess_number.3101
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_sess_number.pod80
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_sess_set_cache_size.352
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_sess_set_cache_size.pod52
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_sess_set_get_cb.3156
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_sess_set_get_cb.pod89
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_sessions.331
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_sessions.pod34
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_cert_store.377
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_cert_store.pod58
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_cert_verify_callback.3109
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_cert_verify_callback.pod75
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_cipher_list.379
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_cipher_list.pod71
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_client_CA_list.3129
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_client_CA_list.pod94
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_client_cert_cb.3140
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_client_cert_cb.pod95
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_default_passwd_cb.392
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_default_passwd_cb.pod77
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_generate_session_id.3193
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_generate_session_id.pod152
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_info_callback.3164
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_info_callback.pod154
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_max_cert_list.3102
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_max_cert_list.pod78
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_mode.3123
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_mode.pod92
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_msg_callback.3132
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_msg_callback.pod101
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_options.3384
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_options.pod350
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_psk_client_callback.365
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_psk_client_callback.pod82
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_quiet_shutdown.3116
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_quiet_shutdown.pod64
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_session_cache_mode.3140
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_session_cache_mode.pod138
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_session_id_context.3102
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_session_id_context.pod84
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_ssl_version.378
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_ssl_version.pod61
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_timeout.362
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_timeout.pod60
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_tmp_dh_callback.3233
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_tmp_dh_callback.pod169
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_tmp_rsa_callback.3228
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_tmp_rsa_callback.pod168
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_verify.3412
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_verify.pod295
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_use_certificate.3333
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_use_certificate.pod180
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_use_psk_identity_hint.3107
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_use_psk_identity_hint.pod106
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_SESSION_free.376
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_SESSION_free.pod55
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_SESSION_get_ex_new_index.377
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_SESSION_get_ex_new_index.pod62
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_SESSION_get_time.391
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_SESSION_get_time.pod66
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_accept.3110
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_accept.pod76
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_alert_type_string.3190
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_alert_type_string.pod234
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_clear.389
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_clear.pod77
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_connect.399
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_connect.pod73
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_do_handshake.3110
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_do_handshake.pod75
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_free.359
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_free.pod46
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_SSL_CTX.325
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_SSL_CTX.pod26
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_ciphers.365
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_ciphers.pod42
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_client_CA_list.358
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_client_CA_list.pod53
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_current_cipher.349
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_current_cipher.pod43
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_default_timeout.333
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_default_timeout.pod41
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_error.3166
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_error.pod113
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_ex_data_X509_STORE_CTX_idx.362
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_ex_data_X509_STORE_CTX_idx.pod61
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_ex_new_index.373
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_ex_new_index.pod60
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_fd.343
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_fd.pod44
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_peer_cert_chain.344
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_peer_cert_chain.pod52
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_peer_certificate.350
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_peer_certificate.pod55
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_psk_identity.341
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_psk_identity.pod64
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_rbio.342
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_rbio.pod40
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_session.394
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_session.pod73
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_verify_result.346
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_verify_result.pod57
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_version.332
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_version.pod54
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_library_init.351
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_library_init.pod57
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_load_client_CA_file.350
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_load_client_CA_file.pod62
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_new.338
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_new.pod44
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_pending.341
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_pending.pod43
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_read.3190
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_read.pod124
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_rstate_string.352
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_rstate_string.pod60
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_session_reused.329
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_session_reused.pod46
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_set_bio.348
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_set_bio.pod34
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_set_connect_state.368
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_set_connect_state.pod56
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_set_fd.370
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_set_fd.pod54
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_set_session.365
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_set_session.pod57
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_set_shutdown.385
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_set_shutdown.pod73
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_set_verify_result.339
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_set_verify_result.pod38
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_shutdown.3201
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_shutdown.pod125
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_state_string.354
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_state_string.pod46
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_want.3100
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_want.pod78
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_write.3172
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_write.pod109
-rw-r--r--src/lib/libssl/src/doc/ssl/d2i_SSL_SESSION.3126
-rw-r--r--src/lib/libssl/src/doc/ssl/d2i_SSL_SESSION.pod80
-rw-r--r--src/lib/libssl/src/doc/ssl/ssl.31317
-rw-r--r--src/lib/libssl/src/doc/ssl/ssl.pod758
249 files changed, 19938 insertions, 7737 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.
diff --git a/src/lib/libssl/src/doc/ssl/BIO_f_ssl.3 b/src/lib/libssl/src/doc/ssl/BIO_f_ssl.3
new file mode 100644
index 0000000000..31c9963edb
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/BIO_f_ssl.pod b/src/lib/libssl/src/doc/ssl/BIO_f_ssl.pod
deleted file mode 100644
index dfd7833b13..0000000000
--- a/src/lib/libssl/src/doc/ssl/BIO_f_ssl.pod
+++ /dev/null
@@ -1,322 +0,0 @@
1=pod
2
3=head1 NAME
4
5BIO_f_ssl, BIO_set_ssl, BIO_get_ssl, BIO_set_ssl_mode,
6BIO_set_ssl_renegotiate_bytes, BIO_get_num_renegotiates,
7BIO_set_ssl_renegotiate_timeout, BIO_new_ssl, BIO_new_ssl_connect,
8BIO_new_buffer_ssl_connect, BIO_ssl_copy_session_id, BIO_ssl_shutdown - SSL BIO
9
10=head1 SYNOPSIS
11
12 #include <openssl/bio.h>
13 #include <openssl/ssl.h>
14
15 BIO_METHOD *BIO_f_ssl(void);
16
17 #define BIO_set_ssl(b,ssl,c) BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)ssl)
18 #define BIO_get_ssl(b,sslp) BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)sslp)
19 #define BIO_set_ssl_mode(b,client) BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL)
20 #define BIO_set_ssl_renegotiate_bytes(b,num) \
21 BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL);
22 #define BIO_set_ssl_renegotiate_timeout(b,seconds) \
23 BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL);
24 #define BIO_get_num_renegotiates(b) \
25 BIO_ctrl(b,BIO_C_SET_SSL_NUM_RENEGOTIATES,0,NULL);
26
27 BIO *BIO_new_ssl(SSL_CTX *ctx,int client);
28 BIO *BIO_new_ssl_connect(SSL_CTX *ctx);
29 BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx);
30 int BIO_ssl_copy_session_id(BIO *to,BIO *from);
31 void BIO_ssl_shutdown(BIO *bio);
32
33 #define BIO_do_handshake(b) BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL)
34
35=head1 DESCRIPTION
36
37BIO_f_ssl() returns the SSL BIO method. This is a filter BIO which
38is a wrapper round the OpenSSL SSL routines adding a BIO "flavour" to
39SSL I/O.
40
41I/O performed on an SSL BIO communicates using the SSL protocol with
42the SSLs read and write BIOs. If an SSL connection is not established
43then an attempt is made to establish one on the first I/O call.
44
45If a BIO is appended to an SSL BIO using BIO_push() it is automatically
46used as the SSL BIOs read and write BIOs.
47
48Calling BIO_reset() on an SSL BIO closes down any current SSL connection
49by calling SSL_shutdown(). BIO_reset() is then sent to the next BIO in
50the chain: this will typically disconnect the underlying transport.
51The SSL BIO is then reset to the initial accept or connect state.
52
53If the close flag is set when an SSL BIO is freed then the internal
54SSL structure is also freed using SSL_free().
55
56BIO_set_ssl() sets the internal SSL pointer of BIO B<b> to B<ssl> using
57the close flag B<c>.
58
59BIO_get_ssl() retrieves the SSL pointer of BIO B<b>, it can then be
60manipulated using the standard SSL library functions.
61
62BIO_set_ssl_mode() sets the SSL BIO mode to B<client>. If B<client>
63is 1 client mode is set. If B<client> is 0 server mode is set.
64
65BIO_set_ssl_renegotiate_bytes() sets the renegotiate byte count
66to B<num>. When set after every B<num> bytes of I/O (read and write)
67the SSL session is automatically renegotiated. B<num> must be at
68least 512 bytes.
69
70BIO_set_ssl_renegotiate_timeout() sets the renegotiate timeout to
71B<seconds>. When the renegotiate timeout elapses the session is
72automatically renegotiated.
73
74BIO_get_num_renegotiates() returns the total number of session
75renegotiations due to I/O or timeout.
76
77BIO_new_ssl() allocates an SSL BIO using SSL_CTX B<ctx> and using
78client mode if B<client> is non zero.
79
80BIO_new_ssl_connect() creates a new BIO chain consisting of an
81SSL BIO (using B<ctx>) followed by a connect BIO.
82
83BIO_new_buffer_ssl_connect() creates a new BIO chain consisting
84of a buffering BIO, an SSL BIO (using B<ctx>) and a connect
85BIO.
86
87BIO_ssl_copy_session_id() copies an SSL session id between
88BIO chains B<from> and B<to>. It does this by locating the
89SSL BIOs in each chain and calling SSL_copy_session_id() on
90the internal SSL pointer.
91
92BIO_ssl_shutdown() closes down an SSL connection on BIO
93chain B<bio>. It does this by locating the SSL BIO in the
94chain and calling SSL_shutdown() on its internal SSL
95pointer.
96
97BIO_do_handshake() attempts to complete an SSL handshake on the
98supplied BIO and establish the SSL connection. It returns 1
99if the connection was established successfully. A zero or negative
100value is returned if the connection could not be established, the
101call BIO_should_retry() should be used for non blocking connect BIOs
102to determine if the call should be retried. If an SSL connection has
103already been established this call has no effect.
104
105=head1 NOTES
106
107SSL BIOs are exceptional in that if the underlying transport
108is non blocking they can still request a retry in exceptional
109circumstances. Specifically this will happen if a session
110renegotiation takes place during a BIO_read() operation, one
111case where this happens is when SGC or step up occurs.
112
113In OpenSSL 0.9.6 and later the SSL flag SSL_AUTO_RETRY can be
114set to disable this behaviour. That is when this flag is set
115an SSL BIO using a blocking transport will never request a
116retry.
117
118Since unknown BIO_ctrl() operations are sent through filter
119BIOs the servers name and port can be set using BIO_set_host()
120on the BIO returned by BIO_new_ssl_connect() without having
121to locate the connect BIO first.
122
123Applications do not have to call BIO_do_handshake() but may wish
124to do so to separate the handshake process from other I/O
125processing.
126
127=head1 RETURN VALUES
128
129TBA
130
131=head1 EXAMPLE
132
133This SSL/TLS client example, attempts to retrieve a page from an
134SSL/TLS web server. The I/O routines are identical to those of the
135unencrypted example in L<BIO_s_connect(3)|BIO_s_connect(3)>.
136
137 BIO *sbio, *out;
138 int len;
139 char tmpbuf[1024];
140 SSL_CTX *ctx;
141 SSL *ssl;
142
143 ERR_load_crypto_strings();
144 ERR_load_SSL_strings();
145 OpenSSL_add_all_algorithms();
146
147 /* We would seed the PRNG here if the platform didn't
148 * do it automatically
149 */
150
151 ctx = SSL_CTX_new(SSLv23_client_method());
152
153 /* We'd normally set some stuff like the verify paths and
154 * mode here because as things stand this will connect to
155 * any server whose certificate is signed by any CA.
156 */
157
158 sbio = BIO_new_ssl_connect(ctx);
159
160 BIO_get_ssl(sbio, &ssl);
161
162 if(!ssl) {
163 fprintf(stderr, "Can't locate SSL pointer\n");
164 /* whatever ... */
165 }
166
167 /* Don't want any retries */
168 SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY);
169
170 /* We might want to do other things with ssl here */
171
172 BIO_set_conn_hostname(sbio, "localhost:https");
173
174 out = BIO_new_fp(stdout, BIO_NOCLOSE);
175 if(BIO_do_connect(sbio) <= 0) {
176 fprintf(stderr, "Error connecting to server\n");
177 ERR_print_errors_fp(stderr);
178 /* whatever ... */
179 }
180
181 if(BIO_do_handshake(sbio) <= 0) {
182 fprintf(stderr, "Error establishing SSL connection\n");
183 ERR_print_errors_fp(stderr);
184 /* whatever ... */
185 }
186
187 /* Could examine ssl here to get connection info */
188
189 BIO_puts(sbio, "GET / HTTP/1.0\n\n");
190 for(;;) {
191 len = BIO_read(sbio, tmpbuf, 1024);
192 if(len <= 0) break;
193 BIO_write(out, tmpbuf, len);
194 }
195 BIO_free_all(sbio);
196 BIO_free(out);
197
198Here is a simple server example. It makes use of a buffering
199BIO to allow lines to be read from the SSL BIO using BIO_gets.
200It creates a pseudo web page containing the actual request from
201a client and also echoes the request to standard output.
202
203 BIO *sbio, *bbio, *acpt, *out;
204 int len;
205 char tmpbuf[1024];
206 SSL_CTX *ctx;
207 SSL *ssl;
208
209 ERR_load_crypto_strings();
210 ERR_load_SSL_strings();
211 OpenSSL_add_all_algorithms();
212
213 /* Might seed PRNG here */
214
215 ctx = SSL_CTX_new(SSLv23_server_method());
216
217 if (!SSL_CTX_use_certificate_file(ctx,"server.pem",SSL_FILETYPE_PEM)
218 || !SSL_CTX_use_PrivateKey_file(ctx,"server.pem",SSL_FILETYPE_PEM)
219 || !SSL_CTX_check_private_key(ctx)) {
220
221 fprintf(stderr, "Error setting up SSL_CTX\n");
222 ERR_print_errors_fp(stderr);
223 return 0;
224 }
225
226 /* Might do other things here like setting verify locations and
227 * DH and/or RSA temporary key callbacks
228 */
229
230 /* New SSL BIO setup as server */
231 sbio=BIO_new_ssl(ctx,0);
232
233 BIO_get_ssl(sbio, &ssl);
234
235 if(!ssl) {
236 fprintf(stderr, "Can't locate SSL pointer\n");
237 /* whatever ... */
238 }
239
240 /* Don't want any retries */
241 SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY);
242
243 /* Create the buffering BIO */
244
245 bbio = BIO_new(BIO_f_buffer());
246
247 /* Add to chain */
248 sbio = BIO_push(bbio, sbio);
249
250 acpt=BIO_new_accept("4433");
251
252 /* By doing this when a new connection is established
253 * we automatically have sbio inserted into it. The
254 * BIO chain is now 'swallowed' by the accept BIO and
255 * will be freed when the accept BIO is freed.
256 */
257
258 BIO_set_accept_bios(acpt,sbio);
259
260 out = BIO_new_fp(stdout, BIO_NOCLOSE);
261
262 /* Setup accept BIO */
263 if(BIO_do_accept(acpt) <= 0) {
264 fprintf(stderr, "Error setting up accept BIO\n");
265 ERR_print_errors_fp(stderr);
266 return 0;
267 }
268
269 /* Now wait for incoming connection */
270 if(BIO_do_accept(acpt) <= 0) {
271 fprintf(stderr, "Error in connection\n");
272 ERR_print_errors_fp(stderr);
273 return 0;
274 }
275
276 /* We only want one connection so remove and free
277 * accept BIO
278 */
279
280 sbio = BIO_pop(acpt);
281
282 BIO_free_all(acpt);
283
284 if(BIO_do_handshake(sbio) <= 0) {
285 fprintf(stderr, "Error in SSL handshake\n");
286 ERR_print_errors_fp(stderr);
287 return 0;
288 }
289
290 BIO_puts(sbio, "HTTP/1.0 200 OK\r\nContent-type: text/plain\r\n\r\n");
291 BIO_puts(sbio, "\r\nConnection Established\r\nRequest headers:\r\n");
292 BIO_puts(sbio, "--------------------------------------------------\r\n");
293
294 for(;;) {
295 len = BIO_gets(sbio, tmpbuf, 1024);
296 if(len <= 0) break;
297 BIO_write(sbio, tmpbuf, len);
298 BIO_write(out, tmpbuf, len);
299 /* Look for blank line signifying end of headers*/
300 if((tmpbuf[0] == '\r') || (tmpbuf[0] == '\n')) break;
301 }
302
303 BIO_puts(sbio, "--------------------------------------------------\r\n");
304 BIO_puts(sbio, "\r\n");
305
306 /* Since there is a buffering BIO present we had better flush it */
307 BIO_flush(sbio);
308
309 BIO_free_all(sbio);
310
311=head1 BUGS
312
313In OpenSSL versions before 1.0.0 the BIO_pop() call was handled incorrectly,
314the I/O BIO reference count was incorrectly incremented (instead of
315decremented) and dissociated with the SSL BIO even if the SSL BIO was not
316explicitly being popped (e.g. a pop higher up the chain). Applications which
317included workarounds for this bug (e.g. freeing BIOs more than once) should
318be modified to handle this fix or they may free up an already freed BIO.
319
320=head1 SEE ALSO
321
322TBA
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CIPHER_get_name.3 b/src/lib/libssl/src/doc/ssl/SSL_CIPHER_get_name.3
new file mode 100644
index 0000000000..0c6cccd1cc
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CIPHER_get_name.pod b/src/lib/libssl/src/doc/ssl/SSL_CIPHER_get_name.pod
deleted file mode 100644
index 3ed016ee2c..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CIPHER_get_name.pod
+++ /dev/null
@@ -1,122 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CIPHER_get_name, SSL_CIPHER_get_bits, SSL_CIPHER_get_version,
6SSL_CIPHER_description - get SSL_CIPHER properties
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 const char *SSL_CIPHER_get_name(const SSL_CIPHER *cipher);
13 int SSL_CIPHER_get_bits(const SSL_CIPHER *cipher, int *alg_bits);
14 char *SSL_CIPHER_get_version(const SSL_CIPHER *cipher);
15 char *SSL_CIPHER_description(const SSL_CIPHER *cipher, char *buf, int size);
16
17=head1 DESCRIPTION
18
19SSL_CIPHER_get_name() returns a pointer to the name of B<cipher>. If the
20argument is the NULL pointer, a pointer to the constant value "NONE" is
21returned.
22
23SSL_CIPHER_get_bits() returns the number of secret bits used for B<cipher>. If
24B<alg_bits> is not NULL, it contains the number of bits processed by the
25chosen algorithm. If B<cipher> is NULL, 0 is returned.
26
27SSL_CIPHER_get_version() returns string which indicates the SSL/TLS protocol
28version that first defined the cipher.
29This is currently B<SSLv2> or B<TLSv1/SSLv3>.
30In some cases it should possibly return "TLSv1.2" but the function does not;
31use SSL_CIPHER_description() instead.
32If B<cipher> is NULL, "(NONE)" is returned.
33
34SSL_CIPHER_description() returns a textual description of the cipher used
35into the buffer B<buf> of length B<len> provided.
36If B<buf> is NULL, a buffer is allocated using asprintf(); that
37buffer should be freed up using the B<free> function.
38If B<len> is too small, or if B<buf> is NULL and the allocation fails, a
39pointer to the string "Buffer too small" is returned.
40
41=head1 NOTES
42
43The number of bits processed can be different from the secret bits. An
44export cipher like e.g. EXP-RC4-MD5 has only 40 secret bits. The algorithm
45does use the full 128 bits (which would be returned for B<alg_bits>), of
46which however 88bits are fixed. The search space is hence only 40 bits.
47
48The string returned by SSL_CIPHER_description() in case of success consists
49of cleartext information separated by one or more blanks in the following
50sequence:
51
52=over 4
53
54=item <ciphername>
55
56Textual representation of the cipher name.
57
58=item <protocol version>
59
60Protocol version: B<SSLv2>, B<SSLv3>, B<TLSv1.2>. The TLSv1.0 ciphers are
61flagged with SSLv3. No new ciphers were added by TLSv1.1.
62
63=item Kx=<key exchange>
64
65Key exchange method: B<RSA> (for export ciphers as B<RSA(512)> or
66B<RSA(1024)>), B<DH> (for export ciphers as B<DH(512)> or B<DH(1024)>),
67B<DH/RSA>, B<DH/DSS>, B<Fortezza>.
68
69=item Au=<authentication>
70
71Authentication method: B<RSA>, B<DSS>, B<DH>, B<None>. None is the
72representation of anonymous ciphers.
73
74=item Enc=<symmetric encryption method>
75
76Encryption method with number of secret bits: B<DES(40)>, B<DES(56)>,
77B<3DES(168)>, B<RC4(40)>, B<RC4(56)>, B<RC4(64)>, B<RC4(128)>,
78B<RC2(40)>, B<RC2(56)>, B<RC2(128)>, B<IDEA(128)>, B<Fortezza>, B<None>.
79
80=item Mac=<message authentication code>
81
82Message digest: B<MD5>, B<SHA1>.
83
84=item <export flag>
85
86If the cipher is flagged exportable with respect to old US crypto
87regulations, the word "B<export>" is printed.
88
89=back
90
91=head1 EXAMPLES
92
93Some examples for the output of SSL_CIPHER_description():
94
95 EDH-RSA-DES-CBC3-SHA SSLv3 Kx=DH Au=RSA Enc=3DES(168) Mac=SHA1
96 EDH-DSS-DES-CBC3-SHA SSLv3 Kx=DH Au=DSS Enc=3DES(168) Mac=SHA1
97 RC4-MD5 SSLv3 Kx=RSA Au=RSA Enc=RC4(128) Mac=MD5
98 EXP-RC4-MD5 SSLv3 Kx=RSA(512) Au=RSA Enc=RC4(40) Mac=MD5 export
99
100A complete list can be retrieved by invoking the following command:
101
102 openssl ciphers -v ALL
103
104=head1 BUGS
105
106If SSL_CIPHER_description() is called with B<cipher> being NULL, the
107library crashes.
108
109If SSL_CIPHER_description() cannot handle a built-in cipher, the according
110description of the cipher property is B<unknown>. This case should not
111occur.
112
113=head1 RETURN VALUES
114
115See DESCRIPTION
116
117=head1 SEE ALSO
118
119L<ssl(3)|ssl(3)>, L<SSL_get_current_cipher(3)|SSL_get_current_cipher(3)>,
120L<SSL_get_ciphers(3)|SSL_get_ciphers(3)>, L<ciphers(1)|ciphers(1)>
121
122=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_COMP_add_compression_method.3 b/src/lib/libssl/src/doc/ssl/SSL_COMP_add_compression_method.3
new file mode 100644
index 0000000000..c23d676930
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_COMP_add_compression_method.pod b/src/lib/libssl/src/doc/ssl/SSL_COMP_add_compression_method.pod
deleted file mode 100644
index 80175a3c17..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_COMP_add_compression_method.pod
+++ /dev/null
@@ -1,70 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_COMP_add_compression_method - handle SSL/TLS integrated compression methods
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 int SSL_COMP_add_compression_method(int id, COMP_METHOD *cm);
12
13=head1 DESCRIPTION
14
15SSL_COMP_add_compression_method() adds the compression method B<cm> with
16the identifier B<id> to the list of available compression methods. This
17list is globally maintained for all SSL operations within this application.
18It cannot be set for specific SSL_CTX or SSL objects.
19
20=head1 NOTES
21
22The TLS standard (or SSLv3) allows the integration of compression methods
23into the communication. The TLS RFC does however not specify compression
24methods or their corresponding identifiers, so there is currently no compatible
25way to integrate compression with unknown peers. It is therefore currently not
26recommended to integrate compression into applications. Applications for
27non-public use may agree on certain compression methods. Using different
28compression methods with the same identifier will lead to connection failure.
29
30An OpenSSL client speaking a protocol that allows compression (SSLv3, TLSv1)
31will unconditionally send the list of all compression methods enabled with
32SSL_COMP_add_compression_method() to the server during the handshake.
33Unlike the mechanisms to set a cipher list, there is no method available to
34restrict the list of compression method on a per connection basis.
35
36An OpenSSL server will match the identifiers listed by a client against
37its own compression methods and will unconditionally activate compression
38when a matching identifier is found. There is no way to restrict the list
39of compression methods supported on a per connection basis.
40
41The OpenSSL library has the compression methods B<COMP_rle()> and (when
42especially enabled during compilation) B<COMP_zlib()> available.
43
44=head1 WARNINGS
45
46Once the identities of the compression methods for the TLS protocol have
47been standardized, the compression API will most likely be changed. Using
48it in the current state is not recommended.
49
50=head1 RETURN VALUES
51
52SSL_COMP_add_compression_method() may return the following values:
53
54=over 4
55
56=item C<0>
57
58The operation succeeded.
59
60=item C<1>
61
62The operation failed. Check the error queue to find out the reason.
63
64=back
65
66=head1 SEE ALSO
67
68L<ssl(3)|ssl(3)>
69
70=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_add_extra_chain_cert.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_add_extra_chain_cert.3
new file mode 100644
index 0000000000..2664c67a5a
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_add_extra_chain_cert.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_add_extra_chain_cert.pod
deleted file mode 100644
index df5441caec..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_add_extra_chain_cert.pod
+++ /dev/null
@@ -1,43 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_add_extra_chain_cert - add certificate to chain
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 long SSL_CTX_add_extra_chain_cert(SSL_CTX ctx, X509 *x509)
12
13=head1 DESCRIPTION
14
15SSL_CTX_add_extra_chain_cert() adds the certificate B<x509> to the certificate
16chain presented together with the certificate. Several certificates
17can be added one after the other.
18
19=head1 NOTES
20
21When constructing the certificate chain, the chain will be formed from
22these certificates explicitly specified. If no chain is specified,
23the library will try to complete the chain from the available CA
24certificates in the trusted CA storage, see
25L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>.
26
27The B<x509> certificate provided to SSL_CTX_add_extra_chain_cert() will be
28freed by the library when the B<SSL_CTX> is destroyed. An application B<should
29not> free the B<x509> object.
30
31=head1 RETURN VALUES
32
33SSL_CTX_add_extra_chain_cert() returns 1 on success. Check out the
34error stack to find out the reason for failure otherwise.
35
36=head1 SEE ALSO
37
38L<ssl(3)|ssl(3)>,
39L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>,
40L<SSL_CTX_set_client_cert_cb(3)|SSL_CTX_set_client_cert_cb(3)>,
41L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>
42
43=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_add_session.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_add_session.3
new file mode 100644
index 0000000000..74b4481496
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_add_session.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_add_session.pod
deleted file mode 100644
index 7f1a1d5ee6..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_add_session.pod
+++ /dev/null
@@ -1,74 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_add_session, SSL_add_session, SSL_CTX_remove_session,
6SSL_remove_session - manipulate session cache
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 int SSL_CTX_add_session(SSL_CTX *ctx, SSL_SESSION *c);
13 int SSL_add_session(SSL_CTX *ctx, SSL_SESSION *c);
14
15 int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c);
16 int SSL_remove_session(SSL_CTX *ctx, SSL_SESSION *c);
17
18=head1 DESCRIPTION
19
20SSL_CTX_add_session() adds the session B<c> to the context B<ctx>. The
21reference count for session B<c> is incremented by 1. If a session with
22the same session id already exists, the old session is removed by calling
23L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>.
24
25SSL_CTX_remove_session() removes the session B<c> from the context B<ctx>.
26L<SSL_SESSION_free(3)|SSL_SESSION_free(3)> is called once for B<c>.
27
28SSL_add_session() and SSL_remove_session() are synonyms for their
29SSL_CTX_*() counterparts.
30
31=head1 NOTES
32
33When adding a new session to the internal session cache, it is examined
34whether a session with the same session id already exists. In this case
35it is assumed that both sessions are identical. If the same session is
36stored in a different SSL_SESSION object, The old session is
37removed and replaced by the new session. If the session is actually
38identical (the SSL_SESSION object is identical), SSL_CTX_add_session()
39is a no-op, and the return value is 0.
40
41If a server SSL_CTX is configured with the SSL_SESS_CACHE_NO_INTERNAL_STORE
42flag then the internal cache will not be populated automatically by new
43sessions negotiated by the SSL/TLS implementation, even though the internal
44cache will be searched automatically for session-resume requests (the
45latter can be suppressed by SSL_SESS_CACHE_NO_INTERNAL_LOOKUP). So the
46application can use SSL_CTX_add_session() directly to have full control
47over the sessions that can be resumed if desired.
48
49
50=head1 RETURN VALUES
51
52The following values are returned by all functions:
53
54=over 4
55
56=item C<0>
57
58 The operation failed. In case of the add operation, it was tried to add
59 the same (identical) session twice. In case of the remove operation, the
60 session was not found in the cache.
61
62=item C<1>
63
64 The operation succeeded.
65
66=back
67
68=head1 SEE ALSO
69
70L<ssl(3)|ssl(3)>,
71L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>,
72L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>
73
74=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_ctrl.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_ctrl.3
new file mode 100644
index 0000000000..d0a4ffd554
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_ctrl.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_ctrl.pod
deleted file mode 100644
index 8133689940..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_ctrl.pod
+++ /dev/null
@@ -1,35 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_ctrl, SSL_CTX_callback_ctrl, SSL_ctrl, SSL_callback_ctrl - internal
6handling functions for SSL_CTX and SSL objects
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 long SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg);
13 long SSL_CTX_callback_ctrl(SSL_CTX *, int cmd, void (*fp)());
14
15 long SSL_ctrl(SSL *ssl, int cmd, long larg, void *parg);
16 long SSL_callback_ctrl(SSL *, int cmd, void (*fp)());
17
18=head1 DESCRIPTION
19
20The SSL_*_ctrl() family of functions is used to manipulate settings of
21the SSL_CTX and SSL objects. Depending on the command B<cmd> the arguments
22B<larg>, B<parg>, or B<fp> are evaluated. These functions should never
23be called directly. All functionalities needed are made available via
24other functions or macros.
25
26=head1 RETURN VALUES
27
28The return values of the SSL*_ctrl() functions depend on the command
29supplied via the B<cmd> parameter.
30
31=head1 SEE ALSO
32
33L<ssl(3)|ssl(3)>
34
35=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_flush_sessions.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_flush_sessions.3
new file mode 100644
index 0000000000..6431008c4f
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_flush_sessions.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_flush_sessions.pod
deleted file mode 100644
index 8fb0f1dbaf..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_flush_sessions.pod
+++ /dev/null
@@ -1,49 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_flush_sessions, SSL_flush_sessions - remove expired sessions
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 void SSL_CTX_flush_sessions(SSL_CTX *ctx, long tm);
12 void SSL_flush_sessions(SSL_CTX *ctx, long tm);
13
14=head1 DESCRIPTION
15
16SSL_CTX_flush_sessions() causes a run through the session cache of
17B<ctx> to remove sessions expired at time B<tm>.
18
19SSL_flush_sessions() is a synonym for SSL_CTX_flush_sessions().
20
21=head1 NOTES
22
23If enabled, the internal session cache will collect all sessions established
24up to the specified maximum number (see SSL_CTX_sess_set_cache_size()).
25As sessions will not be reused ones they are expired, they should be
26removed from the cache to save resources. This can either be done
27automatically whenever 255 new sessions were established (see
28L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>)
29or manually by calling SSL_CTX_flush_sessions().
30
31The parameter B<tm> specifies the time which should be used for the
32expiration test, in most cases the actual time given by time(0)
33will be used.
34
35SSL_CTX_flush_sessions() will only check sessions stored in the internal
36cache. When a session is found and removed, the remove_session_cb is however
37called to synchronize with the external cache (see
38L<SSL_CTX_sess_set_get_cb(3)|SSL_CTX_sess_set_get_cb(3)>).
39
40=head1 RETURN VALUES
41
42=head1 SEE ALSO
43
44L<ssl(3)|ssl(3)>,
45L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>,
46L<SSL_CTX_set_timeout(3)|SSL_CTX_set_timeout(3)>,
47L<SSL_CTX_sess_set_get_cb(3)|SSL_CTX_sess_set_get_cb(3)>
48
49=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_free.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_free.3
new file mode 100644
index 0000000000..9cf5934303
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_free.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_free.pod
deleted file mode 100644
index 51d8676968..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_free.pod
+++ /dev/null
@@ -1,41 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_free - free an allocated SSL_CTX object
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 void SSL_CTX_free(SSL_CTX *ctx);
12
13=head1 DESCRIPTION
14
15SSL_CTX_free() decrements the reference count of B<ctx>, and removes the
16SSL_CTX object pointed to by B<ctx> and frees up the allocated memory if the
17the reference count has reached 0.
18
19It also calls the free()ing procedures for indirectly affected items, if
20applicable: the session cache, the list of ciphers, the list of Client CAs,
21the certificates and keys.
22
23=head1 WARNINGS
24
25If a session-remove callback is set (SSL_CTX_sess_set_remove_cb()), this
26callback will be called for each session being freed from B<ctx>'s
27session cache. This implies, that all corresponding sessions from an
28external session cache are removed as well. If this is not desired, the user
29should explicitly unset the callback by calling
30SSL_CTX_sess_set_remove_cb(B<ctx>, NULL) prior to calling SSL_CTX_free().
31
32=head1 RETURN VALUES
33
34SSL_CTX_free() does not provide diagnostic information.
35
36=head1 SEE ALSO
37
38L<SSL_CTX_new(3)|SSL_CTX_new(3)>, L<ssl(3)|ssl(3)>,
39L<SSL_CTX_sess_set_get_cb(3)|SSL_CTX_sess_set_get_cb(3)>
40
41=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_get_ex_new_index.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_get_ex_new_index.3
new file mode 100644
index 0000000000..593f39c24c
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_get_ex_new_index.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_get_ex_new_index.pod
deleted file mode 100644
index 5a03844114..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_get_ex_new_index.pod
+++ /dev/null
@@ -1,54 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_get_ex_new_index, SSL_CTX_set_ex_data, SSL_CTX_get_ex_data - internal
6application specific data functions
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 int SSL_CTX_get_ex_new_index(long argl, void *argp,
13 CRYPTO_EX_new *new_func,
14 CRYPTO_EX_dup *dup_func,
15 CRYPTO_EX_free *free_func);
16
17 int SSL_CTX_set_ex_data(SSL_CTX *ctx, int idx, void *arg);
18
19 void *SSL_CTX_get_ex_data(const SSL_CTX *ctx, int idx);
20
21 typedef int new_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
22 int idx, long argl, void *argp);
23 typedef void free_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
24 int idx, long argl, void *argp);
25 typedef int dup_func(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
26 int idx, long argl, void *argp);
27
28=head1 DESCRIPTION
29
30Several OpenSSL structures can have application specific data attached to them.
31These functions are used internally by OpenSSL to manipulate application
32specific data attached to a specific structure.
33
34SSL_CTX_get_ex_new_index() is used to register a new index for application
35specific data.
36
37SSL_CTX_set_ex_data() is used to store application data at B<arg> for B<idx>
38into the B<ctx> object.
39
40SSL_CTX_get_ex_data() is used to retrieve the information for B<idx> from
41B<ctx>.
42
43A detailed description for the B<*_get_ex_new_index()> functionality
44can be found in L<RSA_get_ex_new_index(3)|RSA_get_ex_new_index(3)>.
45The B<*_get_ex_data()> and B<*_set_ex_data()> functionality is described in
46L<CRYPTO_set_ex_data(3)|CRYPTO_set_ex_data(3)>.
47
48=head1 SEE ALSO
49
50L<ssl(3)|ssl(3)>,
51L<RSA_get_ex_new_index(3)|RSA_get_ex_new_index(3)>,
52L<CRYPTO_set_ex_data(3)|CRYPTO_set_ex_data(3)>
53
54=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_get_verify_mode.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_get_verify_mode.3
new file mode 100644
index 0000000000..4139229d7b
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_get_verify_mode.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_get_verify_mode.pod
deleted file mode 100644
index d0201bf263..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_get_verify_mode.pod
+++ /dev/null
@@ -1,52 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_get_verify_mode, SSL_get_verify_mode, SSL_CTX_get_verify_depth,
6SSL_get_verify_depth, SSL_get_verify_callback, SSL_CTX_get_verify_callback -
7get currently set verification parameters
8
9=head1 SYNOPSIS
10
11 #include <openssl/ssl.h>
12
13 int SSL_CTX_get_verify_mode(const SSL_CTX *ctx);
14 int SSL_get_verify_mode(const SSL *ssl);
15 int SSL_CTX_get_verify_depth(const SSL_CTX *ctx);
16 int SSL_get_verify_depth(const SSL *ssl);
17 int (*SSL_CTX_get_verify_callback(const SSL_CTX *ctx))(int, X509_STORE_CTX *);
18 int (*SSL_get_verify_callback(const SSL *ssl))(int, X509_STORE_CTX *);
19
20=head1 DESCRIPTION
21
22SSL_CTX_get_verify_mode() returns the verification mode currently set in
23B<ctx>.
24
25SSL_get_verify_mode() returns the verification mode currently set in
26B<ssl>.
27
28SSL_CTX_get_verify_depth() returns the verification depth limit currently set
29in B<ctx>. If no limit has been explicitly set, -1 is returned and the
30default value will be used.
31
32SSL_get_verify_depth() returns the verification depth limit currently set
33in B<ssl>. If no limit has been explicitly set, -1 is returned and the
34default value will be used.
35
36SSL_CTX_get_verify_callback() returns a function pointer to the verification
37callback currently set in B<ctx>. If no callback was explicitly set, the
38NULL pointer is returned and the default callback will be used.
39
40SSL_get_verify_callback() returns a function pointer to the verification
41callback currently set in B<ssl>. If no callback was explicitly set, the
42NULL pointer is returned and the default callback will be used.
43
44=head1 RETURN VALUES
45
46See DESCRIPTION
47
48=head1 SEE ALSO
49
50L<ssl(3)|ssl(3)>, L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>
51
52=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_load_verify_locations.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_load_verify_locations.3
new file mode 100644
index 0000000000..1e494032f4
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_load_verify_locations.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_load_verify_locations.pod
deleted file mode 100644
index cd78dd285f..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_load_verify_locations.pod
+++ /dev/null
@@ -1,137 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_load_verify_locations - set default locations for trusted CA
6certificates
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
13 const char *CApath);
14
15=head1 DESCRIPTION
16
17SSL_CTX_load_verify_locations() specifies the locations for B<ctx>, at
18which CA certificates for verification purposes are located. The certificates
19available via B<CAfile> and B<CApath> are trusted.
20
21=head1 NOTES
22
23If B<CAfile> is not NULL, it points to a file of CA certificates in PEM
24format. The file can contain several CA certificates identified by
25
26 -----BEGIN CERTIFICATE-----
27 ... (CA certificate in base64 encoding) ...
28 -----END CERTIFICATE-----
29
30sequences. Before, between, and after the certificates text is allowed
31which can be used e.g. for descriptions of the certificates.
32
33The B<CAfile> is processed on execution of the SSL_CTX_load_verify_locations()
34function.
35
36If B<CApath> is not NULL, it points to a directory containing CA certificates
37in PEM format. The files each contain one CA certificate. The files are
38looked up by the CA subject name hash value, which must hence be available.
39If more than one CA certificate with the same name hash value exist, the
40extension must be different (e.g. 9d66eef0.0, 9d66eef0.1 etc). The search
41is performed in the ordering of the extension number, regardless of other
42properties of the certificates.
43
44The certificates in B<CApath> are only looked up when required, e.g. when
45building the certificate chain or when actually performing the verification
46of a peer certificate.
47
48When looking up CA certificates, the OpenSSL library will first search the
49certificates in B<CAfile>, then those in B<CApath>. Certificate matching
50is done based on the subject name, the key identifier (if present), and the
51serial number as taken from the certificate to be verified. If these data
52do not match, the next certificate will be tried. If a first certificate
53matching the parameters is found, the verification process will be performed;
54no other certificates for the same parameters will be searched in case of
55failure.
56
57In server mode, when requesting a client certificate, the server must send
58the list of CAs of which it will accept client certificates. This list
59is not influenced by the contents of B<CAfile> or B<CApath> and must
60explicitly be set using the
61L<SSL_CTX_set_client_CA_list(3)|SSL_CTX_set_client_CA_list(3)>
62family of functions.
63
64When building its own certificate chain, an OpenSSL client/server will
65try to fill in missing certificates from B<CAfile>/B<CApath>, if the
66certificate chain was not explicitly specified (see
67L<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)>,
68L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>.
69
70=head1 WARNINGS
71
72If several CA certificates matching the name, key identifier, and serial
73number condition are available, only the first one will be examined. This
74may lead to unexpected results if the same CA certificate is available
75with different expiration dates. If a "certificate expired" verification
76error occurs, no other certificate will be searched. Make sure to not
77have expired certificates mixed with valid ones.
78
79=head1 EXAMPLES
80
81Generate a CA certificate file with descriptive text from the CA certificates
82ca1.pem ca2.pem ca3.pem:
83
84 #!/bin/sh
85 rm CAfile.pem
86 for i in ca1.pem ca2.pem ca3.pem ; do
87 openssl x509 -in $i -text >> CAfile.pem
88 done
89
90Prepare the directory /some/where/certs containing several CA certificates
91for use as B<CApath>:
92
93 cd /some/where/certs
94 rm -f *.[0-9]* *.r[0-9]*
95 for c in *.pem; do
96 [ "$c" = "*.pem" ] && continue
97 hash=$(openssl x509 -noout -hash -in "$c")
98 if egrep -q -- '-BEGIN( X509 | TRUSTED | )CERTIFICATE-' "$c"; then
99 suf=0
100 while [ -e $hash.$suf ]; do suf=$(( $suf + 1 )); done
101 ln -s "$c" $hash.$suf
102 fi
103 if egrep -q -- '-BEGIN X509 CRL-' "$c"; then
104 suf=0
105 while [ -e $hash.r$suf ]; do suf=$(( $suf + 1 )); done
106 ln -s "$c" $hash.r$suf
107 fi
108 done
109
110=head1 RETURN VALUES
111
112The following return values can occur:
113
114=over 4
115
116=item C<0>
117
118The operation failed because B<CAfile> and B<CApath> are NULL or the
119processing at one of the locations specified failed. Check the error
120stack to find out the reason.
121
122=item C<1>
123
124The operation succeeded.
125
126=back
127
128=head1 SEE ALSO
129
130L<ssl(3)|ssl(3)>,
131L<SSL_CTX_set_client_CA_list(3)|SSL_CTX_set_client_CA_list(3)>,
132L<SSL_get_client_CA_list(3)|SSL_get_client_CA_list(3)>,
133L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>,
134L<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)>,
135L<SSL_CTX_set_cert_store(3)|SSL_CTX_set_cert_store(3)>
136
137=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_new.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_new.3
new file mode 100644
index 0000000000..b798d10a9e
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_new.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_new.pod
deleted file mode 100644
index 023be38c0a..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_new.pod
+++ /dev/null
@@ -1,93 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_new, SSLv3_method, SSLv3_server_method, SSLv3_client_method,
6TLSv1_method, TLSv1_server_method, TLSv1_client_method,
7TLSv1_1_method, TLSv1_1_server_method, TLSv1_1_client_method, SSLv23_method,
8SSLv23_server_method, SSLv23_client_method - create a new SSL_CTX object as framework for TLS/SSL enabled functions
9
10=head1 SYNOPSIS
11
12 #include <openssl/ssl.h>
13
14 SSL_CTX *SSL_CTX_new(const SSL_METHOD *method);
15
16=head1 DESCRIPTION
17
18SSL_CTX_new() creates a new B<SSL_CTX> object as framework to establish
19TLS/SSL enabled connections.
20
21=head1 NOTES
22
23The SSL_CTX object uses B<method> as connection method. The methods exist
24in a generic type (for client and server use), a server only type, and a
25client only type. B<method> can be of the following types:
26
27=over 4
28
29=item SSLv3_method(void), SSLv3_server_method(void), SSLv3_client_method(void)
30
31A TLS/SSL connection established with these methods will only understand the
32SSLv3 protocol. A client will send out SSLv3 client hello messages
33and will indicate that it only understands SSLv3. A server will only understand
34SSLv3 client hello messages. This especially means, that it will
35not understand SSLv2 client hello messages which are widely used for
36compatibility reasons, see SSLv23_*_method().
37
38=item TLSv1_method(void), TLSv1_server_method(void), TLSv1_client_method(void)
39
40A TLS/SSL connection established with these methods will only understand the
41TLSv1 protocol. A client will send out TLSv1 client hello messages
42and will indicate that it only understands TLSv1. A server will only understand
43TLSv1 client hello messages. This especially means, that it will
44not understand SSLv2 client hello messages which are widely used for
45compatibility reasons, see SSLv23_*_method(). It will also not understand
46SSLv3 client hello messages.
47
48=item SSLv23_method(void), SSLv23_server_method(void), SSLv23_client_method(void)
49
50A TLS/SSL connection established with these methods may understand the
51SSLv3, TLSv1, TLSv1.1 and TLSv1.2 protocols.
52
53A client will send out TLSv1 client hello messages including extensions and
54will indicate that it also understands TLSv1.1, TLSv1.2 and permits a
55fallback to SSLv3. A server will support SSLv3, TLSv1, TLSv1.1 and TLSv1.2
56protocols. This is the best choice when compatibility is a concern.
57
58=back
59
60The list of protocols available can later be limited using the
61SSL_OP_NO_SSLv3, SSL_OP_NO_TLSv1, SSL_OP_NO_TLSv1_1 and SSL_OP_NO_TLSv1_2
62options of the SSL_CTX_set_options() or SSL_set_options() functions.
63Using these options it is possible to choose e.g. SSLv23_server_method() and
64be able to negotiate with all possible clients, but to only allow newer
65protocols like TLSv1, TLSv1.1 or TLS v1.2.
66
67SSL_CTX_new() initializes the list of ciphers, the session cache setting,
68the callbacks, the keys and certificates and the options to its default
69values.
70
71=head1 RETURN VALUES
72
73The following return values can occur:
74
75=over 4
76
77=item NULL
78
79The creation of a new SSL_CTX object failed. Check the error stack to
80find out the reason.
81
82=item Pointer to an SSL_CTX object
83
84The return value points to an allocated SSL_CTX object.
85
86=back
87
88=head1 SEE ALSO
89
90L<SSL_CTX_free(3)|SSL_CTX_free(3)>, L<SSL_accept(3)|SSL_accept(3)>,
91L<ssl(3)|ssl(3)>, L<SSL_set_connect_state(3)|SSL_set_connect_state(3)>
92
93=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_sess_number.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_sess_number.3
new file mode 100644
index 0000000000..862576ca50
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_sess_number.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_sess_number.pod
deleted file mode 100644
index f7192eb761..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_sess_number.pod
+++ /dev/null
@@ -1,80 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_sess_number, SSL_CTX_sess_connect, SSL_CTX_sess_connect_good,
6SSL_CTX_sess_connect_renegotiate, SSL_CTX_sess_accept,
7SSL_CTX_sess_accept_good, SSL_CTX_sess_accept_renegotiate, SSL_CTX_sess_hits,
8SSL_CTX_sess_cb_hits, SSL_CTX_sess_misses, SSL_CTX_sess_timeouts,
9SSL_CTX_sess_cache_full - obtain session cache statistics
10
11=head1 SYNOPSIS
12
13 #include <openssl/ssl.h>
14
15 long SSL_CTX_sess_number(SSL_CTX *ctx);
16 long SSL_CTX_sess_connect(SSL_CTX *ctx);
17 long SSL_CTX_sess_connect_good(SSL_CTX *ctx);
18 long SSL_CTX_sess_connect_renegotiate(SSL_CTX *ctx);
19 long SSL_CTX_sess_accept(SSL_CTX *ctx);
20 long SSL_CTX_sess_accept_good(SSL_CTX *ctx);
21 long SSL_CTX_sess_accept_renegotiate(SSL_CTX *ctx);
22 long SSL_CTX_sess_hits(SSL_CTX *ctx);
23 long SSL_CTX_sess_cb_hits(SSL_CTX *ctx);
24 long SSL_CTX_sess_misses(SSL_CTX *ctx);
25 long SSL_CTX_sess_timeouts(SSL_CTX *ctx);
26 long SSL_CTX_sess_cache_full(SSL_CTX *ctx);
27
28=head1 DESCRIPTION
29
30SSL_CTX_sess_number() returns the current number of sessions in the internal
31session cache.
32
33SSL_CTX_sess_connect() returns the number of started SSL/TLS handshakes in
34client mode.
35
36SSL_CTX_sess_connect_good() returns the number of successfully established
37SSL/TLS sessions in client mode.
38
39SSL_CTX_sess_connect_renegotiate() returns the number of start renegotiations
40in client mode.
41
42SSL_CTX_sess_accept() returns the number of started SSL/TLS handshakes in
43server mode.
44
45SSL_CTX_sess_accept_good() returns the number of successfully established
46SSL/TLS sessions in server mode.
47
48SSL_CTX_sess_accept_renegotiate() returns the number of start renegotiations
49in server mode.
50
51SSL_CTX_sess_hits() returns the number of successfully reused sessions.
52In client mode a session set with L<SSL_set_session(3)|SSL_set_session(3)>
53successfully reused is counted as a hit. In server mode a session successfully
54retrieved from internal or external cache is counted as a hit.
55
56SSL_CTX_sess_cb_hits() returns the number of successfully retrieved sessions
57from the external session cache in server mode.
58
59SSL_CTX_sess_misses() returns the number of sessions proposed by clients
60that were not found in the internal session cache in server mode.
61
62SSL_CTX_sess_timeouts() returns the number of sessions proposed by clients
63and either found in the internal or external session cache in server mode,
64 but that were invalid due to timeout. These sessions are not included in
65the SSL_CTX_sess_hits() count.
66
67SSL_CTX_sess_cache_full() returns the number of sessions that were removed
68because the maximum session cache size was exceeded.
69
70=head1 RETURN VALUES
71
72The functions return the values indicated in the DESCRIPTION section.
73
74=head1 SEE ALSO
75
76L<ssl(3)|ssl(3)>, L<SSL_set_session(3)|SSL_set_session(3)>,
77L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>
78L<SSL_CTX_sess_set_cache_size(3)|SSL_CTX_sess_set_cache_size(3)>
79
80=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_sess_set_cache_size.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_sess_set_cache_size.3
new file mode 100644
index 0000000000..ad434e8496
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_sess_set_cache_size.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_sess_set_cache_size.pod
deleted file mode 100644
index a8d1bd5e3f..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_sess_set_cache_size.pod
+++ /dev/null
@@ -1,52 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_sess_set_cache_size, SSL_CTX_sess_get_cache_size - manipulate session
6cache size
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 long SSL_CTX_sess_set_cache_size(SSL_CTX *ctx, long t);
13 long SSL_CTX_sess_get_cache_size(SSL_CTX *ctx);
14
15=head1 DESCRIPTION
16
17SSL_CTX_sess_set_cache_size() sets the size of the internal session cache
18of context B<ctx> to B<t>.
19
20SSL_CTX_sess_get_cache_size() returns the currently valid session cache size.
21
22=head1 NOTES
23
24The internal session cache size is SSL_SESSION_CACHE_MAX_SIZE_DEFAULT,
25currently 1024*20, so that up to 20000 sessions can be held. This size
26can be modified using the SSL_CTX_sess_set_cache_size() call. A special
27case is the size 0, which is used for unlimited size.
28
29When the maximum number of sessions is reached, no more new sessions are
30added to the cache. New space may be added by calling
31L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)> to remove
32expired sessions.
33
34If the size of the session cache is reduced and more sessions are already
35in the session cache, old session will be removed at the next time a
36session shall be added. This removal is not synchronized with the
37expiration of sessions.
38
39=head1 RETURN VALUES
40
41SSL_CTX_sess_set_cache_size() returns the previously valid size.
42
43SSL_CTX_sess_get_cache_size() returns the currently valid size.
44
45=head1 SEE ALSO
46
47L<ssl(3)|ssl(3)>,
48L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>,
49L<SSL_CTX_sess_number(3)|SSL_CTX_sess_number(3)>,
50L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)>
51
52=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_sess_set_get_cb.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_sess_set_get_cb.3
new file mode 100644
index 0000000000..d5c506cec8
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_sess_set_get_cb.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_sess_set_get_cb.pod
deleted file mode 100644
index d39c088e7c..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_sess_set_get_cb.pod
+++ /dev/null
@@ -1,89 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_sess_set_new_cb, SSL_CTX_sess_set_remove_cb, SSL_CTX_sess_set_get_cb,
6SSL_CTX_sess_get_new_cb, SSL_CTX_sess_get_remove_cb, SSL_CTX_sess_get_get_cb -
7provide callback functions for server side external session caching
8
9=head1 SYNOPSIS
10
11 #include <openssl/ssl.h>
12
13 void SSL_CTX_sess_set_new_cb(SSL_CTX *ctx,
14 int (*new_session_cb)(SSL *, SSL_SESSION *));
15 void SSL_CTX_sess_set_remove_cb(SSL_CTX *ctx,
16 void (*remove_session_cb)(SSL_CTX *ctx, SSL_SESSION *));
17 void SSL_CTX_sess_set_get_cb(SSL_CTX *ctx,
18 SSL_SESSION (*get_session_cb)(SSL *, unsigned char *, int, int *));
19
20 int (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx))(struct ssl_st *ssl, SSL_SESSION *sess);
21 void (*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx))(struct ssl_ctx_st *ctx, SSL_SESSION *sess);
22 SSL_SESSION *(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx))(struct ssl_st *ssl, unsigned char *data, int len, int *copy);
23
24 int (*new_session_cb)(struct ssl_st *ssl, SSL_SESSION *sess);
25 void (*remove_session_cb)(struct ssl_ctx_st *ctx, SSL_SESSION *sess);
26 SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl, unsigned char *data,
27 int len, int *copy);
28
29=head1 DESCRIPTION
30
31SSL_CTX_sess_set_new_cb() sets the callback function, which is automatically
32called whenever a new session was negotiated.
33
34SSL_CTX_sess_set_remove_cb() sets the callback function, which is
35automatically called whenever a session is removed by the SSL engine,
36because it is considered faulty or the session has become obsolete because
37of exceeding the timeout value.
38
39SSL_CTX_sess_set_get_cb() sets the callback function which is called,
40whenever a SSL/TLS client proposed to resume a session but the session
41could not be found in the internal session cache (see
42L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>).
43(SSL/TLS server only.)
44
45SSL_CTX_sess_get_new_cb(), SSL_CTX_sess_get_remove_cb(), and
46SSL_CTX_sess_get_get_cb() allow to retrieve the function pointers of the
47provided callback functions. If a callback function has not been set,
48the NULL pointer is returned.
49
50=head1 NOTES
51
52In order to allow external session caching, synchronization with the internal
53session cache is realized via callback functions. Inside these callback
54functions, session can be saved to disk or put into a database using the
55L<d2i_SSL_SESSION(3)|d2i_SSL_SESSION(3)> interface.
56
57The new_session_cb() is called, whenever a new session has been negotiated
58and session caching is enabled (see
59L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>).
60The new_session_cb() is passed the B<ssl> connection and the ssl session
61B<sess>. If the callback returns B<0>, the session will be immediately
62removed again.
63
64The remove_session_cb() is called, whenever the SSL engine removes a session
65from the internal cache. This happens when the session is removed because
66it is expired or when a connection was not shutdown cleanly. It also happens
67for all sessions in the internal session cache when
68L<SSL_CTX_free(3)|SSL_CTX_free(3)> is called. The remove_session_cb() is passed
69the B<ctx> and the ssl session B<sess>. It does not provide any feedback.
70
71The get_session_cb() is only called on SSL/TLS servers with the session id
72proposed by the client. The get_session_cb() is always called, also when
73session caching was disabled. The get_session_cb() is passed the
74B<ssl> connection, the session id of length B<length> at the memory location
75B<data>. With the parameter B<copy> the callback can require the
76SSL engine to increment the reference count of the SSL_SESSION object,
77Normally the reference count is not incremented and therefore the
78session must not be explicitly freed with
79L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>.
80
81=head1 SEE ALSO
82
83L<ssl(3)|ssl(3)>, L<d2i_SSL_SESSION(3)|d2i_SSL_SESSION(3)>,
84L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>,
85L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)>,
86L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>,
87L<SSL_CTX_free(3)|SSL_CTX_free(3)>
88
89=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_sessions.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_sessions.3
new file mode 100644
index 0000000000..96aa018289
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_sessions.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_sessions.pod
deleted file mode 100644
index e05aab3c1b..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_sessions.pod
+++ /dev/null
@@ -1,34 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_sessions - access internal session cache
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 struct lhash_st *SSL_CTX_sessions(SSL_CTX *ctx);
12
13=head1 DESCRIPTION
14
15SSL_CTX_sessions() returns a pointer to the lhash databases containing the
16internal session cache for B<ctx>.
17
18=head1 NOTES
19
20The sessions in the internal session cache are kept in an
21L<lhash(3)|lhash(3)> type database. It is possible to directly
22access this database e.g. for searching. In parallel, the sessions
23form a linked list which is maintained separately from the
24L<lhash(3)|lhash(3)> operations, so that the database must not be
25modified directly but by using the
26L<SSL_CTX_add_session(3)|SSL_CTX_add_session(3)> family of functions.
27
28=head1 SEE ALSO
29
30L<ssl(3)|ssl(3)>, L<lhash(3)|lhash(3)>,
31L<SSL_CTX_add_session(3)|SSL_CTX_add_session(3)>,
32L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>
33
34=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cert_store.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cert_store.3
new file mode 100644
index 0000000000..f80670ce78
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_set_cert_store.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cert_store.pod
deleted file mode 100644
index 2f3980fded..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cert_store.pod
+++ /dev/null
@@ -1,58 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_cert_store, SSL_CTX_get_cert_store - manipulate X509 certificate
6verification storage
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 void SSL_CTX_set_cert_store(SSL_CTX *ctx, X509_STORE *store);
13 X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *ctx);
14
15=head1 DESCRIPTION
16
17SSL_CTX_set_cert_store() sets/replaces the certificate verification storage
18of B<ctx> to/with B<store>. If another X509_STORE object is currently
19set in B<ctx>, it will be X509_STORE_free()ed.
20
21SSL_CTX_get_cert_store() returns a pointer to the current certificate
22verification storage.
23
24=head1 NOTES
25
26In order to verify the certificates presented by the peer, trusted CA
27certificates must be accessed. These CA certificates are made available
28via lookup methods, handled inside the X509_STORE. From the X509_STORE
29the X509_STORE_CTX used when verifying certificates is created.
30
31Typically the trusted certificate store is handled indirectly via using
32L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>.
33Using the SSL_CTX_set_cert_store() and SSL_CTX_get_cert_store() functions
34it is possible to manipulate the X509_STORE object beyond the
35L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>
36call.
37
38Currently no detailed documentation on how to use the X509_STORE
39object is available. Not all members of the X509_STORE are used when
40the verification takes place. So will e.g. the verify_callback() be
41overridden with the verify_callback() set via the
42L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)> family of functions.
43This document must therefore be updated when documentation about the
44X509_STORE object and its handling becomes available.
45
46=head1 RETURN VALUES
47
48SSL_CTX_set_cert_store() does not return diagnostic output.
49
50SSL_CTX_get_cert_store() returns the current setting.
51
52=head1 SEE ALSO
53
54L<ssl(3)|ssl(3)>,
55L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>,
56L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>
57
58=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cert_verify_callback.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cert_verify_callback.3
new file mode 100644
index 0000000000..b34d3a6003
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_set_cert_verify_callback.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cert_verify_callback.pod
deleted file mode 100644
index 713b223a63..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cert_verify_callback.pod
+++ /dev/null
@@ -1,75 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_cert_verify_callback - set peer certificate verification procedure
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, int (*callback)(X509_STORE_CTX *,void *), void *arg);
12
13=head1 DESCRIPTION
14
15SSL_CTX_set_cert_verify_callback() sets the verification callback function for
16I<ctx>. SSL objects that are created from I<ctx> inherit the setting valid at
17the time when L<SSL_new(3)|SSL_new(3)> is called.
18
19=head1 NOTES
20
21Whenever a certificate is verified during a SSL/TLS handshake, a verification
22function is called. If the application does not explicitly specify a
23verification callback function, the built-in verification function is used.
24If a verification callback I<callback> is specified via
25SSL_CTX_set_cert_verify_callback(), the supplied callback function is called
26instead. By setting I<callback> to NULL, the default behaviour is restored.
27
28When the verification must be performed, I<callback> will be called with
29the arguments callback(X509_STORE_CTX *x509_store_ctx, void *arg). The
30argument I<arg> is specified by the application when setting I<callback>.
31
32I<callback> should return 1 to indicate verification success and 0 to
33indicate verification failure. If SSL_VERIFY_PEER is set and I<callback>
34returns 0, the handshake will fail. As the verification procedure may
35allow to continue the connection in case of failure (by always returning 1)
36the verification result must be set in any case using the B<error>
37member of I<x509_store_ctx> so that the calling application will be informed
38about the detailed result of the verification procedure!
39
40Within I<x509_store_ctx>, I<callback> has access to the I<verify_callback>
41function set using L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>.
42
43=head1 WARNINGS
44
45Do not mix the verification callback described in this function with the
46B<verify_callback> function called during the verification process. The
47latter is set using the L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>
48family of functions.
49
50Providing a complete verification procedure including certificate purpose
51settings etc is a complex task. The built-in procedure is quite powerful
52and in most cases it should be sufficient to modify its behaviour using
53the B<verify_callback> function.
54
55=head1 BUGS
56
57=head1 RETURN VALUES
58
59SSL_CTX_set_cert_verify_callback() does not provide diagnostic information.
60
61=head1 SEE ALSO
62
63L<ssl(3)|ssl(3)>, L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>,
64L<SSL_get_verify_result(3)|SSL_get_verify_result(3)>,
65L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>
66
67=head1 HISTORY
68
69Previous to OpenSSL 0.9.7, the I<arg> argument to
70B<SSL_CTX_set_cert_verify_callback> was ignored, and I<callback> was called
71simply as int (*callback)(X509_STORE_CTX *) To compile software written for
72previous versions of OpenSSL, a dummy argument will have to be added to
73I<callback>.
74
75=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cipher_list.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cipher_list.3
new file mode 100644
index 0000000000..c3ee5304e3
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_set_cipher_list.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cipher_list.pod
deleted file mode 100644
index 83e9c6b7e3..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cipher_list.pod
+++ /dev/null
@@ -1,71 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_cipher_list, SSL_set_cipher_list - choose list of available
6SSL_CIPHERs
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 int SSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *str);
13 int SSL_set_cipher_list(SSL *ssl, const char *str);
14
15=head1 DESCRIPTION
16
17SSL_CTX_set_cipher_list() sets the list of available ciphers for B<ctx>
18using the control string B<str>. The format of the string is described
19in L<ciphers(1)|ciphers(1)>. The list of ciphers is inherited by all
20B<ssl> objects created from B<ctx>.
21
22SSL_set_cipher_list() sets the list of ciphers only for B<ssl>.
23
24=head1 NOTES
25
26The control string B<str> should be universally usable and not depend
27on details of the library configuration (ciphers compiled in). Thus no
28syntax checking takes place. Items that are not recognized, because the
29corresponding ciphers are not compiled in or because they are mistyped,
30are simply ignored. Failure is only flagged if no ciphers could be collected
31at all.
32
33It should be noted, that inclusion of a cipher to be used into the list is
34a necessary condition. On the client side, the inclusion into the list is
35also sufficient. On the server side, additional restrictions apply. All ciphers
36have additional requirements. ADH ciphers don't need a certificate, but
37DH-parameters must have been set. All other ciphers need a corresponding
38certificate and key.
39
40A RSA cipher can only be chosen, when a RSA certificate is available.
41RSA export ciphers with a keylength of 512 bits for the RSA key require
42a temporary 512 bit RSA key, as typically the supplied key has a length
43of 1024 bit (see
44L<SSL_CTX_set_tmp_rsa_callback(3)|SSL_CTX_set_tmp_rsa_callback(3)>).
45RSA ciphers using EDH need a certificate and key and additional DH-parameters
46(see L<SSL_CTX_set_tmp_dh_callback(3)|SSL_CTX_set_tmp_dh_callback(3)>).
47
48A DSA cipher can only be chosen, when a DSA certificate is available.
49DSA ciphers always use DH key exchange and therefore need DH-parameters
50(see L<SSL_CTX_set_tmp_dh_callback(3)|SSL_CTX_set_tmp_dh_callback(3)>).
51
52When these conditions are not met for any cipher in the list (e.g. a
53client only supports export RSA ciphers with a asymmetric key length
54of 512 bits and the server is not configured to use temporary RSA
55keys), the "no shared cipher" (SSL_R_NO_SHARED_CIPHER) error is generated
56and the handshake will fail.
57
58=head1 RETURN VALUES
59
60SSL_CTX_set_cipher_list() and SSL_set_cipher_list() return 1 if any cipher
61could be selected and 0 on complete failure.
62
63=head1 SEE ALSO
64
65L<ssl(3)|ssl(3)>, L<SSL_get_ciphers(3)|SSL_get_ciphers(3)>,
66L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>,
67L<SSL_CTX_set_tmp_rsa_callback(3)|SSL_CTX_set_tmp_rsa_callback(3)>,
68L<SSL_CTX_set_tmp_dh_callback(3)|SSL_CTX_set_tmp_dh_callback(3)>,
69L<ciphers(1)|ciphers(1)>
70
71=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_client_CA_list.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_client_CA_list.3
new file mode 100644
index 0000000000..5d6fa9bea1
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_set_client_CA_list.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_client_CA_list.pod
deleted file mode 100644
index d1758a7d20..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_client_CA_list.pod
+++ /dev/null
@@ -1,94 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_client_CA_list, SSL_set_client_CA_list, SSL_CTX_add_client_CA,
6SSL_add_client_CA - set list of CAs sent to the client when requesting a
7client certificate
8
9=head1 SYNOPSIS
10
11 #include <openssl/ssl.h>
12
13 void SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *list);
14 void SSL_set_client_CA_list(SSL *s, STACK_OF(X509_NAME) *list);
15 int SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *cacert);
16 int SSL_add_client_CA(SSL *ssl, X509 *cacert);
17
18=head1 DESCRIPTION
19
20SSL_CTX_set_client_CA_list() sets the B<list> of CAs sent to the client when
21requesting a client certificate for B<ctx>.
22
23SSL_set_client_CA_list() sets the B<list> of CAs sent to the client when
24requesting a client certificate for the chosen B<ssl>, overriding the
25setting valid for B<ssl>'s SSL_CTX object.
26
27SSL_CTX_add_client_CA() adds the CA name extracted from B<cacert> to the
28list of CAs sent to the client when requesting a client certificate for
29B<ctx>.
30
31SSL_add_client_CA() adds the CA name extracted from B<cacert> to the
32list of CAs sent to the client when requesting a client certificate for
33the chosen B<ssl>, overriding the setting valid for B<ssl>'s SSL_CTX object.
34
35=head1 NOTES
36
37When a TLS/SSL server requests a client certificate (see
38B<SSL_CTX_set_verify(3)>), it sends a list of CAs, for which
39it will accept certificates, to the client.
40
41This list must explicitly be set using SSL_CTX_set_client_CA_list() for
42B<ctx> and SSL_set_client_CA_list() for the specific B<ssl>. The list
43specified overrides the previous setting. The CAs listed do not become
44trusted (B<list> only contains the names, not the complete certificates); use
45L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>
46to additionally load them for verification.
47
48If the list of acceptable CAs is compiled in a file, the
49L<SSL_load_client_CA_file(3)|SSL_load_client_CA_file(3)>
50function can be used to help importing the necessary data.
51
52SSL_CTX_add_client_CA() and SSL_add_client_CA() can be used to add additional
53items the list of client CAs. If no list was specified before using
54SSL_CTX_set_client_CA_list() or SSL_set_client_CA_list(), a new client
55CA list for B<ctx> or B<ssl> (as appropriate) is opened.
56
57These functions are only useful for TLS/SSL servers.
58
59=head1 RETURN VALUES
60
61SSL_CTX_set_client_CA_list() and SSL_set_client_CA_list() do not return
62diagnostic information.
63
64SSL_CTX_add_client_CA() and SSL_add_client_CA() have the following return
65values:
66
67=over 4
68
69=item C<0>
70
71A failure while manipulating the STACK_OF(X509_NAME) object occurred or
72the X509_NAME could not be extracted from B<cacert>. Check the error stack
73to find out the reason.
74
75=item C<1>
76
77The operation succeeded.
78
79=back
80
81=head1 EXAMPLES
82
83Scan all certificates in B<CAfile> and list them as acceptable CAs:
84
85 SSL_CTX_set_client_CA_list(ctx,SSL_load_client_CA_file(CAfile));
86
87=head1 SEE ALSO
88
89L<ssl(3)|ssl(3)>,
90L<SSL_get_client_CA_list(3)|SSL_get_client_CA_list(3)>,
91L<SSL_load_client_CA_file(3)|SSL_load_client_CA_file(3)>,
92L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>
93
94=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_client_cert_cb.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_client_cert_cb.3
new file mode 100644
index 0000000000..6aaa5f1016
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_set_client_cert_cb.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_client_cert_cb.pod
deleted file mode 100644
index 0462bbebac..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_client_cert_cb.pod
+++ /dev/null
@@ -1,95 +0,0 @@
13=pod
2
3=head1 NAME
4
5SSL_CTX_set_client_cert_cb, SSL_CTX_get_client_cert_cb - handle client
6certificate callback function
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 void SSL_CTX_set_client_cert_cb(SSL_CTX *ctx, int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey));
13 int (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx))(SSL *ssl, X509 **x509, EVP_PKEY **pkey);
14 int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey);
15
16=head1 DESCRIPTION
17
18SSL_CTX_set_client_cert_cb() sets the B<client_cert_cb()> callback, that is
19called when a client certificate is requested by a server and no certificate
20was yet set for the SSL object.
21
22When B<client_cert_cb()> is NULL, no callback function is used.
23
24SSL_CTX_get_client_cert_cb() returns a pointer to the currently set callback
25function.
26
27client_cert_cb() is the application defined callback. If it wants to
28set a certificate, a certificate/private key combination must be set
29using the B<x509> and B<pkey> arguments and "1" must be returned. The
30certificate will be installed into B<ssl>, see the NOTES and BUGS sections.
31If no certificate should be set, "0" has to be returned and no certificate
32will be sent. A negative return value will suspend the handshake and the
33handshake function will return immediately. L<SSL_get_error(3)|SSL_get_error(3)>
34will return SSL_ERROR_WANT_X509_LOOKUP to indicate, that the handshake was
35suspended. The next call to the handshake function will again lead to the call
36of client_cert_cb(). It is the job of the client_cert_cb() to store information
37about the state of the last call, if required to continue.
38
39=head1 NOTES
40
41During a handshake (or renegotiation) a server may request a certificate
42from the client. A client certificate must only be sent, when the server
43did send the request.
44
45When a certificate was set using the
46L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)> family of functions,
47it will be sent to the server. The TLS standard requires that only a
48certificate is sent, if it matches the list of acceptable CAs sent by the
49server. This constraint is violated by the default behavior of the OpenSSL
50library. Using the callback function it is possible to implement a proper
51selection routine or to allow a user interaction to choose the certificate to
52be sent.
53
54If a callback function is defined and no certificate was yet defined for the
55SSL object, the callback function will be called.
56If the callback function returns a certificate, the OpenSSL library
57will try to load the private key and certificate data into the SSL
58object using the SSL_use_certificate() and SSL_use_private_key() functions.
59Thus it will permanently install the certificate and key for this SSL
60object. It will not be reset by calling L<SSL_clear(3)|SSL_clear(3)>.
61If the callback returns no certificate, the OpenSSL library will not send
62a certificate.
63
64=head1 BUGS
65
66The client_cert_cb() cannot return a complete certificate chain, it can
67only return one client certificate. If the chain only has a length of 2,
68the root CA certificate may be omitted according to the TLS standard and
69thus a standard conforming answer can be sent to the server. For a
70longer chain, the client must send the complete chain (with the option
71to leave out the root CA certificate). This can only be accomplished by
72either adding the intermediate CA certificates into the trusted
73certificate store for the SSL_CTX object (resulting in having to add
74CA certificates that otherwise maybe would not be trusted), or by adding
75the chain certificates using the
76L<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)>
77function, which is only available for the SSL_CTX object as a whole and that
78therefore probably can only apply for one client certificate, making
79the concept of the callback function (to allow the choice from several
80certificates) questionable.
81
82Once the SSL object has been used in conjunction with the callback function,
83the certificate will be set for the SSL object and will not be cleared
84even when L<SSL_clear(3)|SSL_clear(3)> is being called. It is therefore
85mandatory to destroy the SSL object using L<SSL_free(3)|SSL_free(3)>
86and create a new one to return to the previous state.
87
88=head1 SEE ALSO
89
90L<ssl(3)|ssl(3)>, L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>,
91L<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)>,
92L<SSL_get_client_CA_list(3)|SSL_get_client_CA_list(3)>,
93L<SSL_clear(3)|SSL_clear(3)>, L<SSL_free(3)|SSL_free(3)>
94
95=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_default_passwd_cb.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_default_passwd_cb.3
new file mode 100644
index 0000000000..2c35ed501c
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_set_default_passwd_cb.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_default_passwd_cb.pod
deleted file mode 100644
index f7bfc64930..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_default_passwd_cb.pod
+++ /dev/null
@@ -1,77 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_default_passwd_cb, SSL_CTX_set_default_passwd_cb_userdata - set
6passwd callback for encrypted PEM file handling
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb);
13 void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u);
14
15 int pem_passwd_cb(char *buf, int size, int rwflag, void *userdata);
16
17=head1 DESCRIPTION
18
19SSL_CTX_set_default_passwd_cb() sets the default password callback called
20when loading/storing a PEM certificate with encryption.
21
22SSL_CTX_set_default_passwd_cb_userdata() sets a pointer to B<userdata> which
23will be provided to the password callback on invocation.
24
25The pem_passwd_cb(), which must be provided by the application, hands back the
26password to be used during decryption. On invocation a pointer to B<userdata>
27is provided. The pem_passwd_cb must write the password into the provided buffer
28B<buf> which is of size B<size>. The actual length of the password must
29be returned to the calling function. B<rwflag> indicates whether the
30callback is used for reading/decryption (rwflag=0) or writing/encryption
31(rwflag=1).
32
33=head1 NOTES
34
35When loading or storing private keys, a password might be supplied to
36protect the private key. The way this password can be supplied may depend
37on the application. If only one private key is handled, it can be practical
38to have pem_passwd_cb() handle the password dialog interactively. If several
39keys have to be handled, it can be practical to ask for the password once,
40then keep it in memory and use it several times. In the last case, the
41password could be stored into the B<userdata> storage and the
42pem_passwd_cb() only returns the password already stored.
43
44When asking for the password interactively, pem_passwd_cb() can use
45B<rwflag> to check, whether an item shall be encrypted (rwflag=1).
46In this case the password dialog may ask for the same password twice
47for comparison in order to catch typos, that would make decryption
48impossible.
49
50Other items in PEM formatting (certificates) can also be encrypted, it is
51however not usual, as certificate information is considered public.
52
53=head1 RETURN VALUES
54
55SSL_CTX_set_default_passwd_cb() and SSL_CTX_set_default_passwd_cb_userdata()
56do not provide diagnostic information.
57
58=head1 EXAMPLES
59
60The following example returns the password provided as B<userdata> to the
61calling function. The password is considered to be a '\0' terminated
62string. If the password does not fit into the buffer, the password is
63truncated.
64
65 int pem_passwd_cb(char *buf, int size, int rwflag, void *password)
66 {
67 strncpy(buf, (char *)(password), size);
68 buf[size - 1] = '\0';
69 return(strlen(buf));
70 }
71
72=head1 SEE ALSO
73
74L<ssl(3)|ssl(3)>,
75L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>
76
77=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_generate_session_id.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_generate_session_id.3
new file mode 100644
index 0000000000..e2e2a70362
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_set_generate_session_id.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_generate_session_id.pod
deleted file mode 100644
index c04588a03c..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_generate_session_id.pod
+++ /dev/null
@@ -1,152 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_generate_session_id, SSL_set_generate_session_id,
6SSL_has_matching_session_id - manipulate generation of SSL session IDs (server
7only)
8
9=head1 SYNOPSIS
10
11 #include <openssl/ssl.h>
12
13 typedef int (*GEN_SESSION_CB)(const SSL *ssl, unsigned char *id,
14 unsigned int *id_len);
15
16 int SSL_CTX_set_generate_session_id(SSL_CTX *ctx, GEN_SESSION_CB cb);
17 int SSL_set_generate_session_id(SSL *ssl, GEN_SESSION_CB, cb);
18 int SSL_has_matching_session_id(const SSL *ssl, const unsigned char *id,
19 unsigned int id_len);
20
21=head1 DESCRIPTION
22
23SSL_CTX_set_generate_session_id() sets the callback function for generating
24new session ids for SSL/TLS sessions for B<ctx> to be B<cb>.
25
26SSL_set_generate_session_id() sets the callback function for generating
27new session ids for SSL/TLS sessions for B<ssl> to be B<cb>.
28
29SSL_has_matching_session_id() checks, whether a session with id B<id>
30(of length B<id_len>) is already contained in the internal session cache
31of the parent context of B<ssl>.
32
33=head1 NOTES
34
35When a new session is established between client and server, the server
36generates a session id. The session id is an arbitrary sequence of bytes.
37The length of the session id is 16 bytes for SSLv2 sessions and between
381 and 32 bytes for SSLv3/TLSv1. The session id is not security critical
39but must be unique for the server. Additionally, the session id is
40transmitted in the clear when reusing the session so it must not contain
41sensitive information.
42
43Without a callback being set, an OpenSSL server will generate a unique
44session id from pseudo random numbers of the maximum possible length.
45Using the callback function, the session id can be changed to contain
46additional information like e.g. a host id in order to improve load balancing
47or external caching techniques.
48
49The callback function receives a pointer to the memory location to put
50B<id> into and a pointer to the maximum allowed length B<id_len>. The
51buffer at location B<id> is only guaranteed to have the size B<id_len>.
52The callback is only allowed to generate a shorter id and reduce B<id_len>;
53the callback B<must never> increase B<id_len> or write to the location
54B<id> exceeding the given limit.
55
56If a SSLv2 session id is generated and B<id_len> is reduced, it will be
57restored after the callback has finished and the session id will be padded
58with 0x00. It is not recommended to change the B<id_len> for SSLv2 sessions.
59The callback can use the L<SSL_get_version(3)|SSL_get_version(3)> function
60to check, whether the session is of type SSLv2.
61
62The location B<id> is filled with 0x00 before the callback is called, so the
63callback may only fill part of the possible length and leave B<id_len>
64untouched while maintaining reproducibility.
65
66Since the sessions must be distinguished, session ids must be unique.
67Without the callback a random number is used, so that the probability
68of generating the same session id is extremely small (2^128 possible ids
69for an SSLv2 session, 2^256 for SSLv3/TLSv1). In order to assure the
70uniqueness of the generated session id, the callback must call
71SSL_has_matching_session_id() and generate another id if a conflict occurs.
72If an id conflict is not resolved, the handshake will fail.
73If the application codes e.g. a unique host id, a unique process number, and
74a unique sequence number into the session id, uniqueness could easily be
75achieved without randomness added (it should however be taken care that
76no confidential information is leaked this way). If the application can not
77guarantee uniqueness, it is recommended to use the maximum B<id_len> and
78fill in the bytes not used to code special information with random data
79to avoid collisions.
80
81SSL_has_matching_session_id() will only query the internal session cache,
82not the external one. Since the session id is generated before the
83handshake is completed, it is not immediately added to the cache. If
84another thread is using the same internal session cache, a race condition
85can occur in that another thread generates the same session id.
86Collisions can also occur when using an external session cache, since
87the external cache is not tested with SSL_has_matching_session_id()
88and the same race condition applies.
89
90When calling SSL_has_matching_session_id() for an SSLv2 session with
91reduced B<id_len>, the match operation will be performed using the
92fixed length required and with a 0x00 padded id.
93
94The callback must return 0 if it cannot generate a session id for whatever
95reason and return 1 on success.
96
97=head1 EXAMPLES
98
99The callback function listed will generate a session id with the
100server id given, and will fill the rest with pseudo random bytes:
101
102 const char session_id_prefix = "www-18";
103
104 #define MAX_SESSION_ID_ATTEMPTS 10
105 static int generate_session_id(const SSL *ssl, unsigned char *id,
106 unsigned int *id_len)
107 {
108 unsigned int count = 0;
109 const char *version;
110
111 version = SSL_get_version(ssl);
112 if (!strcmp(version, "SSLv2"))
113 /* we must not change id_len */;
114
115 do {
116 RAND_pseudo_bytes(id, *id_len);
117 /* Prefix the session_id with the required prefix. NB: If our
118 * prefix is too long, clip it - but there will be worse effects
119 * anyway, eg. the server could only possibly create 1 session
120 * ID (ie. the prefix!) so all future session negotiations will
121 * fail due to conflicts. */
122 memcpy(id, session_id_prefix,
123 (strlen(session_id_prefix) < *id_len) ?
124 strlen(session_id_prefix) : *id_len);
125 }
126 while(SSL_has_matching_session_id(ssl, id, *id_len) &&
127 (++count < MAX_SESSION_ID_ATTEMPTS));
128 if(count >= MAX_SESSION_ID_ATTEMPTS)
129 return 0;
130 return 1;
131 }
132
133
134=head1 RETURN VALUES
135
136SSL_CTX_set_generate_session_id() and SSL_set_generate_session_id()
137always return 1.
138
139SSL_has_matching_session_id() returns 1 if another session with the
140same id is already in the cache.
141
142=head1 SEE ALSO
143
144L<ssl(3)|ssl(3)>, L<SSL_get_version(3)|SSL_get_version(3)>
145
146=head1 HISTORY
147
148SSL_CTX_set_generate_session_id(), SSL_set_generate_session_id()
149and SSL_has_matching_session_id() have been introduced in
150OpenSSL 0.9.7.
151
152=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_info_callback.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_info_callback.3
new file mode 100644
index 0000000000..dcf298addf
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_set_info_callback.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_info_callback.pod
deleted file mode 100644
index f7923dedc1..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_info_callback.pod
+++ /dev/null
@@ -1,154 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_info_callback, SSL_CTX_get_info_callback, SSL_set_info_callback,
6SSL_get_info_callback - handle information callback for SSL connections
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 void SSL_CTX_set_info_callback(SSL_CTX *ctx, void (*callback)());
13 void (*SSL_CTX_get_info_callback(const SSL_CTX *ctx))();
14
15 void SSL_set_info_callback(SSL *ssl, void (*callback)());
16 void (*SSL_get_info_callback(const SSL *ssl))();
17
18=head1 DESCRIPTION
19
20SSL_CTX_set_info_callback() sets the B<callback> function, that can be used to
21obtain state information for SSL objects created from B<ctx> during connection
22setup and use. The setting for B<ctx> is overridden from the setting for
23a specific SSL object, if specified.
24When B<callback> is NULL, no callback function is used.
25
26SSL_set_info_callback() sets the B<callback> function, that can be used to
27obtain state information for B<ssl> during connection setup and use.
28When B<callback> is NULL, the callback setting currently valid for
29B<ctx> is used.
30
31SSL_CTX_get_info_callback() returns a pointer to the currently set information
32callback function for B<ctx>.
33
34SSL_get_info_callback() returns a pointer to the currently set information
35callback function for B<ssl>.
36
37=head1 NOTES
38
39When setting up a connection and during use, it is possible to obtain state
40information from the SSL/TLS engine. When set, an information callback function
41is called whenever the state changes, an alert appears, or an error occurs.
42
43The callback function is called as B<callback(SSL *ssl, int where, int ret)>.
44The B<where> argument specifies information about where (in which context)
45the callback function was called. If B<ret> is 0, an error condition occurred.
46If an alert is handled, SSL_CB_ALERT is set and B<ret> specifies the alert
47information.
48
49B<where> is a bitmask made up of the following bits:
50
51=over 4
52
53=item SSL_CB_LOOP
54
55Callback has been called to indicate state change inside a loop.
56
57=item SSL_CB_EXIT
58
59Callback has been called to indicate error exit of a handshake function.
60(May be soft error with retry option for non-blocking setups.)
61
62=item SSL_CB_READ
63
64Callback has been called during read operation.
65
66=item SSL_CB_WRITE
67
68Callback has been called during write operation.
69
70=item SSL_CB_ALERT
71
72Callback has been called due to an alert being sent or received.
73
74=item SSL_CB_READ_ALERT (SSL_CB_ALERT|SSL_CB_READ)
75
76=item SSL_CB_WRITE_ALERT (SSL_CB_ALERT|SSL_CB_WRITE)
77
78=item SSL_CB_ACCEPT_LOOP (SSL_ST_ACCEPT|SSL_CB_LOOP)
79
80=item SSL_CB_ACCEPT_EXIT (SSL_ST_ACCEPT|SSL_CB_EXIT)
81
82=item SSL_CB_CONNECT_LOOP (SSL_ST_CONNECT|SSL_CB_LOOP)
83
84=item SSL_CB_CONNECT_EXIT (SSL_ST_CONNECT|SSL_CB_EXIT)
85
86=item SSL_CB_HANDSHAKE_START
87
88Callback has been called because a new handshake is started.
89
90=item SSL_CB_HANDSHAKE_DONE 0x20
91
92Callback has been called because a handshake is finished.
93
94=back
95
96The current state information can be obtained using the
97L<SSL_state_string(3)|SSL_state_string(3)> family of functions.
98
99The B<ret> information can be evaluated using the
100L<SSL_alert_type_string(3)|SSL_alert_type_string(3)> family of functions.
101
102=head1 RETURN VALUES
103
104SSL_set_info_callback() does not provide diagnostic information.
105
106SSL_get_info_callback() returns the current setting.
107
108=head1 EXAMPLES
109
110The following example callback function prints state strings, information
111about alerts being handled and error messages to the B<bio_err> BIO.
112
113 void apps_ssl_info_callback(SSL *s, int where, int ret)
114 {
115 const char *str;
116 int w;
117
118 w=where& ~SSL_ST_MASK;
119
120 if (w & SSL_ST_CONNECT) str="SSL_connect";
121 else if (w & SSL_ST_ACCEPT) str="SSL_accept";
122 else str="undefined";
123
124 if (where & SSL_CB_LOOP)
125 {
126 BIO_printf(bio_err,"%s:%s\n",str,SSL_state_string_long(s));
127 }
128 else if (where & SSL_CB_ALERT)
129 {
130 str=(where & SSL_CB_READ)?"read":"write";
131 BIO_printf(bio_err,"SSL3 alert %s:%s:%s\n",
132 str,
133 SSL_alert_type_string_long(ret),
134 SSL_alert_desc_string_long(ret));
135 }
136 else if (where & SSL_CB_EXIT)
137 {
138 if (ret == 0)
139 BIO_printf(bio_err,"%s:failed in %s\n",
140 str,SSL_state_string_long(s));
141 else if (ret < 0)
142 {
143 BIO_printf(bio_err,"%s:error in %s\n",
144 str,SSL_state_string_long(s));
145 }
146 }
147 }
148
149=head1 SEE ALSO
150
151L<ssl(3)|ssl(3)>, L<SSL_state_string(3)|SSL_state_string(3)>,
152L<SSL_alert_type_string(3)|SSL_alert_type_string(3)>
153
154=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_max_cert_list.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_max_cert_list.3
new file mode 100644
index 0000000000..7380884867
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_set_max_cert_list.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_max_cert_list.pod
deleted file mode 100644
index 5b874aa5fd..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_max_cert_list.pod
+++ /dev/null
@@ -1,78 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_max_cert_list, SSL_CTX_get_max_cert_list, SSL_set_max_cert_list,
6SSL_get_max_cert_list - manipulate allowed size for the peer's certificate chain
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 long SSL_CTX_set_max_cert_list(SSL_CTX *ctx, long size);
13 long SSL_CTX_get_max_cert_list(SSL_CTX *ctx);
14
15 long SSL_set_max_cert_list(SSL *ssl, long size);
16 long SSL_get_max_cert_list(SSL *ctx);
17
18=head1 DESCRIPTION
19
20SSL_CTX_set_max_cert_list() sets the maximum size allowed for the peer's
21certificate chain for all SSL objects created from B<ctx> to be <size> bytes.
22The SSL objects inherit the setting valid for B<ctx> at the time
23L<SSL_new(3)|SSL_new(3)> is being called.
24
25SSL_CTX_get_max_cert_list() returns the currently set maximum size for B<ctx>.
26
27SSL_set_max_cert_list() sets the maximum size allowed for the peer's
28certificate chain for B<ssl> to be <size> bytes. This setting stays valid
29until a new value is set.
30
31SSL_get_max_cert_list() returns the currently set maximum size for B<ssl>.
32
33=head1 NOTES
34
35During the handshake process, the peer may send a certificate chain.
36The TLS/SSL standard does not give any maximum size of the certificate chain.
37The OpenSSL library handles incoming data by a dynamically allocated buffer.
38In order to prevent this buffer from growing without bounds due to data
39received from a faulty or malicious peer, a maximum size for the certificate
40chain is set.
41
42The default value for the maximum certificate chain size is 100kB (30kB
43on the 16bit DOS platform). This should be sufficient for usual certificate
44chains (OpenSSL's default maximum chain length is 10, see
45L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>, and certificates
46without special extensions have a typical size of 1-2kB).
47
48For special applications it can be necessary to extend the maximum certificate
49chain size allowed to be sent by the peer, see e.g. the work on
50"Internet X.509 Public Key Infrastructure Proxy Certificate Profile"
51and "TLS Delegation Protocol" at http://www.ietf.org/ and
52http://www.globus.org/ .
53
54Under normal conditions it should never be necessary to set a value smaller
55than the default, as the buffer is handled dynamically and only uses the
56memory actually required by the data sent by the peer.
57
58If the maximum certificate chain size allowed is exceeded, the handshake will
59fail with a SSL_R_EXCESSIVE_MESSAGE_SIZE error.
60
61=head1 RETURN VALUES
62
63SSL_CTX_set_max_cert_list() and SSL_set_max_cert_list() return the previously
64set value.
65
66SSL_CTX_get_max_cert_list() and SSL_get_max_cert_list() return the currently
67set value.
68
69=head1 SEE ALSO
70
71L<ssl(3)|ssl(3)>, L<SSL_new(3)|SSL_new(3)>,
72L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>
73
74=head1 HISTORY
75
76SSL*_set/get_max_cert_list() have been introduced in OpenSSL 0.9.7.
77
78=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_mode.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_mode.3
new file mode 100644
index 0000000000..b980d43dbe
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_set_mode.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_mode.pod
deleted file mode 100644
index 0208d17654..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_mode.pod
+++ /dev/null
@@ -1,92 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_mode, SSL_set_mode, SSL_CTX_get_mode, SSL_get_mode - manipulate SSL
6engine mode
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 long SSL_CTX_set_mode(SSL_CTX *ctx, long mode);
13 long SSL_set_mode(SSL *ssl, long mode);
14
15 long SSL_CTX_get_mode(SSL_CTX *ctx);
16 long SSL_get_mode(SSL *ssl);
17
18=head1 DESCRIPTION
19
20SSL_CTX_set_mode() adds the mode set via bitmask in B<mode> to B<ctx>.
21Options already set before are not cleared.
22
23SSL_set_mode() adds the mode set via bitmask in B<mode> to B<ssl>.
24Options already set before are not cleared.
25
26SSL_CTX_get_mode() returns the mode set for B<ctx>.
27
28SSL_get_mode() returns the mode set for B<ssl>.
29
30=head1 NOTES
31
32The following mode changes are available:
33
34=over 4
35
36=item SSL_MODE_ENABLE_PARTIAL_WRITE
37
38Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success
39when just a single record has been written). When not set (the default),
40SSL_write() will only report success once the complete chunk was written.
41Once SSL_write() returns with r, r bytes have been successfully written
42and the next call to SSL_write() must only send the n-r bytes left,
43imitating the behaviour of write().
44
45=item SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER
46
47Make it possible to retry SSL_write() with changed buffer location
48(the buffer contents must stay the same). This is not the default to avoid
49the misconception that non-blocking SSL_write() behaves like
50non-blocking write().
51
52=item SSL_MODE_AUTO_RETRY
53
54Never bother the application with retries if the transport is blocking.
55If a renegotiation take place during normal operation, a
56L<SSL_read(3)|SSL_read(3)> or L<SSL_write(3)|SSL_write(3)> would return
57with -1 and indicate the need to retry with SSL_ERROR_WANT_READ.
58In a non-blocking environment applications must be prepared to handle
59incomplete read/write operations.
60In a blocking environment, applications are not always prepared to
61deal with read/write operations returning without success report. The
62flag SSL_MODE_AUTO_RETRY will cause read/write operations to only
63return after the handshake and successful completion.
64
65=item SSL_MODE_RELEASE_BUFFERS
66
67When we no longer need a read buffer or a write buffer for a given SSL,
68then release the memory we were using to hold it. Released memory is
69either appended to a list of unused RAM chunks on the SSL_CTX, or simply
70freed if the list of unused chunks would become longer than
71SSL_CTX->freelist_max_len, which defaults to 32. Using this flag can
72save around 34k per idle SSL connection.
73This flag has no effect on SSL v2 connections, or on DTLS connections.
74
75=back
76
77=head1 RETURN VALUES
78
79SSL_CTX_set_mode() and SSL_set_mode() return the new mode bitmask
80after adding B<mode>.
81
82SSL_CTX_get_mode() and SSL_get_mode() return the current bitmask.
83
84=head1 SEE ALSO
85
86L<ssl(3)|ssl(3)>, L<SSL_read(3)|SSL_read(3)>, L<SSL_write(3)|SSL_write(3)>
87
88=head1 HISTORY
89
90SSL_MODE_AUTO_RETRY as been added in OpenSSL 0.9.6.
91
92=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_msg_callback.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_msg_callback.3
new file mode 100644
index 0000000000..82c1479af0
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_set_msg_callback.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_msg_callback.pod
deleted file mode 100644
index 89a33e8750..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_msg_callback.pod
+++ /dev/null
@@ -1,101 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_msg_callback, SSL_CTX_set_msg_callback_arg, SSL_set_msg_callback,
6SSL_get_msg_callback_arg - install callback for observing protocol messages
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 void SSL_CTX_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg));
13 void SSL_CTX_set_msg_callback_arg(SSL_CTX *ctx, void *arg);
14
15 void SSL_set_msg_callback(SSL *ssl, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg));
16 void SSL_set_msg_callback_arg(SSL *ssl, void *arg);
17
18=head1 DESCRIPTION
19
20SSL_CTX_set_msg_callback() or SSL_set_msg_callback() can be used to
21define a message callback function I<cb> for observing all SSL/TLS
22protocol messages (such as handshake messages) that are received or
23sent. SSL_CTX_set_msg_callback_arg() and SSL_set_msg_callback_arg()
24can be used to set argument I<arg> to the callback function, which is
25available for arbitrary application use.
26
27SSL_CTX_set_msg_callback() and SSL_CTX_set_msg_callback_arg() specify
28default settings that will be copied to new B<SSL> objects by
29L<SSL_new(3)|SSL_new(3)>. SSL_set_msg_callback() and
30SSL_set_msg_callback_arg() modify the actual settings of an B<SSL>
31object. Using a B<0> pointer for I<cb> disables the message callback.
32
33When I<cb> is called by the SSL/TLS library for a protocol message,
34the function arguments have the following meaning:
35
36=over 4
37
38=item I<write_p>
39
40This flag is B<0> when a protocol message has been received and B<1>
41when a protocol message has been sent.
42
43=item I<version>
44
45The protocol version according to which the protocol message is
46interpreted by the library. Currently, this is one of
47B<SSL2_VERSION>, B<SSL3_VERSION> and B<TLS1_VERSION> (for SSL 2.0, SSL
483.0 and TLS 1.0, respectively).
49
50=item I<content_type>
51
52In the case of SSL 2.0, this is always B<0>. In the case of SSL 3.0
53or TLS 1.0, this is one of the B<ContentType> values defined in the
54protocol specification (B<change_cipher_spec(20)>, B<alert(21)>,
55B<handshake(22)>; but never B<application_data(23)> because the
56callback will only be called for protocol messages).
57
58=item I<buf>, I<len>
59
60I<buf> points to a buffer containing the protocol message, which
61consists of I<len> bytes. The buffer is no longer valid after the
62callback function has returned.
63
64=item I<ssl>
65
66The B<SSL> object that received or sent the message.
67
68=item I<arg>
69
70The user-defined argument optionally defined by
71SSL_CTX_set_msg_callback_arg() or SSL_set_msg_callback_arg().
72
73=back
74
75=head1 NOTES
76
77Protocol messages are passed to the callback function after decryption
78and fragment collection where applicable. (Thus record boundaries are
79not visible.)
80
81If processing a received protocol message results in an error,
82the callback function may not be called. For example, the callback
83function will never see messages that are considered too large to be
84processed.
85
86Due to automatic protocol version negotiation, I<version> is not
87necessarily the protocol version used by the sender of the message: If
88a TLS 1.0 ClientHello message is received by an SSL 3.0-only server,
89I<version> will be B<SSL3_VERSION>.
90
91=head1 SEE ALSO
92
93L<ssl(3)|ssl(3)>, L<SSL_new(3)|SSL_new(3)>
94
95=head1 HISTORY
96
97SSL_CTX_set_msg_callback(), SSL_CTX_set_msg_callback_arg(),
98SSL_set_msg_callback() and SSL_get_msg_callback_arg() were added in OpenSSL
990.9.7.
100
101=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_options.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_options.3
new file mode 100644
index 0000000000..8b2f75cc59
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_set_options.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_options.pod
deleted file mode 100644
index c656fb2e19..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_options.pod
+++ /dev/null
@@ -1,350 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_options, SSL_set_options, SSL_CTX_clear_options, SSL_clear_options,
6SSL_CTX_get_options, SSL_get_options, SSL_get_secure_renegotiation_support -
7manipulate SSL options
8
9=head1 SYNOPSIS
10
11 #include <openssl/ssl.h>
12
13 long SSL_CTX_set_options(SSL_CTX *ctx, long options);
14 long SSL_set_options(SSL *ssl, long options);
15
16 long SSL_CTX_clear_options(SSL_CTX *ctx, long options);
17 long SSL_clear_options(SSL *ssl, long options);
18
19 long SSL_CTX_get_options(SSL_CTX *ctx);
20 long SSL_get_options(SSL *ssl);
21
22 long SSL_get_secure_renegotiation_support(SSL *ssl);
23
24=head1 DESCRIPTION
25
26Note: all these functions are implemented using macros.
27
28SSL_CTX_set_options() adds the options set via bitmask in B<options> to B<ctx>.
29Options already set before are not cleared!
30
31SSL_set_options() adds the options set via bitmask in B<options> to B<ssl>.
32Options already set before are not cleared!
33
34SSL_CTX_clear_options() clears the options set via bitmask in B<options>
35to B<ctx>.
36
37SSL_clear_options() clears the options set via bitmask in B<options> to B<ssl>.
38
39SSL_CTX_get_options() returns the options set for B<ctx>.
40
41SSL_get_options() returns the options set for B<ssl>.
42
43SSL_get_secure_renegotiation_support() indicates whether the peer supports
44secure renegotiation.
45
46=head1 NOTES
47
48The behaviour of the SSL library can be changed by setting several options.
49The options are coded as bitmasks and can be combined by a bitwise B<or>
50operation (|).
51
52SSL_CTX_set_options() and SSL_set_options() affect the (external)
53protocol behaviour of the SSL library. The (internal) behaviour of
54the API can be changed by using the similar
55L<SSL_CTX_set_mode(3)|SSL_CTX_set_mode(3)> and SSL_set_mode() functions.
56
57During a handshake, the option settings of the SSL object are used. When
58a new SSL object is created from a context using SSL_new(), the current
59option setting is copied. Changes to B<ctx> do not affect already created
60SSL objects. SSL_clear() does not affect the settings.
61
62The following B<bug workaround> options are available:
63
64=over 4
65
66=item SSL_OP_MICROSOFT_SESS_ID_BUG
67
68www.microsoft.com - when talking SSLv2, if session-id reuse is
69performed, the session-id passed back in the server-finished message
70is different from the one decided upon.
71
72=item SSL_OP_NETSCAPE_CHALLENGE_BUG
73
74Netscape-Commerce/1.12, when talking SSLv2, accepts a 32 byte
75challenge but then appears to only use 16 bytes when generating the
76encryption keys. Using 16 bytes is ok but it should be ok to use 32.
77According to the SSLv3 spec, one should use 32 bytes for the challenge
78when operating in SSLv2/v3 compatibility mode, but as mentioned above,
79this breaks this server so 16 bytes is the way to go.
80
81=item SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG
82
83As of OpenSSL 0.9.8q and 1.0.0c, this option has no effect.
84
85=item SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG
86
87...
88
89=item SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER
90
91...
92
93=item SSL_OP_SAFARI_ECDHE_ECDSA_BUG
94
95Don't prefer ECDHE-ECDSA ciphers when the client appears to be Safari on OS X.
96OS X 10.8..10.8.3 has broken support for ECDHE-ECDSA ciphers.
97
98=item SSL_OP_SSLEAY_080_CLIENT_DH_BUG
99
100...
101
102=item SSL_OP_TLS_D5_BUG
103
104...
105
106=item SSL_OP_TLS_BLOCK_PADDING_BUG
107
108...
109
110=item SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS
111
112Disables a countermeasure against a SSL 3.0/TLS 1.0 protocol
113vulnerability affecting CBC ciphers, which cannot be handled by some
114broken SSL implementations. This option has no effect for connections
115using other ciphers.
116
117=item SSL_OP_TLSEXT_PADDING
118
119Adds a padding extension to ensure the ClientHello size is never between
120256 and 511 bytes in length. This is needed as a workaround for some
121implementations.
122
123=item SSL_OP_ALL
124
125All of the above bug workarounds.
126
127=back
128
129It is usually safe to use B<SSL_OP_ALL> to enable the bug workaround
130options if compatibility with somewhat broken implementations is
131desired.
132
133The following B<modifying> options are available:
134
135=over 4
136
137=item SSL_OP_TLS_ROLLBACK_BUG
138
139Disable version rollback attack detection.
140
141During the client key exchange, the client must send the same information
142about acceptable SSL/TLS protocol levels as during the first hello. Some
143clients violate this rule by adapting to the server's answer. (Example:
144the client sends a SSLv2 hello and accepts up to SSLv3.1=TLSv1, the server
145only understands up to SSLv3. In this case the client must still use the
146same SSLv3.1=TLSv1 announcement. Some clients step down to SSLv3 with respect
147to the server's answer and violate the version rollback protection.)
148
149=item SSL_OP_SINGLE_DH_USE
150
151Always create a new key when using temporary/ephemeral DH parameters
152(see L<SSL_CTX_set_tmp_dh_callback(3)|SSL_CTX_set_tmp_dh_callback(3)>).
153This option must be used to prevent small subgroup attacks, when
154the DH parameters were not generated using "strong" primes
155(e.g. when using DSA-parameters, see L<dhparam(1)|dhparam(1)>).
156If "strong" primes were used, it is not strictly necessary to generate
157a new DH key during each handshake but it is also recommended.
158B<SSL_OP_SINGLE_DH_USE> should therefore be enabled whenever
159temporary/ephemeral DH parameters are used.
160
161=item SSL_OP_EPHEMERAL_RSA
162
163Always use ephemeral (temporary) RSA key when doing RSA operations
164(see L<SSL_CTX_set_tmp_rsa_callback(3)|SSL_CTX_set_tmp_rsa_callback(3)>).
165According to the specifications this is only done, when a RSA key
166can only be used for signature operations (namely under export ciphers
167with restricted RSA keylength). By setting this option, ephemeral
168RSA keys are always used. This option breaks compatibility with the
169SSL/TLS specifications and may lead to interoperability problems with
170clients and should therefore never be used. Ciphers with EDH (ephemeral
171Diffie-Hellman) key exchange should be used instead.
172
173=item SSL_OP_CIPHER_SERVER_PREFERENCE
174
175When choosing a cipher, use the server's preferences instead of the client
176preferences. When not set, the SSL server will always follow the clients
177preferences. When set, the SSLv3/TLSv1 server will choose following its
178own preferences. Because of the different protocol, for SSLv2 the server
179will send its list of preferences to the client and the client chooses.
180
181=item SSL_OP_NETSCAPE_CA_DN_BUG
182
183If we accept a netscape connection, demand a client cert, have a
184non-self-signed CA which does not have its CA in netscape, and the
185browser has a cert, it will crash/hang. Works for 3.x and 4.xbeta
186
187=item SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG
188
189...
190
191=item SSL_OP_NO_SSLv2
192
193As of OpenBSD 5.6, this option has no effect as SSLv2 support has been removed.
194In previous versions it disabled use of the SSLv2 protocol.
195
196=item SSL_OP_NO_SSLv3
197
198Do not use the SSLv3 protocol.
199
200=item SSL_OP_NO_TLSv1
201
202Do not use the TLSv1.0 protocol.
203
204=item SSL_OP_NO_TLSv1_1
205
206Do not use the TLSv1.1 protocol.
207
208=item SSL_OP_NO_TLSv1_2
209
210Do not use the TLSv1.2 protocol.
211
212=item SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION
213
214When performing renegotiation as a server, always start a new session
215(i.e., session resumption requests are only accepted in the initial
216handshake). This option is not needed for clients.
217
218=item SSL_OP_NO_TICKET
219
220Normally clients and servers will, where possible, transparently make use
221of RFC4507bis tickets for stateless session resumption.
222
223If this option is set this functionality is disabled and tickets will
224not be used by clients or servers.
225
226=item SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION
227
228As of OpenBSD 5.6, this option has no effect.
229In previous versions it allowed legacy insecure renegotiation between
230OpenSSL and unpatched clients or servers.
231See the B<SECURE RENEGOTIATION> section for more details.
232
233=item SSL_OP_LEGACY_SERVER_CONNECT
234
235Allow legacy insecure renegotiation between OpenSSL and unpatched servers
236B<only>: this option is currently set by default. See the
237B<SECURE RENEGOTIATION> section for more details.
238
239=back
240
241=head1 SECURE RENEGOTIATION
242
243OpenSSL 0.9.8m and later always attempts to use secure renegotiation as
244described in RFC5746. This counters the prefix attack described in
245CVE-2009-3555 and elsewhere.
246
247The deprecated and highly broken SSLv2 protocol does not support
248renegotiation at all: its use is B<strongly> discouraged.
249
250This attack has far reaching consequences which application writers should be
251aware of. In the description below an implementation supporting secure
252renegotiation is referred to as I<patched>. A server not supporting secure
253renegotiation is referred to as I<unpatched>.
254
255The following sections describe the operations permitted by OpenSSL's secure
256renegotiation implementation.
257
258=head2 Patched client and server
259
260Connections and renegotiation are always permitted by OpenSSL implementations.
261
262=head2 Unpatched client and patched OpenSSL server
263
264The initial connection succeeds but client renegotiation is denied by the
265server with a B<no_renegotiation> warning alert if TLS v1.0 is used or a fatal
266B<handshake_failure> alert in SSL v3.0.
267
268If the patched OpenSSL server attempts to renegotiate a fatal
269B<handshake_failure> alert is sent. This is because the server code may be
270unaware of the unpatched nature of the client.
271
272B<NB:> a bug in OpenSSL clients earlier than 0.9.8m (all of which are
273unpatched) will result in the connection hanging if it receives a
274B<no_renegotiation> alert. OpenSSL versions 0.9.8m and later will regard
275a B<no_renegotiation> alert as fatal and respond with a fatal
276B<handshake_failure> alert. This is because the OpenSSL API currently has
277no provision to indicate to an application that a renegotiation attempt
278was refused.
279
280=head2 Patched OpenSSL client and unpatched server.
281
282If the option B<SSL_OP_LEGACY_SERVER_CONNECT> is set then initial connections
283and renegotiation between patched OpenSSL clients and unpatched servers
284succeeds. If neither option is set then initial connections to unpatched
285servers will fail.
286
287The option B<SSL_OP_LEGACY_SERVER_CONNECT> is currently set by default even
288though it has security implications: otherwise it would be impossible to
289connect to unpatched servers (i.e. all of them initially) and this is clearly
290not acceptable. Renegotiation is permitted because this does not add any
291additional security issues: during an attack clients do not see any
292renegotiations anyway.
293
294As more servers become patched the option B<SSL_OP_LEGACY_SERVER_CONNECT> will
295B<not> be set by default in a future version of OpenSSL.
296
297OpenSSL client applications wishing to ensure they can connect to unpatched
298servers should always B<set> B<SSL_OP_LEGACY_SERVER_CONNECT>
299
300OpenSSL client applications that want to ensure they can B<not> connect to
301unpatched servers (and thus avoid any security issues) should always B<clear>
302B<SSL_OP_LEGACY_SERVER_CONNECT> using SSL_CTX_clear_options() or
303SSL_clear_options().
304
305=head1 RETURN VALUES
306
307SSL_CTX_set_options() and SSL_set_options() return the new options bitmask
308after adding B<options>.
309
310SSL_CTX_clear_options() and SSL_clear_options() return the new options bitmask
311after clearing B<options>.
312
313SSL_CTX_get_options() and SSL_get_options() return the current bitmask.
314
315SSL_get_secure_renegotiation_support() returns 1 is the peer supports
316secure renegotiation and 0 if it does not.
317
318=head1 SEE ALSO
319
320L<ssl(3)|ssl(3)>, L<SSL_new(3)|SSL_new(3)>, L<SSL_clear(3)|SSL_clear(3)>,
321L<SSL_CTX_set_tmp_dh_callback(3)|SSL_CTX_set_tmp_dh_callback(3)>,
322L<SSL_CTX_set_tmp_rsa_callback(3)|SSL_CTX_set_tmp_rsa_callback(3)>,
323L<dhparam(1)|dhparam(1)>
324
325=head1 HISTORY
326
327B<SSL_OP_CIPHER_SERVER_PREFERENCE> and
328B<SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION> have been added in
329OpenSSL 0.9.7.
330
331B<SSL_OP_TLS_ROLLBACK_BUG> has been added in OpenSSL 0.9.6 and was
332automatically enabled with B<SSL_OP_ALL>. As of 0.9.7, it is no longer included
333in B<SSL_OP_ALL> and must be explicitly set.
334
335B<SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS> has been added in OpenSSL 0.9.6e.
336Versions up to OpenSSL 0.9.6c do not include the countermeasure that
337can be disabled with this option (in OpenSSL 0.9.6d, it was always
338enabled).
339
340SSL_CTX_clear_options() and SSL_clear_options() were first added in OpenSSL
3410.9.8m.
342
343B<SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION>, B<SSL_OP_LEGACY_SERVER_CONNECT>
344and the function SSL_get_secure_renegotiation_support() were first added in
345OpenSSL 0.9.8m.
346
347B<SSL_OP_NO_SSLv2> and B<SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION>
348were changed to have no effect in OpenBSD 5.6.
349
350=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_psk_client_callback.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_psk_client_callback.3
new file mode 100644
index 0000000000..9bd5c9c545
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_set_psk_client_callback.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_psk_client_callback.pod
deleted file mode 100644
index 7a85ba16d2..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_psk_client_callback.pod
+++ /dev/null
@@ -1,82 +0,0 @@
1=pod
2
3=begin comment
4
5Copyright 2005 Nokia. All rights reserved.
6
7The portions of the attached software ("Contribution") is developed by
8Nokia Corporation and is licensed pursuant to the OpenSSL open source
9license.
10
11The Contribution, originally written by Mika Kousa and Pasi Eronen of
12Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites
13support (see RFC 4279) to OpenSSL.
14
15No patent licenses or other rights except those expressly stated in
16the OpenSSL open source license shall be deemed granted or received
17expressly, by implication, estoppel, or otherwise.
18
19No assurances are provided by Nokia that the Contribution does not
20infringe the patent or other intellectual property rights of any third
21party or that the license provides you with all the necessary rights
22to make use of the Contribution.
23
24THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN
25ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA
26SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY
27OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR
28OTHERWISE.
29
30=end comment
31
32=head1 NAME
33
34SSL_CTX_set_psk_client_callback, SSL_set_psk_client_callback - set PSK client
35callback
36
37=head1 SYNOPSIS
38
39 #include <openssl/ssl.h>
40
41 void SSL_CTX_set_psk_client_callback(SSL_CTX *ctx,
42 unsigned int (*callback)(SSL *ssl, const char *hint,
43 char *identity, unsigned int max_identity_len,
44 unsigned char *psk, unsigned int max_psk_len));
45 void SSL_set_psk_client_callback(SSL *ssl,
46 unsigned int (*callback)(SSL *ssl, const char *hint,
47 char *identity, unsigned int max_identity_len,
48 unsigned char *psk, unsigned int max_psk_len));
49
50
51=head1 DESCRIPTION
52
53A client application must provide a callback function which is called
54when the client is sending the ClientKeyExchange message to the server.
55
56The purpose of the callback function is to select the PSK identity and
57the pre-shared key to use during the connection setup phase.
58
59The callback is set using functions SSL_CTX_set_psk_client_callback()
60or SSL_set_psk_client_callback(). The callback function is given the
61connection in parameter B<ssl>, a B<NULL>-terminated PSK identity hint
62sent by the server in parameter B<hint>, a buffer B<identity> of
63length B<max_identity_len> bytes where the the resulting
64B<NULL>-terminated identity is to be stored, and a buffer B<psk> of
65length B<max_psk_len> bytes where the resulting pre-shared key is to
66be stored.
67
68=head1 NOTES
69
70Note that parameter B<hint> given to the callback may be B<NULL>.
71
72=head1 RETURN VALUES
73
74Return values from the client callback are interpreted as follows:
75
76On success (callback found a PSK identity and a pre-shared key to use)
77the length (> 0) of B<psk> in bytes is returned.
78
79Otherwise or on errors callback should return 0. In this case
80the connection setup fails.
81
82=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_quiet_shutdown.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_quiet_shutdown.3
new file mode 100644
index 0000000000..91e17350f9
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_set_quiet_shutdown.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_quiet_shutdown.pod
deleted file mode 100644
index 32604dbd1a..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_quiet_shutdown.pod
+++ /dev/null
@@ -1,64 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_quiet_shutdown, SSL_CTX_get_quiet_shutdown, SSL_set_quiet_shutdown,
6SSL_get_quiet_shutdown - manipulate shutdown behaviour
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 void SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx, int mode);
13 int SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx);
14
15 void SSL_set_quiet_shutdown(SSL *ssl, int mode);
16 int SSL_get_quiet_shutdown(const SSL *ssl);
17
18=head1 DESCRIPTION
19
20SSL_CTX_set_quiet_shutdown() sets the "quiet shutdown" flag for B<ctx> to be
21B<mode>. SSL objects created from B<ctx> inherit the B<mode> valid at the time
22L<SSL_new(3)|SSL_new(3)> is called. B<mode> may be 0 or 1.
23
24SSL_CTX_get_quiet_shutdown() returns the "quiet shutdown" setting of B<ctx>.
25
26SSL_set_quiet_shutdown() sets the "quiet shutdown" flag for B<ssl> to be
27B<mode>. The setting stays valid until B<ssl> is removed with
28L<SSL_free(3)|SSL_free(3)> or SSL_set_quiet_shutdown() is called again.
29It is not changed when L<SSL_clear(3)|SSL_clear(3)> is called.
30B<mode> may be 0 or 1.
31
32SSL_get_quiet_shutdown() returns the "quiet shutdown" setting of B<ssl>.
33
34=head1 NOTES
35
36Normally when a SSL connection is finished, the parties must send out
37"close notify" alert messages using L<SSL_shutdown(3)|SSL_shutdown(3)>
38for a clean shutdown.
39
40When setting the "quiet shutdown" flag to 1, L<SSL_shutdown(3)|SSL_shutdown(3)>
41will set the internal flags to SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN.
42(L<SSL_shutdown(3)|SSL_shutdown(3)> then behaves like
43L<SSL_set_shutdown(3)|SSL_set_shutdown(3)> called with
44SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN.)
45The session is thus considered to be shutdown, but no "close notify" alert
46is sent to the peer. This behaviour violates the TLS standard.
47
48The default is normal shutdown behaviour as described by the TLS standard.
49
50=head1 RETURN VALUES
51
52SSL_CTX_set_quiet_shutdown() and SSL_set_quiet_shutdown() do not return
53diagnostic information.
54
55SSL_CTX_get_quiet_shutdown() and SSL_get_quiet_shutdown return the current
56setting.
57
58=head1 SEE ALSO
59
60L<ssl(3)|ssl(3)>, L<SSL_shutdown(3)|SSL_shutdown(3)>,
61L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>, L<SSL_new(3)|SSL_new(3)>,
62L<SSL_clear(3)|SSL_clear(3)>, L<SSL_free(3)|SSL_free(3)>
63
64=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_session_cache_mode.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_session_cache_mode.3
new file mode 100644
index 0000000000..e7ebe2190e
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_set_session_cache_mode.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_session_cache_mode.pod
deleted file mode 100644
index fe8ec09aee..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_session_cache_mode.pod
+++ /dev/null
@@ -1,138 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_session_cache_mode, SSL_CTX_get_session_cache_mode - enable/disable
6session caching
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 long SSL_CTX_set_session_cache_mode(SSL_CTX ctx, long mode);
13 long SSL_CTX_get_session_cache_mode(SSL_CTX ctx);
14
15=head1 DESCRIPTION
16
17SSL_CTX_set_session_cache_mode() enables/disables session caching
18by setting the operational mode for B<ctx> to <mode>.
19
20SSL_CTX_get_session_cache_mode() returns the currently used cache mode.
21
22=head1 NOTES
23
24The OpenSSL library can store/retrieve SSL/TLS sessions for later reuse.
25The sessions can be held in memory for each B<ctx>, if more than one
26SSL_CTX object is being maintained, the sessions are unique for each SSL_CTX
27object.
28
29In order to reuse a session, a client must send the session's id to the
30server. It can only send exactly one id. The server then either
31agrees to reuse the session or it starts a full handshake (to create a new
32session).
33
34A server will lookup up the session in its internal session storage. If the
35session is not found in internal storage or lookups for the internal storage
36have been deactivated (SSL_SESS_CACHE_NO_INTERNAL_LOOKUP), the server will try
37the external storage if available.
38
39Since a client may try to reuse a session intended for use in a different
40context, the session id context must be set by the server (see
41L<SSL_CTX_set_session_id_context(3)|SSL_CTX_set_session_id_context(3)>).
42
43The following session cache modes and modifiers are available:
44
45=over 4
46
47=item SSL_SESS_CACHE_OFF
48
49No session caching for client or server takes place.
50
51=item SSL_SESS_CACHE_CLIENT
52
53Client sessions are added to the session cache. As there is no reliable way
54for the OpenSSL library to know whether a session should be reused or which
55session to choose (due to the abstract BIO layer the SSL engine does not
56have details about the connection), the application must select the session
57to be reused by using the L<SSL_set_session(3)|SSL_set_session(3)>
58function. This option is not activated by default.
59
60=item SSL_SESS_CACHE_SERVER
61
62Server sessions are added to the session cache. When a client proposes a
63session to be reused, the server looks for the corresponding session in (first)
64the internal session cache (unless SSL_SESS_CACHE_NO_INTERNAL_LOOKUP is set),
65then (second) in the external cache if available. If the session is found, the
66server will try to reuse the session. This is the default.
67
68=item SSL_SESS_CACHE_BOTH
69
70Enable both SSL_SESS_CACHE_CLIENT and SSL_SESS_CACHE_SERVER at the same time.
71
72=item SSL_SESS_CACHE_NO_AUTO_CLEAR
73
74Normally the session cache is checked for expired sessions every
75255 connections using the
76L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)> function. Since
77this may lead to a delay which cannot be controlled, the automatic
78flushing may be disabled and
79L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)> can be called
80explicitly by the application.
81
82=item SSL_SESS_CACHE_NO_INTERNAL_LOOKUP
83
84By setting this flag, session-resume operations in an SSL/TLS server will not
85automatically look up sessions in the internal cache, even if sessions are
86automatically stored there. If external session caching callbacks are in use,
87this flag guarantees that all lookups are directed to the external cache.
88As automatic lookup only applies for SSL/TLS servers, the flag has no effect on
89clients.
90
91=item SSL_SESS_CACHE_NO_INTERNAL_STORE
92
93Depending on the presence of SSL_SESS_CACHE_CLIENT and/or SSL_SESS_CACHE_SERVER,
94sessions negotiated in an SSL/TLS handshake may be cached for possible reuse.
95Normally a new session is added to the internal cache as well as any external
96session caching (callback) that is configured for the SSL_CTX. This flag will
97prevent sessions being stored in the internal cache (though the application can
98add them manually using L<SSL_CTX_add_session(3)|SSL_CTX_add_session(3)>). Note:
99in any SSL/TLS servers where external caching is configured, any successful
100session lookups in the external cache (ie. for session-resume requests) would
101normally be copied into the local cache before processing continues - this flag
102prevents these additions to the internal cache as well.
103
104=item SSL_SESS_CACHE_NO_INTERNAL
105
106Enable both SSL_SESS_CACHE_NO_INTERNAL_LOOKUP and
107SSL_SESS_CACHE_NO_INTERNAL_STORE at the same time.
108
109
110=back
111
112The default mode is SSL_SESS_CACHE_SERVER.
113
114=head1 RETURN VALUES
115
116SSL_CTX_set_session_cache_mode() returns the previously set cache mode.
117
118SSL_CTX_get_session_cache_mode() returns the currently set cache mode.
119
120
121=head1 SEE ALSO
122
123L<ssl(3)|ssl(3)>, L<SSL_set_session(3)|SSL_set_session(3)>,
124L<SSL_session_reused(3)|SSL_session_reused(3)>,
125L<SSL_CTX_add_session(3)|SSL_CTX_add_session(3)>,
126L<SSL_CTX_sess_number(3)|SSL_CTX_sess_number(3)>,
127L<SSL_CTX_sess_set_cache_size(3)|SSL_CTX_sess_set_cache_size(3)>,
128L<SSL_CTX_sess_set_get_cb(3)|SSL_CTX_sess_set_get_cb(3)>,
129L<SSL_CTX_set_session_id_context(3)|SSL_CTX_set_session_id_context(3)>,
130L<SSL_CTX_set_timeout(3)|SSL_CTX_set_timeout(3)>,
131L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)>
132
133=head1 HISTORY
134
135SSL_SESS_CACHE_NO_INTERNAL_STORE and SSL_SESS_CACHE_NO_INTERNAL
136were introduced in OpenSSL 0.9.6h.
137
138=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_session_id_context.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_session_id_context.3
new file mode 100644
index 0000000000..0411c687a4
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_set_session_id_context.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_session_id_context.pod
deleted file mode 100644
index 2b1ce18ed9..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_session_id_context.pod
+++ /dev/null
@@ -1,84 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_session_id_context, SSL_set_session_id_context - set context within
6which session can be reused (server side only)
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 int SSL_CTX_set_session_id_context(SSL_CTX *ctx, const unsigned char *sid_ctx,
13 unsigned int sid_ctx_len);
14 int SSL_set_session_id_context(SSL *ssl, const unsigned char *sid_ctx,
15 unsigned int sid_ctx_len);
16
17=head1 DESCRIPTION
18
19SSL_CTX_set_session_id_context() sets the context B<sid_ctx> of length
20B<sid_ctx_len> within which a session can be reused for the B<ctx> object.
21
22SSL_set_session_id_context() sets the context B<sid_ctx> of length
23B<sid_ctx_len> within which a session can be reused for the B<ssl> object.
24
25=head1 NOTES
26
27Sessions are generated within a certain context. When exporting/importing
28sessions with B<i2d_SSL_SESSION>/B<d2i_SSL_SESSION> it would be possible,
29to re-import a session generated from another context (e.g. another
30application), which might lead to malfunctions. Therefore each application
31must set its own session id context B<sid_ctx> which is used to distinguish
32the contexts and is stored in exported sessions. The B<sid_ctx> can be
33any kind of binary data with a given length, it is therefore possible
34to use e.g. the name of the application and/or the hostname and/or service
35name ...
36
37The session id context becomes part of the session. The session id context
38is set by the SSL/TLS server. The SSL_CTX_set_session_id_context() and
39SSL_set_session_id_context() functions are therefore only useful on the
40server side.
41
42OpenSSL clients will check the session id context returned by the server
43when reusing a session.
44
45The maximum length of the B<sid_ctx> is limited to
46B<SSL_MAX_SSL_SESSION_ID_LENGTH>.
47
48=head1 WARNINGS
49
50If the session id context is not set on an SSL/TLS server and client
51certificates are used, stored sessions
52will not be reused but a fatal error will be flagged and the handshake
53will fail.
54
55If a server returns a different session id context to an OpenSSL client
56when reusing a session, an error will be flagged and the handshake will
57fail. OpenSSL servers will always return the correct session id context,
58as an OpenSSL server checks the session id context itself before reusing
59a session as described above.
60
61=head1 RETURN VALUES
62
63SSL_CTX_set_session_id_context() and SSL_set_session_id_context()
64return the following values:
65
66=over 4
67
68=item C<0>
69
70The length B<sid_ctx_len> of the session id context B<sid_ctx> exceeded
71the maximum allowed length of B<SSL_MAX_SSL_SESSION_ID_LENGTH>. The error
72is logged to the error stack.
73
74=item C<1>
75
76The operation succeeded.
77
78=back
79
80=head1 SEE ALSO
81
82L<ssl(3)|ssl(3)>
83
84=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_ssl_version.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_ssl_version.3
new file mode 100644
index 0000000000..f3753dac20
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_set_ssl_version.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_ssl_version.pod
deleted file mode 100644
index 5ea8f0d4f6..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_ssl_version.pod
+++ /dev/null
@@ -1,61 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_ssl_version, SSL_set_ssl_method, SSL_get_ssl_method
6- choose a new TLS/SSL method
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 int SSL_CTX_set_ssl_version(SSL_CTX *ctx, const SSL_METHOD *method);
13 int SSL_set_ssl_method(SSL *s, const SSL_METHOD *method);
14 const SSL_METHOD *SSL_get_ssl_method(SSL *ssl);
15
16=head1 DESCRIPTION
17
18SSL_CTX_set_ssl_version() sets a new default TLS/SSL B<method> for SSL objects
19newly created from this B<ctx>. SSL objects already created with
20L<SSL_new(3)|SSL_new(3)> are not affected, except when
21L<SSL_clear(3)|SSL_clear(3)> is being called.
22
23SSL_set_ssl_method() sets a new TLS/SSL B<method> for a particular B<ssl>
24object. It may be reset, when SSL_clear() is called.
25
26SSL_get_ssl_method() returns a function pointer to the TLS/SSL method
27set in B<ssl>.
28
29=head1 NOTES
30
31The available B<method> choices are described in
32L<SSL_CTX_new(3)|SSL_CTX_new(3)>.
33
34When L<SSL_clear(3)|SSL_clear(3)> is called and no session is connected to
35an SSL object, the method of the SSL object is reset to the method currently
36set in the corresponding SSL_CTX object.
37
38=head1 RETURN VALUES
39
40The following return values can occur for SSL_CTX_set_ssl_version()
41and SSL_set_ssl_method():
42
43=over 4
44
45=item C<0>
46
47The new choice failed, check the error stack to find out the reason.
48
49=item C<1>
50
51The operation succeeded.
52
53=back
54
55=head1 SEE ALSO
56
57L<SSL_CTX_new(3)|SSL_CTX_new(3)>, L<SSL_new(3)|SSL_new(3)>,
58L<SSL_clear(3)|SSL_clear(3)>, L<ssl(3)|ssl(3)>,
59L<SSL_set_connect_state(3)|SSL_set_connect_state(3)>
60
61=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_timeout.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_timeout.3
new file mode 100644
index 0000000000..c8aaee24e2
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_set_timeout.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_timeout.pod
deleted file mode 100644
index 4422373fea..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_timeout.pod
+++ /dev/null
@@ -1,60 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_timeout, SSL_CTX_get_timeout - manipulate timeout values for
6session caching
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 long SSL_CTX_set_timeout(SSL_CTX *ctx, long t);
13 long SSL_CTX_get_timeout(SSL_CTX *ctx);
14
15=head1 DESCRIPTION
16
17SSL_CTX_set_timeout() sets the timeout for newly created sessions for
18B<ctx> to B<t>. The timeout value B<t> must be given in seconds.
19
20SSL_CTX_get_timeout() returns the currently set timeout value for B<ctx>.
21
22=head1 NOTES
23
24Whenever a new session is created, it is assigned a maximum lifetime. This
25lifetime is specified by storing the creation time of the session and the
26timeout value valid at this time. If the actual time is later than creation
27time plus timeout, the session is not reused.
28
29Due to this realization, all sessions behave according to the timeout value
30valid at the time of the session negotiation. Changes of the timeout value
31do not affect already established sessions.
32
33The expiration time of a single session can be modified using the
34L<SSL_SESSION_get_time(3)|SSL_SESSION_get_time(3)> family of functions.
35
36Expired sessions are removed from the internal session cache, whenever
37L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)> is called, either
38directly by the application or automatically (see
39L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>)
40
41The default value for session timeout is decided on a per protocol
42basis, see L<SSL_get_default_timeout(3)|SSL_get_default_timeout(3)>.
43All currently supported protocols have the same default timeout value
44of 300 seconds.
45
46=head1 RETURN VALUES
47
48SSL_CTX_set_timeout() returns the previously set timeout value.
49
50SSL_CTX_get_timeout() returns the currently set timeout value.
51
52=head1 SEE ALSO
53
54L<ssl(3)|ssl(3)>,
55L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>,
56L<SSL_SESSION_get_time(3)|SSL_SESSION_get_time(3)>,
57L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)>,
58L<SSL_get_default_timeout(3)|SSL_get_default_timeout(3)>
59
60=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_tmp_dh_callback.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_tmp_dh_callback.3
new file mode 100644
index 0000000000..f28d083f45
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_set_tmp_dh_callback.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_tmp_dh_callback.pod
deleted file mode 100644
index 0fda967814..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_tmp_dh_callback.pod
+++ /dev/null
@@ -1,169 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_tmp_dh_callback, SSL_CTX_set_tmp_dh, SSL_set_tmp_dh_callback,
6SSL_set_tmp_dh - handle DH keys for ephemeral key exchange
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,
13 DH *(*tmp_dh_callback)(SSL *ssl, int is_export, int keylength));
14 long SSL_CTX_set_tmp_dh(SSL_CTX *ctx, DH *dh);
15
16 void SSL_set_tmp_dh_callback(SSL *ssl,
17 DH *(*tmp_dh_callback)(SSL *ssl, int is_export, int keylength));
18 long SSL_set_tmp_dh(SSL *ssl, DH *dh)
19
20=head1 DESCRIPTION
21
22SSL_CTX_set_tmp_dh_callback() sets the callback function for B<ctx> to be
23used when a DH parameters are required to B<tmp_dh_callback>.
24The callback is inherited by all B<ssl> objects created from B<ctx>.
25
26SSL_CTX_set_tmp_dh() sets DH parameters to be used to be B<dh>.
27The key is inherited by all B<ssl> objects created from B<ctx>.
28
29SSL_set_tmp_dh_callback() sets the callback only for B<ssl>.
30
31SSL_set_tmp_dh() sets the parameters only for B<ssl>.
32
33These functions apply to SSL/TLS servers only.
34
35=head1 NOTES
36
37When using a cipher with RSA authentication, an ephemeral DH key exchange
38can take place. Ciphers with DSA keys always use ephemeral DH keys as well.
39In these cases, the session data are negotiated using the
40ephemeral/temporary DH key and the key supplied and certified
41by the certificate chain is only used for signing.
42Anonymous ciphers (without a permanent server key) also use ephemeral DH keys.
43
44Using ephemeral DH key exchange yields forward secrecy, as the connection
45can only be decrypted, when the DH key is known. By generating a temporary
46DH key inside the server application that is lost when the application
47is left, it becomes impossible for an attacker to decrypt past sessions,
48even if he gets hold of the normal (certified) key, as this key was
49only used for signing.
50
51In order to perform a DH key exchange the server must use a DH group
52(DH parameters) and generate a DH key. The server will always generate a new
53DH key during the negotiation, when the DH parameters are supplied via
54callback and/or when the SSL_OP_SINGLE_DH_USE option of
55L<SSL_CTX_set_options(3)|SSL_CTX_set_options(3)> is set. It will
56immediately create a DH key, when DH parameters are supplied via
57SSL_CTX_set_tmp_dh() and SSL_OP_SINGLE_DH_USE is not set. In this case,
58it may happen that a key is generated on initialization without later
59being needed, while on the other hand the computer time during the
60negotiation is being saved.
61
62If "strong" primes were used to generate the DH parameters, it is not strictly
63necessary to generate a new key for each handshake but it does improve forward
64secrecy. If it is not assured, that "strong" primes were used (see especially
65the section about DSA parameters below), SSL_OP_SINGLE_DH_USE must be used
66in order to prevent small subgroup attacks. Always using SSL_OP_SINGLE_DH_USE
67has an impact on the computer time needed during negotiation, but it is not
68very large, so application authors/users should consider to always enable
69this option.
70
71As generating DH parameters is extremely time consuming, an application
72should not generate the parameters on the fly but supply the parameters.
73DH parameters can be reused, as the actual key is newly generated during
74the negotiation. The risk in reusing DH parameters is that an attacker
75may specialize on a very often used DH group. Applications should therefore
76generate their own DH parameters during the installation process using the
77openssl L<dhparam(1)|dhparam(1)> application. In order to reduce the computer
78time needed for this generation, it is possible to use DSA parameters
79instead (see L<dhparam(1)|dhparam(1)>), but in this case SSL_OP_SINGLE_DH_USE
80is mandatory.
81
82Application authors may compile in DH parameters. Files dh512.pem,
83dh1024.pem, dh2048.pem, and dh4096.pem in the 'apps' directory of current
84version of the OpenSSL distribution contain the 'SKIP' DH parameters,
85which use safe primes and were generated verifiably pseudo-randomly.
86These files can be converted into C code using the B<-C> option of the
87L<dhparam(1)|dhparam(1)> application.
88Authors may also generate their own set of parameters using
89L<dhparam(1)|dhparam(1)>, but a user may not be sure how the parameters were
90generated. The generation of DH parameters during installation is therefore
91recommended.
92
93An application may either directly specify the DH parameters or
94can supply the DH parameters via a callback function. The callback approach
95has the advantage, that the callback may supply DH parameters for different
96key lengths.
97
98The B<tmp_dh_callback> is called with the B<keylength> needed and
99the B<is_export> information. The B<is_export> flag is set, when the
100ephemeral DH key exchange is performed with an export cipher.
101
102=head1 EXAMPLES
103
104Handle DH parameters for key lengths of 512 and 1024 bits. (Error handling
105partly left out.)
106
107 ...
108 /* Set up ephemeral DH stuff */
109 DH *dh_512 = NULL;
110 DH *dh_1024 = NULL;
111 FILE *paramfile;
112
113 ...
114 /* "openssl dhparam -out dh_param_512.pem -2 512" */
115 paramfile = fopen("dh_param_512.pem", "r");
116 if (paramfile) {
117 dh_512 = PEM_read_DHparams(paramfile, NULL, NULL, NULL);
118 fclose(paramfile);
119 }
120 /* "openssl dhparam -out dh_param_1024.pem -2 1024" */
121 paramfile = fopen("dh_param_1024.pem", "r");
122 if (paramfile) {
123 dh_1024 = PEM_read_DHparams(paramfile, NULL, NULL, NULL);
124 fclose(paramfile);
125 }
126 ...
127
128 /* "openssl dhparam -C -2 512" etc... */
129 DH *get_dh512() { ... }
130 DH *get_dh1024() { ... }
131
132 DH *tmp_dh_callback(SSL *s, int is_export, int keylength)
133 {
134 DH *dh_tmp=NULL;
135
136 switch (keylength) {
137 case 512:
138 if (!dh_512)
139 dh_512 = get_dh512();
140 dh_tmp = dh_512;
141 break;
142 case 1024:
143 if (!dh_1024)
144 dh_1024 = get_dh1024();
145 dh_tmp = dh_1024;
146 break;
147 default:
148 /* Generating a key on the fly is very costly, so use what is there */
149 setup_dh_parameters_like_above();
150 }
151 return(dh_tmp);
152 }
153
154=head1 RETURN VALUES
155
156SSL_CTX_set_tmp_dh_callback() and SSL_set_tmp_dh_callback() do not return
157diagnostic output.
158
159SSL_CTX_set_tmp_dh() and SSL_set_tmp_dh() do return 1 on success and 0
160on failure. Check the error queue to find out the reason of failure.
161
162=head1 SEE ALSO
163
164L<ssl(3)|ssl(3)>, L<SSL_CTX_set_cipher_list(3)|SSL_CTX_set_cipher_list(3)>,
165L<SSL_CTX_set_tmp_rsa_callback(3)|SSL_CTX_set_tmp_rsa_callback(3)>,
166L<SSL_CTX_set_options(3)|SSL_CTX_set_options(3)>,
167L<ciphers(1)|ciphers(1)>, L<dhparam(1)|dhparam(1)>
168
169=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_tmp_rsa_callback.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_tmp_rsa_callback.3
new file mode 100644
index 0000000000..55b3aaafed
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_set_tmp_rsa_callback.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_tmp_rsa_callback.pod
deleted file mode 100644
index 003dfdb73e..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_tmp_rsa_callback.pod
+++ /dev/null
@@ -1,168 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_tmp_rsa_callback, SSL_CTX_set_tmp_rsa, SSL_CTX_need_tmp_rsa,
6SSL_set_tmp_rsa_callback, SSL_set_tmp_rsa, SSL_need_tmp_rsa - handle RSA keys
7for ephemeral key exchange
8
9=head1 SYNOPSIS
10
11 #include <openssl/ssl.h>
12
13 void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,
14 RSA *(*tmp_rsa_callback)(SSL *ssl, int is_export, int keylength));
15 long SSL_CTX_set_tmp_rsa(SSL_CTX *ctx, RSA *rsa);
16 long SSL_CTX_need_tmp_rsa(SSL_CTX *ctx);
17
18 void SSL_set_tmp_rsa_callback(SSL_CTX *ctx,
19 RSA *(*tmp_rsa_callback)(SSL *ssl, int is_export, int keylength));
20 long SSL_set_tmp_rsa(SSL *ssl, RSA *rsa)
21 long SSL_need_tmp_rsa(SSL *ssl)
22
23 RSA *(*tmp_rsa_callback)(SSL *ssl, int is_export, int keylength);
24
25=head1 DESCRIPTION
26
27SSL_CTX_set_tmp_rsa_callback() sets the callback function for B<ctx> to be
28used when a temporary/ephemeral RSA key is required to B<tmp_rsa_callback>.
29The callback is inherited by all SSL objects newly created from B<ctx>
30with <SSL_new(3)|SSL_new(3)>. Already created SSL objects are not affected.
31
32SSL_CTX_set_tmp_rsa() sets the temporary/ephemeral RSA key to be used to be
33B<rsa>. The key is inherited by all SSL objects newly created from B<ctx>
34with <SSL_new(3)|SSL_new(3)>. Already created SSL objects are not affected.
35
36SSL_CTX_need_tmp_rsa() returns 1, if a temporary/ephemeral RSA key is needed
37for RSA-based strength-limited 'exportable' ciphersuites because a RSA key
38with a keysize larger than 512 bits is installed.
39
40SSL_set_tmp_rsa_callback() sets the callback only for B<ssl>.
41
42SSL_set_tmp_rsa() sets the key only for B<ssl>.
43
44SSL_need_tmp_rsa() returns 1, if a temporary/ephemeral RSA key is needed,
45for RSA-based strength-limited 'exportable' ciphersuites because a RSA key
46with a keysize larger than 512 bits is installed.
47
48These functions apply to SSL/TLS servers only.
49
50=head1 NOTES
51
52When using a cipher with RSA authentication, an ephemeral RSA key exchange
53can take place. In this case the session data are negotiated using the
54ephemeral/temporary RSA key and the RSA key supplied and certified
55by the certificate chain is only used for signing.
56
57Under previous export restrictions, ciphers with RSA keys shorter (512 bits)
58than the usual key length of 1024 bits were created. To use these ciphers
59with RSA keys of usual length, an ephemeral key exchange must be performed,
60as the normal (certified) key cannot be directly used.
61
62Using ephemeral RSA key exchange yields forward secrecy, as the connection
63can only be decrypted, when the RSA key is known. By generating a temporary
64RSA key inside the server application that is lost when the application
65is left, it becomes impossible for an attacker to decrypt past sessions,
66even if he gets hold of the normal (certified) RSA key, as this key was
67used for signing only. The downside is that creating a RSA key is
68computationally expensive.
69
70Additionally, the use of ephemeral RSA key exchange is only allowed in
71the TLS standard, when the RSA key can be used for signing only, that is
72for export ciphers. Using ephemeral RSA key exchange for other purposes
73violates the standard and can break interoperability with clients.
74It is therefore strongly recommended to not use ephemeral RSA key
75exchange and use EDH (Ephemeral Diffie-Hellman) key exchange instead
76in order to achieve forward secrecy (see
77L<SSL_CTX_set_tmp_dh_callback(3)|SSL_CTX_set_tmp_dh_callback(3)>).
78
79On OpenSSL servers ephemeral RSA key exchange is therefore disabled by default
80and must be explicitly enabled using the SSL_OP_EPHEMERAL_RSA option of
81L<SSL_CTX_set_options(3)|SSL_CTX_set_options(3)>, violating the TLS/SSL
82standard. When ephemeral RSA key exchange is required for export ciphers,
83it will automatically be used without this option!
84
85An application may either directly specify the key or can supply the key via
86a callback function. The callback approach has the advantage, that the
87callback may generate the key only in case it is actually needed. As the
88generation of a RSA key is however costly, it will lead to a significant
89delay in the handshake procedure. Another advantage of the callback function
90is that it can supply keys of different size (e.g. for SSL_OP_EPHEMERAL_RSA
91usage) while the explicit setting of the key is only useful for key size of
92512 bits to satisfy the export restricted ciphers and does give away key length
93if a longer key would be allowed.
94
95The B<tmp_rsa_callback> is called with the B<keylength> needed and
96the B<is_export> information. The B<is_export> flag is set, when the
97ephemeral RSA key exchange is performed with an export cipher.
98
99=head1 EXAMPLES
100
101Generate temporary RSA keys to prepare ephemeral RSA key exchange. As the
102generation of a RSA key costs a lot of computer time, they saved for later
103reuse. For demonstration purposes, two keys for 512 bits and 1024 bits
104respectively are generated.
105
106 ...
107 /* Set up ephemeral RSA stuff */
108 RSA *rsa_512 = NULL;
109 RSA *rsa_1024 = NULL;
110
111 rsa_512 = RSA_generate_key(512,RSA_F4,NULL,NULL);
112 if (rsa_512 == NULL)
113 evaluate_error_queue();
114
115 rsa_1024 = RSA_generate_key(1024,RSA_F4,NULL,NULL);
116 if (rsa_1024 == NULL)
117 evaluate_error_queue();
118
119 ...
120
121 RSA *tmp_rsa_callback(SSL *s, int is_export, int keylength)
122 {
123 RSA *rsa_tmp=NULL;
124
125 switch (keylength) {
126 case 512:
127 if (rsa_512)
128 rsa_tmp = rsa_512;
129 else { /* generate on the fly, should not happen in this example */
130 rsa_tmp = RSA_generate_key(keylength,RSA_F4,NULL,NULL);
131 rsa_512 = rsa_tmp; /* Remember for later reuse */
132 }
133 break;
134 case 1024:
135 if (rsa_1024)
136 rsa_tmp=rsa_1024;
137 else
138 should_not_happen_in_this_example();
139 break;
140 default:
141 /* Generating a key on the fly is very costly, so use what is there */
142 if (rsa_1024)
143 rsa_tmp=rsa_1024;
144 else
145 rsa_tmp=rsa_512; /* Use at least a shorter key */
146 }
147 return(rsa_tmp);
148 }
149
150=head1 RETURN VALUES
151
152SSL_CTX_set_tmp_rsa_callback() and SSL_set_tmp_rsa_callback() do not return
153diagnostic output.
154
155SSL_CTX_set_tmp_rsa() and SSL_set_tmp_rsa() do return 1 on success and 0
156on failure. Check the error queue to find out the reason of failure.
157
158SSL_CTX_need_tmp_rsa() and SSL_need_tmp_rsa() return 1 if a temporary
159RSA key is needed and 0 otherwise.
160
161=head1 SEE ALSO
162
163L<ssl(3)|ssl(3)>, L<SSL_CTX_set_cipher_list(3)|SSL_CTX_set_cipher_list(3)>,
164L<SSL_CTX_set_options(3)|SSL_CTX_set_options(3)>,
165L<SSL_CTX_set_tmp_dh_callback(3)|SSL_CTX_set_tmp_dh_callback(3)>,
166L<SSL_new(3)|SSL_new(3)>, L<ciphers(1)|ciphers(1)>
167
168=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_verify.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_verify.3
new file mode 100644
index 0000000000..6ce2e60089
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_set_verify.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_verify.pod
deleted file mode 100644
index 0af8e69441..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_verify.pod
+++ /dev/null
@@ -1,295 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_verify, SSL_set_verify, SSL_CTX_set_verify_depth,
6SSL_set_verify_depth - set peer certificate verification parameters
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 void SSL_CTX_set_verify(SSL_CTX *ctx, int mode,
13 int (*verify_callback)(int, X509_STORE_CTX *));
14 void SSL_set_verify(SSL *s, int mode,
15 int (*verify_callback)(int, X509_STORE_CTX *));
16 void SSL_CTX_set_verify_depth(SSL_CTX *ctx,int depth);
17 void SSL_set_verify_depth(SSL *s, int depth);
18
19 int verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx);
20
21=head1 DESCRIPTION
22
23SSL_CTX_set_verify() sets the verification flags for B<ctx> to be B<mode> and
24specifies the B<verify_callback> function to be used. If no callback function
25shall be specified, the NULL pointer can be used for B<verify_callback>.
26
27SSL_set_verify() sets the verification flags for B<ssl> to be B<mode> and
28specifies the B<verify_callback> function to be used. If no callback function
29shall be specified, the NULL pointer can be used for B<verify_callback>. In
30this case last B<verify_callback> set specifically for this B<ssl> remains. If
31no special B<callback> was set before, the default callback for the underlying
32B<ctx> is used, that was valid at the time B<ssl> was created with
33L<SSL_new(3)|SSL_new(3)>.
34
35SSL_CTX_set_verify_depth() sets the maximum B<depth> for the certificate chain
36verification that shall be allowed for B<ctx>. (See the BUGS section.)
37
38SSL_set_verify_depth() sets the maximum B<depth> for the certificate chain
39verification that shall be allowed for B<ssl>. (See the BUGS section.)
40
41=head1 NOTES
42
43The verification of certificates can be controlled by a set of logically
44or'ed B<mode> flags:
45
46=over 4
47
48=item SSL_VERIFY_NONE
49
50B<Server mode:> the server will not send a client certificate request to the
51client, so the client will not send a certificate.
52
53B<Client mode:> if not using an anonymous cipher (by default disabled), the
54server will send a certificate which will be checked. The result of the
55certificate verification process can be checked after the TLS/SSL handshake
56using the L<SSL_get_verify_result(3)|SSL_get_verify_result(3)> function.
57The handshake will be continued regardless of the verification result.
58
59=item SSL_VERIFY_PEER
60
61B<Server mode:> the server sends a client certificate request to the client.
62The certificate returned (if any) is checked. If the verification process
63fails, the TLS/SSL handshake is
64immediately terminated with an alert message containing the reason for
65the verification failure.
66The behaviour can be controlled by the additional
67SSL_VERIFY_FAIL_IF_NO_PEER_CERT and SSL_VERIFY_CLIENT_ONCE flags.
68
69B<Client mode:> the server certificate is verified. If the verification process
70fails, the TLS/SSL handshake is
71immediately terminated with an alert message containing the reason for
72the verification failure. If no server certificate is sent, because an
73anonymous cipher is used, SSL_VERIFY_PEER is ignored.
74
75=item SSL_VERIFY_FAIL_IF_NO_PEER_CERT
76
77B<Server mode:> if the client did not return a certificate, the TLS/SSL
78handshake is immediately terminated with a "handshake failure" alert.
79This flag must be used together with SSL_VERIFY_PEER.
80
81B<Client mode:> ignored
82
83=item SSL_VERIFY_CLIENT_ONCE
84
85B<Server mode:> only request a client certificate on the initial TLS/SSL
86handshake. Do not ask for a client certificate again in case of a
87renegotiation. This flag must be used together with SSL_VERIFY_PEER.
88
89B<Client mode:> ignored
90
91=back
92
93Exactly one of the B<mode> flags SSL_VERIFY_NONE and SSL_VERIFY_PEER must be
94set at any time.
95
96The actual verification procedure is performed either using the built-in
97verification procedure or using another application provided verification
98function set with
99L<SSL_CTX_set_cert_verify_callback(3)|SSL_CTX_set_cert_verify_callback(3)>.
100The following descriptions apply in the case of the built-in procedure. An
101application provided procedure also has access to the verify depth information
102and the verify_callback() function, but the way this information is used
103may be different.
104
105SSL_CTX_set_verify_depth() and SSL_set_verify_depth() set the limit up
106to which depth certificates in a chain are used during the verification
107procedure. If the certificate chain is longer than allowed, the certificates
108above the limit are ignored. Error messages are generated as if these
109certificates would not be present, most likely a
110X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY will be issued.
111The depth count is "level 0:peer certificate", "level 1: CA certificate",
112"level 2: higher level CA certificate", and so on. Setting the maximum
113depth to 2 allows the levels 0, 1, and 2. The default depth limit is 100,
114allowing for the peer certificate and additional 100 CA certificates.
115
116The B<verify_callback> function is used to control the behaviour when the
117SSL_VERIFY_PEER flag is set. It must be supplied by the application and
118receives two arguments: B<preverify_ok> indicates, whether the verification of
119the certificate in question was passed (preverify_ok=1) or not
120(preverify_ok=0). B<x509_ctx> is a pointer to the complete context used
121for the certificate chain verification.
122
123The certificate chain is checked starting with the deepest nesting level
124(the root CA certificate) and worked upward to the peer's certificate.
125At each level signatures and issuer attributes are checked. Whenever
126a verification error is found, the error number is stored in B<x509_ctx>
127and B<verify_callback> is called with B<preverify_ok>=0. By applying
128X509_CTX_store_* functions B<verify_callback> can locate the certificate
129in question and perform additional steps (see EXAMPLES). If no error is
130found for a certificate, B<verify_callback> is called with B<preverify_ok>=1
131before advancing to the next level.
132
133The return value of B<verify_callback> controls the strategy of the further
134verification process. If B<verify_callback> returns 0, the verification
135process is immediately stopped with "verification failed" state. If
136SSL_VERIFY_PEER is set, a verification failure alert is sent to the peer and
137the TLS/SSL handshake is terminated. If B<verify_callback> returns 1,
138the verification process is continued. If B<verify_callback> always returns
1391, the TLS/SSL handshake will not be terminated with respect to verification
140failures and the connection will be established. The calling process can
141however retrieve the error code of the last verification error using
142L<SSL_get_verify_result(3)|SSL_get_verify_result(3)> or by maintaining its
143own error storage managed by B<verify_callback>.
144
145If no B<verify_callback> is specified, the default callback will be used.
146Its return value is identical to B<preverify_ok>, so that any verification
147failure will lead to a termination of the TLS/SSL handshake with an
148alert message, if SSL_VERIFY_PEER is set.
149
150=head1 BUGS
151
152In client mode, it is not checked whether the SSL_VERIFY_PEER flag
153is set, but whether SSL_VERIFY_NONE is not set. This can lead to
154unexpected behaviour, if the SSL_VERIFY_PEER and SSL_VERIFY_NONE are not
155used as required (exactly one must be set at any time).
156
157The certificate verification depth set with SSL[_CTX]_verify_depth()
158stops the verification at a certain depth. The error message produced
159will be that of an incomplete certificate chain and not
160X509_V_ERR_CERT_CHAIN_TOO_LONG as may be expected.
161
162=head1 RETURN VALUES
163
164The SSL*_set_verify*() functions do not provide diagnostic information.
165
166=head1 EXAMPLES
167
168The following code sequence realizes an example B<verify_callback> function
169that will always continue the TLS/SSL handshake regardless of verification
170failure, if wished. The callback realizes a verification depth limit with
171more informational output.
172
173All verification errors are printed; information about the certificate chain
174is printed on request.
175The example is realized for a server that does allow but not require client
176certificates.
177
178The example makes use of the ex_data technique to store application data
179into/retrieve application data from the SSL structure
180(see L<SSL_get_ex_new_index(3)|SSL_get_ex_new_index(3)>,
181L<SSL_get_ex_data_X509_STORE_CTX_idx(3)|SSL_get_ex_data_X509_STORE_CTX_idx(3)>).
182
183 ...
184 typedef struct {
185 int verbose_mode;
186 int verify_depth;
187 int always_continue;
188 } mydata_t;
189 int mydata_index;
190 ...
191 static int verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
192 {
193 char buf[256];
194 X509 *err_cert;
195 int err, depth;
196 SSL *ssl;
197 mydata_t *mydata;
198
199 err_cert = X509_STORE_CTX_get_current_cert(ctx);
200 err = X509_STORE_CTX_get_error(ctx);
201 depth = X509_STORE_CTX_get_error_depth(ctx);
202
203 /*
204 * Retrieve the pointer to the SSL of the connection currently treated
205 * and the application specific data stored into the SSL object.
206 */
207 ssl = X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx());
208 mydata = SSL_get_ex_data(ssl, mydata_index);
209
210 X509_NAME_oneline(X509_get_subject_name(err_cert), buf, 256);
211
212 /*
213 * Catch a too long certificate chain. The depth limit set using
214 * SSL_CTX_set_verify_depth() is by purpose set to "limit+1" so
215 * that whenever the "depth>verify_depth" condition is met, we
216 * have violated the limit and want to log this error condition.
217 * We must do it here, because the CHAIN_TOO_LONG error would not
218 * be found explicitly; only errors introduced by cutting off the
219 * additional certificates would be logged.
220 */
221 if (depth > mydata->verify_depth) {
222 preverify_ok = 0;
223 err = X509_V_ERR_CERT_CHAIN_TOO_LONG;
224 X509_STORE_CTX_set_error(ctx, err);
225 }
226 if (!preverify_ok) {
227 printf("verify error:num=%d:%s:depth=%d:%s\n", err,
228 X509_verify_cert_error_string(err), depth, buf);
229 }
230 else if (mydata->verbose_mode)
231 {
232 printf("depth=%d:%s\n", depth, buf);
233 }
234
235 /*
236 * At this point, err contains the last verification error. We can use
237 * it for something special
238 */
239 if (!preverify_ok && (err == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT))
240 {
241 X509_NAME_oneline(X509_get_issuer_name(ctx->current_cert), buf, 256);
242 printf("issuer= %s\n", buf);
243 }
244
245 if (mydata->always_continue)
246 return 1;
247 else
248 return preverify_ok;
249 }
250 ...
251
252 mydata_t mydata;
253
254 ...
255 mydata_index = SSL_get_ex_new_index(0, "mydata index", NULL, NULL, NULL);
256
257 ...
258 SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
259 verify_callback);
260
261 /*
262 * Let the verify_callback catch the verify_depth error so that we get
263 * an appropriate error in the logfile.
264 */
265 SSL_CTX_set_verify_depth(verify_depth + 1);
266
267 /*
268 * Set up the SSL specific data into "mydata" and store it into th SSL
269 * structure.
270 */
271 mydata.verify_depth = verify_depth; ...
272 SSL_set_ex_data(ssl, mydata_index, &mydata);
273
274 ...
275 SSL_accept(ssl); /* check of success left out for clarity */
276 if (peer = SSL_get_peer_certificate(ssl))
277 {
278 if (SSL_get_verify_result(ssl) == X509_V_OK)
279 {
280 /* The client sent a certificate which verified OK */
281 }
282 }
283
284=head1 SEE ALSO
285
286L<ssl(3)|ssl(3)>, L<SSL_new(3)|SSL_new(3)>,
287L<SSL_CTX_get_verify_mode(3)|SSL_CTX_get_verify_mode(3)>,
288L<SSL_get_verify_result(3)|SSL_get_verify_result(3)>,
289L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>,
290L<SSL_get_peer_certificate(3)|SSL_get_peer_certificate(3)>,
291L<SSL_CTX_set_cert_verify_callback(3)|SSL_CTX_set_cert_verify_callback(3)>,
292L<SSL_get_ex_data_X509_STORE_CTX_idx(3)|SSL_get_ex_data_X509_STORE_CTX_idx(3)>,
293L<SSL_get_ex_new_index(3)|SSL_get_ex_new_index(3)>
294
295=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_use_certificate.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_use_certificate.3
new file mode 100644
index 0000000000..eac4d8e42c
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_use_certificate.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_use_certificate.pod
deleted file mode 100644
index 560e00937f..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_use_certificate.pod
+++ /dev/null
@@ -1,180 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_use_certificate, SSL_CTX_use_certificate_ASN1,
6SSL_CTX_use_certificate_file, SSL_use_certificate,
7SSL_use_certificate_ASN1, SSL_use_certificate_file,
8SSL_CTX_use_certificate_chain, SSL_CTX_use_certificate_chain_file,
9SSL_CTX_use_PrivateKey, SSL_CTX_use_PrivateKey_ASN1,
10SSL_CTX_use_PrivateKey_file, SSL_CTX_use_RSAPrivateKey,
11SSL_CTX_use_RSAPrivateKey_ASN1, SSL_CTX_use_RSAPrivateKey_file,
12SSL_use_PrivateKey_file, SSL_use_PrivateKey_ASN1, SSL_use_PrivateKey,
13SSL_use_RSAPrivateKey, SSL_use_RSAPrivateKey_ASN1, SSL_use_RSAPrivateKey_file,
14SSL_CTX_check_private_key, SSL_check_private_key - load certificate and key
15data
16
17=head1 SYNOPSIS
18
19 #include <openssl/ssl.h>
20
21 int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x);
22 int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len, unsigned char *d);
23 int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type);
24 int SSL_use_certificate(SSL *ssl, X509 *x);
25 int SSL_use_certificate_ASN1(SSL *ssl, unsigned char *d, int len);
26 int SSL_use_certificate_file(SSL *ssl, const char *file, int type);
27
28 int SSL_CTX_use_certificate_chain(SSL_CTX *ctx, void *buf, int len);
29 int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file);
30
31 int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey);
32 int SSL_CTX_use_PrivateKey_ASN1(int pk, SSL_CTX *ctx, unsigned char *d,
33 long len);
34 int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type);
35 int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa);
36 int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, unsigned char *d, long len);
37 int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type);
38 int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey);
39 int SSL_use_PrivateKey_ASN1(int pk,SSL *ssl, unsigned char *d, long len);
40 int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type);
41 int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa);
42 int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len);
43 int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type);
44
45 int SSL_CTX_check_private_key(const SSL_CTX *ctx);
46 int SSL_check_private_key(const SSL *ssl);
47
48=head1 DESCRIPTION
49
50These functions load the certificates and private keys into the SSL_CTX
51or SSL object, respectively.
52
53The SSL_CTX_* class of functions loads the certificates and keys into the
54SSL_CTX object B<ctx>. The information is passed to SSL objects B<ssl>
55created from B<ctx> with L<SSL_new(3)|SSL_new(3)> by copying, so that
56changes applied to B<ctx> do not propagate to already existing SSL objects.
57
58The SSL_* class of functions only loads certificates and keys into a
59specific SSL object. The specific information is kept, when
60L<SSL_clear(3)|SSL_clear(3)> is called for this SSL object.
61
62SSL_CTX_use_certificate() loads the certificate B<x> into B<ctx>,
63SSL_use_certificate() loads B<x> into B<ssl>. The rest of the
64certificates needed to form the complete certificate chain can be
65specified using the
66L<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)>
67function.
68
69SSL_CTX_use_certificate_ASN1() loads the ASN1 encoded certificate from
70the memory location B<d> (with length B<len>) into B<ctx>,
71SSL_use_certificate_ASN1() loads the ASN1 encoded certificate into B<ssl>.
72
73SSL_CTX_use_certificate_file() loads the first certificate stored in B<file>
74into B<ctx>. The formatting B<type> of the certificate must be specified
75from the known types SSL_FILETYPE_PEM, SSL_FILETYPE_ASN1.
76SSL_use_certificate_file() loads the certificate from B<file> into B<ssl>.
77See the NOTES section on why SSL_CTX_use_certificate_chain_file()
78should be preferred.
79
80The SSL_CTX_use_certificate_chain*() functions load a certificate chain
81into B<ctx>. The certificates must be in PEM format and must
82be sorted starting with the subject's certificate (actual client or server
83certificate), followed by intermediate CA certificates if applicable, and
84ending at the highest level (root) CA.
85There is no corresponding function working on a single SSL object.
86
87SSL_CTX_use_PrivateKey() adds B<pkey> as private key to B<ctx>.
88SSL_CTX_use_RSAPrivateKey() adds the private key B<rsa> of type RSA
89to B<ctx>. SSL_use_PrivateKey() adds B<pkey> as private key to B<ssl>;
90SSL_use_RSAPrivateKey() adds B<rsa> as private key of type RSA to B<ssl>.
91If a certificate has already been set and the private does not belong
92to the certificate an error is returned. To change a certificate, private
93key pair the new certificate needs to be set with SSL_use_certificate()
94or SSL_CTX_use_certificate() before setting the private key with
95SSL_CTX_use_PrivateKey() or SSL_use_PrivateKey().
96
97
98SSL_CTX_use_PrivateKey_ASN1() adds the private key of type B<pk>
99stored at memory location B<d> (length B<len>) to B<ctx>.
100SSL_CTX_use_RSAPrivateKey_ASN1() adds the private key of type RSA
101stored at memory location B<d> (length B<len>) to B<ctx>.
102SSL_use_PrivateKey_ASN1() and SSL_use_RSAPrivateKey_ASN1() add the private
103key to B<ssl>.
104
105SSL_CTX_use_PrivateKey_file() adds the first private key found in
106B<file> to B<ctx>. The formatting B<type> of the certificate must be specified
107from the known types SSL_FILETYPE_PEM, SSL_FILETYPE_ASN1.
108SSL_CTX_use_RSAPrivateKey_file() adds the first private RSA key found in
109B<file> to B<ctx>. SSL_use_PrivateKey_file() adds the first private key found
110in B<file> to B<ssl>; SSL_use_RSAPrivateKey_file() adds the first private
111RSA key found to B<ssl>.
112
113SSL_CTX_check_private_key() checks the consistency of a private key with
114the corresponding certificate loaded into B<ctx>. If more than one
115key/certificate pair (RSA/DSA) is installed, the last item installed will
116be checked. If e.g. the last item was a RSA certificate or key, the RSA
117key/certificate pair will be checked. SSL_check_private_key() performs
118the same check for B<ssl>. If no key/certificate was explicitly added for
119this B<ssl>, the last item added into B<ctx> will be checked.
120
121=head1 NOTES
122
123The internal certificate store of OpenSSL can hold two private key/certificate
124pairs at a time: one key/certificate of type RSA and one key/certificate
125of type DSA. The certificate used depends on the cipher select, see
126also L<SSL_CTX_set_cipher_list(3)|SSL_CTX_set_cipher_list(3)>.
127
128When reading certificates and private keys from file, files of type
129SSL_FILETYPE_ASN1 (also known as B<DER>, binary encoding) can only contain
130one certificate or private key, consequently
131SSL_CTX_use_certificate_chain_file() is only applicable to PEM formatting.
132Files of type SSL_FILETYPE_PEM can contain more than one item.
133
134SSL_CTX_use_certificate_chain_file() adds the first certificate found
135in the file to the certificate store. The other certificates are added
136to the store of chain certificates using
137L<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)>.
138There exists only one extra chain store, so that the same chain is appended
139to both types of certificates, RSA and DSA! If it is not intended to use
140both type of certificate at the same time, it is recommended to use the
141SSL_CTX_use_certificate_chain_file() instead of the
142SSL_CTX_use_certificate_file() function in order to allow the use of
143complete certificate chains even when no trusted CA storage is used or
144when the CA issuing the certificate shall not be added to the trusted
145CA storage.
146
147If additional certificates are needed to complete the chain during the
148TLS negotiation, CA certificates are additionally looked up in the
149locations of trusted CA certificates, see
150L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>.
151
152The private keys loaded from file can be encrypted. In order to successfully
153load encrypted keys, a function returning the passphrase must have been
154supplied, see
155L<SSL_CTX_set_default_passwd_cb(3)|SSL_CTX_set_default_passwd_cb(3)>.
156(Certificate files might be encrypted as well from the technical point
157of view, it however does not make sense as the data in the certificate
158is considered public anyway.)
159
160=head1 RETURN VALUES
161
162On success, the functions return 1.
163Otherwise check out the error stack to find out the reason.
164
165=head1 SEE ALSO
166
167L<ssl(3)|ssl(3)>, L<SSL_new(3)|SSL_new(3)>, L<SSL_clear(3)|SSL_clear(3)>,
168L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>,
169L<SSL_CTX_set_default_passwd_cb(3)|SSL_CTX_set_default_passwd_cb(3)>,
170L<SSL_CTX_set_cipher_list(3)|SSL_CTX_set_cipher_list(3)>,
171L<SSL_CTX_set_client_cert_cb(3)|SSL_CTX_set_client_cert_cb(3)>,
172L<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)>
173
174=head1 HISTORY
175
176Support for DER encoded private keys (SSL_FILETYPE_ASN1) in
177SSL_CTX_use_PrivateKey_file() and SSL_use_PrivateKey_file() was added
178in 0.9.8 .
179
180=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_use_psk_identity_hint.3 b/src/lib/libssl/src/doc/ssl/SSL_CTX_use_psk_identity_hint.3
new file mode 100644
index 0000000000..4d4e8a6173
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_CTX_use_psk_identity_hint.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_use_psk_identity_hint.pod
deleted file mode 100644
index 9f88d284d2..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_use_psk_identity_hint.pod
+++ /dev/null
@@ -1,106 +0,0 @@
1=pod
2
3=begin comment
4
5Copyright 2005 Nokia. All rights reserved.
6
7The portions of the attached software ("Contribution") is developed by
8Nokia Corporation and is licensed pursuant to the OpenSSL open source
9license.
10
11The Contribution, originally written by Mika Kousa and Pasi Eronen of
12Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites
13support (see RFC 4279) to OpenSSL.
14
15No patent licenses or other rights except those expressly stated in
16the OpenSSL open source license shall be deemed granted or received
17expressly, by implication, estoppel, or otherwise.
18
19No assurances are provided by Nokia that the Contribution does not
20infringe the patent or other intellectual property rights of any third
21party or that the license provides you with all the necessary rights
22to make use of the Contribution.
23
24THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN
25ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA
26SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY
27OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR
28OTHERWISE.
29
30=end comment
31
32=head1 NAME
33
34SSL_CTX_use_psk_identity_hint, SSL_use_psk_identity_hint,
35SSL_CTX_set_psk_server_callback, SSL_set_psk_server_callback - set PSK
36identity hint to use
37
38
39=head1 SYNOPSIS
40
41 #include <openssl/ssl.h>
42
43 int SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, const char *hint);
44 int SSL_use_psk_identity_hint(SSL *ssl, const char *hint);
45
46 void SSL_CTX_set_psk_server_callback(SSL_CTX *ctx,
47 unsigned int (*callback)(SSL *ssl, const char *identity,
48 unsigned char *psk, int max_psk_len));
49 void SSL_set_psk_server_callback(SSL *ssl,
50 unsigned int (*callback)(SSL *ssl, const char *identity,
51 unsigned char *psk, int max_psk_len));
52
53
54=head1 DESCRIPTION
55
56SSL_CTX_use_psk_identity_hint() sets the given B<NULL>-terminated PSK
57identity hint B<hint> to SSL context object
58B<ctx>. SSL_use_psk_identity_hint() sets the given B<NULL>-terminated
59PSK identity hint B<hint> to SSL connection object B<ssl>. If B<hint>
60is B<NULL> the current hint from B<ctx> or B<ssl> is deleted.
61
62In the case where PSK identity hint is B<NULL>, the server
63does not send the ServerKeyExchange message to the client.
64
65A server application must provide a callback function which is called
66when the server receives the ClientKeyExchange message from the
67client. The purpose of the callback function is to validate the
68received PSK identity and to fetch the pre-shared key used during the
69connection setup phase. The callback is set using functions
70SSL_CTX_set_psk_server_callback() or
71SSL_set_psk_server_callback(). The callback function is given the
72connection in parameter B<ssl>, B<NULL>-terminated PSK identity sent
73by the client in parameter B<identity>, and a buffer B<psk> of length
74B<max_psk_len> bytes where the pre-shared key is to be stored.
75
76
77=head1 RETURN VALUES
78
79SSL_CTX_use_psk_identity_hint() and SSL_use_psk_identity_hint() return
801 on success, 0 otherwise.
81
82Return values from the server callback are interpreted as follows:
83
84=over 4
85
86=item C<E<gt> 0>
87
88PSK identity was found and the server callback has provided the PSK
89successfully in parameter B<psk>. Return value is the length of
90B<psk> in bytes. It is an error to return a value greater than
91B<max_psk_len>.
92
93If the PSK identity was not found but the callback instructs the
94protocol to continue anyway, the callback must provide some random
95data to B<psk> and return the length of the random data, so the
96connection will fail with decryption_error before it will be finished
97completely.
98
99=item C<0>
100
101PSK identity was not found. An "unknown_psk_identity" alert message
102will be sent and the connection setup fails.
103
104=back
105
106=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_SESSION_free.3 b/src/lib/libssl/src/doc/ssl/SSL_SESSION_free.3
new file mode 100644
index 0000000000..f7d2350b55
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_SESSION_free.pod b/src/lib/libssl/src/doc/ssl/SSL_SESSION_free.pod
deleted file mode 100644
index 110ec73ab6..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_SESSION_free.pod
+++ /dev/null
@@ -1,55 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_SESSION_free - free an allocated SSL_SESSION structure
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 void SSL_SESSION_free(SSL_SESSION *session);
12
13=head1 DESCRIPTION
14
15SSL_SESSION_free() decrements the reference count of B<session> and removes
16the B<SSL_SESSION> structure pointed to by B<session> and frees up the allocated
17memory, if the reference count has reached 0.
18
19=head1 NOTES
20
21SSL_SESSION objects are allocated, when a TLS/SSL handshake operation
22is successfully completed. Depending on the settings, see
23L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>,
24the SSL_SESSION objects are internally referenced by the SSL_CTX and
25linked into its session cache. SSL objects may be using the SSL_SESSION object;
26as a session may be reused, several SSL objects may be using one SSL_SESSION
27object at the same time. It is therefore crucial to keep the reference
28count (usage information) correct and not delete a SSL_SESSION object
29that is still used, as this may lead to program failures due to
30dangling pointers. These failures may also appear delayed, e.g.
31when an SSL_SESSION object was completely freed as the reference count
32incorrectly became 0, but it is still referenced in the internal
33session cache and the cache list is processed during a
34L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)> operation.
35
36SSL_SESSION_free() must only be called for SSL_SESSION objects, for
37which the reference count was explicitly incremented (e.g.
38by calling SSL_get1_session(), see L<SSL_get_session(3)|SSL_get_session(3)>)
39or when the SSL_SESSION object was generated outside a TLS handshake
40operation, e.g. by using L<d2i_SSL_SESSION(3)|d2i_SSL_SESSION(3)>.
41It must not be called on other SSL_SESSION objects, as this would cause
42incorrect reference counts and therefore program failures.
43
44=head1 RETURN VALUES
45
46SSL_SESSION_free() does not provide diagnostic information.
47
48=head1 SEE ALSO
49
50L<ssl(3)|ssl(3)>, L<SSL_get_session(3)|SSL_get_session(3)>,
51L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>,
52L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)>,
53 L<d2i_SSL_SESSION(3)|d2i_SSL_SESSION(3)>
54
55=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_SESSION_get_ex_new_index.3 b/src/lib/libssl/src/doc/ssl/SSL_SESSION_get_ex_new_index.3
new file mode 100644
index 0000000000..d6a94cb0b7
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_SESSION_get_ex_new_index.pod b/src/lib/libssl/src/doc/ssl/SSL_SESSION_get_ex_new_index.pod
deleted file mode 100644
index 1e6bec2314..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_SESSION_get_ex_new_index.pod
+++ /dev/null
@@ -1,62 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_SESSION_get_ex_new_index, SSL_SESSION_set_ex_data, SSL_SESSION_get_ex_data
6- internal application specific data functions
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 int SSL_SESSION_get_ex_new_index(long argl, void *argp,
13 CRYPTO_EX_new *new_func,
14 CRYPTO_EX_dup *dup_func,
15 CRYPTO_EX_free *free_func);
16
17 int SSL_SESSION_set_ex_data(SSL_SESSION *session, int idx, void *arg);
18
19 void *SSL_SESSION_get_ex_data(const SSL_SESSION *session, int idx);
20
21 typedef int new_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
22 int idx, long argl, void *argp);
23 typedef void free_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
24 int idx, long argl, void *argp);
25 typedef int dup_func(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
26 int idx, long argl, void *argp);
27
28=head1 DESCRIPTION
29
30Several OpenSSL structures can have application specific data attached to them.
31These functions are used internally by OpenSSL to manipulate application
32specific data attached to a specific structure.
33
34SSL_SESSION_get_ex_new_index() is used to register a new index for application
35specific data.
36
37SSL_SESSION_set_ex_data() is used to store application data at B<arg> for B<idx>
38into the B<session> object.
39
40SSL_SESSION_get_ex_data() is used to retrieve the information for B<idx> from
41B<session>.
42
43A detailed description for the B<*_get_ex_new_index()> functionality
44can be found in L<RSA_get_ex_new_index(3)|RSA_get_ex_new_index(3)>.
45The B<*_get_ex_data()> and B<*_set_ex_data()> functionality is described in
46L<CRYPTO_set_ex_data(3)|CRYPTO_set_ex_data(3)>.
47
48=head1 WARNINGS
49
50The application data is only maintained for sessions held in memory. The
51application data is not included when dumping the session with
52i2d_SSL_SESSION() (and all functions indirectly calling the dump functions
53like PEM_write_SSL_SESSION() and PEM_write_bio_SSL_SESSION()) and can
54therefore not be restored.
55
56=head1 SEE ALSO
57
58L<ssl(3)|ssl(3)>,
59L<RSA_get_ex_new_index(3)|RSA_get_ex_new_index(3)>,
60L<CRYPTO_set_ex_data(3)|CRYPTO_set_ex_data(3)>
61
62=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_SESSION_get_time.3 b/src/lib/libssl/src/doc/ssl/SSL_SESSION_get_time.3
new file mode 100644
index 0000000000..d094adb50a
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_SESSION_get_time.pod b/src/lib/libssl/src/doc/ssl/SSL_SESSION_get_time.pod
deleted file mode 100644
index a9b44b3a5c..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_SESSION_get_time.pod
+++ /dev/null
@@ -1,66 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_SESSION_get_time, SSL_SESSION_set_time, SSL_SESSION_get_timeout,
6SSL_SESSION_set_timeout - retrieve and manipulate session time and timeout
7settings
8
9=head1 SYNOPSIS
10
11 #include <openssl/ssl.h>
12
13 long SSL_SESSION_get_time(const SSL_SESSION *s);
14 long SSL_SESSION_set_time(SSL_SESSION *s, long tm);
15 long SSL_SESSION_get_timeout(const SSL_SESSION *s);
16 long SSL_SESSION_set_timeout(SSL_SESSION *s, long tm);
17
18 long SSL_get_time(const SSL_SESSION *s);
19 long SSL_set_time(SSL_SESSION *s, long tm);
20 long SSL_get_timeout(const SSL_SESSION *s);
21 long SSL_set_timeout(SSL_SESSION *s, long tm);
22
23=head1 DESCRIPTION
24
25SSL_SESSION_get_time() returns the time at which the session B<s> was
26established. The time is given in seconds since the Epoch and therefore
27compatible to the time delivered by the time() call.
28
29SSL_SESSION_set_time() replaces the creation time of the session B<s> with
30the chosen value B<tm>.
31
32SSL_SESSION_get_timeout() returns the timeout value set for session B<s>
33in seconds.
34
35SSL_SESSION_set_timeout() sets the timeout value for session B<s> in seconds
36to B<tm>.
37
38The SSL_get_time(), SSL_set_time(), SSL_get_timeout(), and SSL_set_timeout()
39functions are synonyms for the SSL_SESSION_*() counterparts.
40
41=head1 NOTES
42
43Sessions are expired by examining the creation time and the timeout value.
44Both are set at creation time of the session to the actual time and the
45default timeout value at creation, respectively, as set by
46L<SSL_CTX_set_timeout(3)|SSL_CTX_set_timeout(3)>.
47Using these functions it is possible to extend or shorten the lifetime
48of the session.
49
50=head1 RETURN VALUES
51
52SSL_SESSION_get_time() and SSL_SESSION_get_timeout() return the currently
53valid values.
54
55SSL_SESSION_set_time() and SSL_SESSION_set_timeout() return 1 on success.
56
57If any of the function is passed the NULL pointer for the session B<s>,
580 is returned.
59
60=head1 SEE ALSO
61
62L<ssl(3)|ssl(3)>,
63L<SSL_CTX_set_timeout(3)|SSL_CTX_set_timeout(3)>,
64L<SSL_get_default_timeout(3)|SSL_get_default_timeout(3)>
65
66=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_accept.3 b/src/lib/libssl/src/doc/ssl/SSL_accept.3
new file mode 100644
index 0000000000..88bea1fde7
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_accept.pod b/src/lib/libssl/src/doc/ssl/SSL_accept.pod
deleted file mode 100644
index 42a539d354..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_accept.pod
+++ /dev/null
@@ -1,76 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_accept - wait for a TLS/SSL client to initiate a TLS/SSL handshake
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 int SSL_accept(SSL *ssl);
12
13=head1 DESCRIPTION
14
15SSL_accept() waits for a TLS/SSL client to initiate the TLS/SSL handshake.
16The communication channel must already have been set and assigned to the
17B<ssl> by setting an underlying B<BIO>.
18
19=head1 NOTES
20
21The behaviour of SSL_accept() depends on the underlying BIO.
22
23If the underlying BIO is B<blocking>, SSL_accept() will only return once the
24handshake has been finished or an error occurred, except for SGC (Server
25Gated Cryptography). For SGC, SSL_accept() may return with -1, but
26SSL_get_error() will yield B<SSL_ERROR_WANT_READ/WRITE> and SSL_accept()
27should be called again.
28
29If the underlying BIO is B<non-blocking>, SSL_accept() will also return
30when the underlying BIO could not satisfy the needs of SSL_accept()
31to continue the handshake, indicating the problem by the return value -1.
32In this case a call to SSL_get_error() with the
33return value of SSL_accept() will yield B<SSL_ERROR_WANT_READ> or
34B<SSL_ERROR_WANT_WRITE>. The calling process then must repeat the call after
35taking appropriate action to satisfy the needs of SSL_accept().
36The action depends on the underlying BIO. When using a non-blocking socket,
37nothing is to be done, but select() can be used to check for the required
38condition. When using a buffering BIO, like a BIO pair, data must be written
39into or retrieved out of the BIO before being able to continue.
40
41=head1 RETURN VALUES
42
43The following return values can occur:
44
45=over 4
46
47=item C<0>
48
49The TLS/SSL handshake was not successful but was shut down controlled and
50by the specifications of the TLS/SSL protocol. Call SSL_get_error() with the
51return value B<ret> to find out the reason.
52
53=item C<1>
54
55The TLS/SSL handshake was successfully completed, a TLS/SSL connection has been
56established.
57
58=item E<lt>0
59
60The TLS/SSL handshake was not successful because a fatal error occurred either
61at the protocol level or a connection failure occurred. The shutdown was
62not clean. It can also occur of action is need to continue the operation
63for non-blocking BIOs. Call SSL_get_error() with the return value B<ret>
64to find out the reason.
65
66=back
67
68=head1 SEE ALSO
69
70L<SSL_get_error(3)|SSL_get_error(3)>, L<SSL_connect(3)|SSL_connect(3)>,
71L<SSL_shutdown(3)|SSL_shutdown(3)>, L<ssl(3)|ssl(3)>, L<bio(3)|bio(3)>,
72L<SSL_set_connect_state(3)|SSL_set_connect_state(3)>,
73L<SSL_do_handshake(3)|SSL_do_handshake(3)>,
74L<SSL_CTX_new(3)|SSL_CTX_new(3)>
75
76=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_alert_type_string.3 b/src/lib/libssl/src/doc/ssl/SSL_alert_type_string.3
new file mode 100644
index 0000000000..f4b652bc1a
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_alert_type_string.pod b/src/lib/libssl/src/doc/ssl/SSL_alert_type_string.pod
deleted file mode 100644
index 0a70a46890..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_alert_type_string.pod
+++ /dev/null
@@ -1,234 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_alert_type_string, SSL_alert_type_string_long, SSL_alert_desc_string,
6SSL_alert_desc_string_long - get textual description of alert information
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 const char *SSL_alert_type_string(int value);
13 const char *SSL_alert_type_string_long(int value);
14
15 const char *SSL_alert_desc_string(int value);
16 const char *SSL_alert_desc_string_long(int value);
17
18=head1 DESCRIPTION
19
20SSL_alert_type_string() returns a one letter string indicating the
21type of the alert specified by B<value>.
22
23SSL_alert_type_string_long() returns a string indicating the type of the alert
24specified by B<value>.
25
26SSL_alert_desc_string() returns a two letter string as a short form
27describing the reason of the alert specified by B<value>.
28
29SSL_alert_desc_string_long() returns a string describing the reason
30of the alert specified by B<value>.
31
32=head1 NOTES
33
34When one side of an SSL/TLS communication wants to inform the peer about
35a special situation, it sends an alert. The alert is sent as a special message
36and does not influence the normal data stream (unless its contents results
37in the communication being canceled).
38
39A warning alert is sent, when a non-fatal error condition occurs. The
40"close notify" alert is sent as a warning alert. Other examples for
41non-fatal errors are certificate errors ("certificate expired",
42"unsupported certificate"), for which a warning alert may be sent.
43(The sending party may however decide to send a fatal error.) The
44receiving side may cancel the connection on reception of a warning
45alert on it discretion.
46
47Several alert messages must be sent as fatal alert messages as specified
48by the TLS RFC. A fatal alert always leads to a connection abort.
49
50=head1 RETURN VALUES
51
52The following strings can occur for SSL_alert_type_string() or
53SSL_alert_type_string_long():
54
55=over 4
56
57=item "W"/"warning"
58
59=item "F"/"fatal"
60
61=item "U"/"unknown"
62
63This indicates that no support is available for this alert type.
64Probably B<value> does not contain a correct alert message.
65
66=back
67
68The following strings can occur for SSL_alert_desc_string() or
69SSL_alert_desc_string_long():
70
71=over 4
72
73=item "CN"/"close notify"
74
75The connection shall be closed. This is a warning alert.
76
77=item "UM"/"unexpected message"
78
79An inappropriate message was received. This alert is always fatal
80and should never be observed in communication between proper
81implementations.
82
83=item "BM"/"bad record mac"
84
85This alert is returned if a record is received with an incorrect
86MAC. This message is always fatal.
87
88=item "DF"/"decompression failure"
89
90The decompression function received improper input (e.g. data
91that would expand to excessive length). This message is always
92fatal.
93
94=item "HF"/"handshake failure"
95
96Reception of a handshake_failure alert message indicates that the
97sender was unable to negotiate an acceptable set of security
98parameters given the options available. This is a fatal error.
99
100=item "NC"/"no certificate"
101
102A client, that was asked to send a certificate, does not send a certificate
103(SSLv3 only).
104
105=item "BC"/"bad certificate"
106
107A certificate was corrupt, contained signatures that did not
108verify correctly, etc
109
110=item "UC"/"unsupported certificate"
111
112A certificate was of an unsupported type.
113
114=item "CR"/"certificate revoked"
115
116A certificate was revoked by its signer.
117
118=item "CE"/"certificate expired"
119
120A certificate has expired or is not currently valid.
121
122=item "CU"/"certificate unknown"
123
124Some other (unspecified) issue arose in processing the
125certificate, rendering it unacceptable.
126
127=item "IP"/"illegal parameter"
128
129A field in the handshake was out of range or inconsistent with
130other fields. This is always fatal.
131
132=item "DC"/"decryption failed"
133
134A TLSCiphertext decrypted in an invalid way: either it wasn't an
135even multiple of the block length or its padding values, when
136checked, weren't correct. This message is always fatal.
137
138=item "RO"/"record overflow"
139
140A TLSCiphertext record was received which had a length more than
1412^14+2048 bytes, or a record decrypted to a TLSCompressed record
142with more than 2^14+1024 bytes. This message is always fatal.
143
144=item "CA"/"unknown CA"
145
146A valid certificate chain or partial chain was received, but the
147certificate was not accepted because the CA certificate could not
148be located or couldn't be matched with a known, trusted CA. This
149message is always fatal.
150
151=item "AD"/"access denied"
152
153A valid certificate was received, but when access control was
154applied, the sender decided not to proceed with negotiation.
155This message is always fatal.
156
157=item "DE"/"decode error"
158
159A message could not be decoded because some field was out of the
160specified range or the length of the message was incorrect. This
161message is always fatal.
162
163=item "CY"/"decrypt error"
164
165A handshake cryptographic operation failed, including being
166unable to correctly verify a signature, decrypt a key exchange,
167or validate a finished message.
168
169=item "ER"/"export restriction"
170
171A negotiation not in compliance with export restrictions was
172detected; for example, attempting to transfer a 1024 bit
173ephemeral RSA key for the RSA_EXPORT handshake method. This
174message is always fatal.
175
176=item "PV"/"protocol version"
177
178The protocol version the client has attempted to negotiate is
179recognized, but not supported. (For example, old protocol
180versions might be avoided for security reasons). This message is
181always fatal.
182
183=item "IS"/"insufficient security"
184
185Returned instead of handshake_failure when a negotiation has
186failed specifically because the server requires ciphers more
187secure than those supported by the client. This message is always
188fatal.
189
190=item "IE"/"internal error"
191
192An internal error unrelated to the peer or the correctness of the
193protocol makes it impossible to continue (such as a memory
194allocation failure). This message is always fatal.
195
196=item "US"/"user canceled"
197
198This handshake is being canceled for some reason unrelated to a
199protocol failure. If the user cancels an operation after the
200handshake is complete, just closing the connection by sending a
201close_notify is more appropriate. This alert should be followed
202by a close_notify. This message is generally a warning.
203
204=item "NR"/"no renegotiation"
205
206Sent by the client in response to a hello request or by the
207server in response to a client hello after initial handshaking.
208Either of these would normally lead to renegotiation; when that
209is not appropriate, the recipient should respond with this alert;
210at that point, the original requester can decide whether to
211proceed with the connection. One case where this would be
212appropriate would be where a server has spawned a process to
213satisfy a request; the process might receive security parameters
214(key length, authentication, etc.) at startup and it might be
215difficult to communicate changes to these parameters after that
216point. This message is always a warning.
217
218=item "UP"/"unknown PSK identity"
219
220Sent by the server to indicate that it does not recognize a PSK
221identity or an SRP identity.
222
223=item "UK"/"unknown"
224
225This indicates that no description is available for this alert type.
226Probably B<value> does not contain a correct alert message.
227
228=back
229
230=head1 SEE ALSO
231
232L<ssl(3)|ssl(3)>, L<SSL_CTX_set_info_callback(3)|SSL_CTX_set_info_callback(3)>
233
234=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_clear.3 b/src/lib/libssl/src/doc/ssl/SSL_clear.3
new file mode 100644
index 0000000000..dc596ce12a
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_clear.pod b/src/lib/libssl/src/doc/ssl/SSL_clear.pod
deleted file mode 100644
index e115a07db6..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_clear.pod
+++ /dev/null
@@ -1,77 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_clear - reset SSL object to allow another connection
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 int SSL_clear(SSL *ssl);
12
13=head1 DESCRIPTION
14
15Reset B<ssl> to allow another connection. All settings (method, ciphers,
16BIOs) are kept.
17
18=head1 NOTES
19
20SSL_clear is used to prepare an SSL object for a new connection. While all
21settings are kept, a side effect is the handling of the current SSL session.
22If a session is still B<open>, it is considered bad and will be removed
23from the session cache, as required by RFC2246. A session is considered open,
24if L<SSL_shutdown(3)|SSL_shutdown(3)> was not called for the connection
25or at least L<SSL_set_shutdown(3)|SSL_set_shutdown(3)> was used to
26set the SSL_SENT_SHUTDOWN state.
27
28If a session was closed cleanly, the session object will be kept and all
29settings corresponding. This explicitly means, that e.g. the special method
30used during the session will be kept for the next handshake. So if the
31session was a TLSv1 session, a SSL client object will use a TLSv1 client
32method for the next handshake and a SSL server object will use a TLSv1
33server method, even if SSLv23_*_methods were chosen on startup. This
34will might lead to connection failures (see L<SSL_new(3)|SSL_new(3)>)
35for a description of the method's properties.
36
37=head1 WARNINGS
38
39SSL_clear() resets the SSL object to allow for another connection. The
40reset operation however keeps several settings of the last sessions
41(some of these settings were made automatically during the last
42handshake). It only makes sense for a new connection with the exact
43same peer that shares these settings, and may fail if that peer
44changes its settings between connections. Use the sequence
45L<SSL_get_session(3)|SSL_get_session(3)>;
46L<SSL_new(3)|SSL_new(3)>;
47L<SSL_set_session(3)|SSL_set_session(3)>;
48L<SSL_free(3)|SSL_free(3)>
49instead to avoid such failures
50(or simply L<SSL_free(3)|SSL_free(3)>; L<SSL_new(3)|SSL_new(3)>
51if session reuse is not desired).
52
53=head1 RETURN VALUES
54
55The following return values can occur:
56
57=over 4
58
59=item C<0>
60
61The SSL_clear() operation could not be performed. Check the error stack to
62find out the reason.
63
64=item C<1>
65
66The SSL_clear() operation was successful.
67
68=back
69
70=head1 SEE ALSO
71
72L<SSL_new(3)|SSL_new(3)>, L<SSL_free(3)|SSL_free(3)>,
73L<SSL_shutdown(3)|SSL_shutdown(3)>, L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>,
74L<SSL_CTX_set_options(3)|SSL_CTX_set_options(3)>, L<ssl(3)|ssl(3)>,
75L<SSL_CTX_set_client_cert_cb(3)|SSL_CTX_set_client_cert_cb(3)>
76
77=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_connect.3 b/src/lib/libssl/src/doc/ssl/SSL_connect.3
new file mode 100644
index 0000000000..4f8428c3c9
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_connect.pod b/src/lib/libssl/src/doc/ssl/SSL_connect.pod
deleted file mode 100644
index 5b21119a91..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_connect.pod
+++ /dev/null
@@ -1,73 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_connect - initiate the TLS/SSL handshake with an TLS/SSL server
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 int SSL_connect(SSL *ssl);
12
13=head1 DESCRIPTION
14
15SSL_connect() initiates the TLS/SSL handshake with a server. The communication
16channel must already have been set and assigned to the B<ssl> by setting an
17underlying B<BIO>.
18
19=head1 NOTES
20
21The behaviour of SSL_connect() depends on the underlying BIO.
22
23If the underlying BIO is B<blocking>, SSL_connect() will only return once the
24handshake has been finished or an error occurred.
25
26If the underlying BIO is B<non-blocking>, SSL_connect() will also return
27when the underlying BIO could not satisfy the needs of SSL_connect()
28to continue the handshake, indicating the problem by the return value -1.
29In this case a call to SSL_get_error() with the
30return value of SSL_connect() will yield B<SSL_ERROR_WANT_READ> or
31B<SSL_ERROR_WANT_WRITE>. The calling process then must repeat the call after
32taking appropriate action to satisfy the needs of SSL_connect().
33The action depends on the underlying BIO. When using a non-blocking socket,
34nothing is to be done, but select() can be used to check for the required
35condition. When using a buffering BIO, like a BIO pair, data must be written
36into or retrieved out of the BIO before being able to continue.
37
38=head1 RETURN VALUES
39
40The following return values can occur:
41
42=over 4
43
44=item C<0>
45
46The TLS/SSL handshake was not successful but was shut down controlled and
47by the specifications of the TLS/SSL protocol. Call SSL_get_error() with the
48return value B<ret> to find out the reason.
49
50=item C<1>
51
52The TLS/SSL handshake was successfully completed, a TLS/SSL connection has been
53established.
54
55=item C<E<lt>0>
56
57The TLS/SSL handshake was not successful, because a fatal error occurred either
58at the protocol level or a connection failure occurred. The shutdown was
59not clean. It can also occur of action is need to continue the operation
60for non-blocking BIOs. Call SSL_get_error() with the return value B<ret>
61to find out the reason.
62
63=back
64
65=head1 SEE ALSO
66
67L<SSL_get_error(3)|SSL_get_error(3)>, L<SSL_accept(3)|SSL_accept(3)>,
68L<SSL_shutdown(3)|SSL_shutdown(3)>, L<ssl(3)|ssl(3)>, L<bio(3)|bio(3)>,
69L<SSL_set_connect_state(3)|SSL_set_connect_state(3)>,
70L<SSL_do_handshake(3)|SSL_do_handshake(3)>,
71L<SSL_CTX_new(3)|SSL_CTX_new(3)>
72
73=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_do_handshake.3 b/src/lib/libssl/src/doc/ssl/SSL_do_handshake.3
new file mode 100644
index 0000000000..8e6e0a820b
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_do_handshake.pod b/src/lib/libssl/src/doc/ssl/SSL_do_handshake.pod
deleted file mode 100644
index 1ca18d4723..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_do_handshake.pod
+++ /dev/null
@@ -1,75 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_do_handshake - perform a TLS/SSL handshake
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 int SSL_do_handshake(SSL *ssl);
12
13=head1 DESCRIPTION
14
15SSL_do_handshake() will wait for a SSL/TLS handshake to take place. If the
16connection is in client mode, the handshake will be started. The handshake
17routines may have to be explicitly set in advance using either
18L<SSL_set_connect_state(3)|SSL_set_connect_state(3)> or
19L<SSL_set_accept_state(3)|SSL_set_accept_state(3)>.
20
21=head1 NOTES
22
23The behaviour of SSL_do_handshake() depends on the underlying BIO.
24
25If the underlying BIO is B<blocking>, SSL_do_handshake() will only return
26once the handshake has been finished or an error occurred, except for SGC
27(Server Gated Cryptography). For SGC, SSL_do_handshake() may return with -1,
28but SSL_get_error() will yield B<SSL_ERROR_WANT_READ/WRITE> and
29SSL_do_handshake() should be called again.
30
31If the underlying BIO is B<non-blocking>, SSL_do_handshake() will also return
32when the underlying BIO could not satisfy the needs of SSL_do_handshake()
33to continue the handshake. In this case a call to SSL_get_error() with the
34return value of SSL_do_handshake() will yield B<SSL_ERROR_WANT_READ> or
35B<SSL_ERROR_WANT_WRITE>. The calling process then must repeat the call after
36taking appropriate action to satisfy the needs of SSL_do_handshake().
37The action depends on the underlying BIO. When using a non-blocking socket,
38nothing is to be done, but select() can be used to check for the required
39condition. When using a buffering BIO, like a BIO pair, data must be written
40into or retrieved out of the BIO before being able to continue.
41
42=head1 RETURN VALUES
43
44The following return values can occur:
45
46=over 4
47
48=item C<0>
49
50The TLS/SSL handshake was not successful but was shut down controlled and
51by the specifications of the TLS/SSL protocol. Call SSL_get_error() with the
52return value B<ret> to find out the reason.
53
54=item C<1>
55
56The TLS/SSL handshake was successfully completed, a TLS/SSL connection has been
57established.
58
59=item C<E<lt>0>
60
61The TLS/SSL handshake was not successful because a fatal error occurred either
62at the protocol level or a connection failure occurred. The shutdown was
63not clean. It can also occur of action is need to continue the operation
64for non-blocking BIOs. Call SSL_get_error() with the return value B<ret>
65to find out the reason.
66
67=back
68
69=head1 SEE ALSO
70
71L<SSL_get_error(3)|SSL_get_error(3)>, L<SSL_connect(3)|SSL_connect(3)>,
72L<SSL_accept(3)|SSL_accept(3)>, L<ssl(3)|ssl(3)>, L<bio(3)|bio(3)>,
73L<SSL_set_connect_state(3)|SSL_set_connect_state(3)>
74
75=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_free.3 b/src/lib/libssl/src/doc/ssl/SSL_free.3
new file mode 100644
index 0000000000..453cd7d424
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_free.pod b/src/lib/libssl/src/doc/ssl/SSL_free.pod
deleted file mode 100644
index 61603d833b..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_free.pod
+++ /dev/null
@@ -1,46 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_free - free an allocated SSL structure
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 void SSL_free(SSL *ssl);
12
13=head1 DESCRIPTION
14
15SSL_free() decrements the reference count of B<ssl>, and removes the SSL
16structure pointed to by B<ssl> and frees up the allocated memory if the
17reference count has reached 0.
18
19=head1 NOTES
20
21SSL_free() also calls the free()ing procedures for indirectly affected items, if
22applicable: the buffering BIO, the read and write BIOs,
23cipher lists specially created for this B<ssl>, the B<SSL_SESSION>.
24Do not explicitly free these indirectly freed up items before or after
25calling SSL_free(), as trying to free things twice may lead to program
26failure.
27
28The ssl session has reference counts from two users: the SSL object, for
29which the reference count is removed by SSL_free() and the internal
30session cache. If the session is considered bad, because
31L<SSL_shutdown(3)|SSL_shutdown(3)> was not called for the connection
32and L<SSL_set_shutdown(3)|SSL_set_shutdown(3)> was not used to set the
33SSL_SENT_SHUTDOWN state, the session will also be removed
34from the session cache as required by RFC2246.
35
36=head1 RETURN VALUES
37
38SSL_free() does not provide diagnostic information.
39
40=head1 SEE ALSO
41
42L<SSL_new(3)|SSL_new(3)>, L<SSL_clear(3)|SSL_clear(3)>,
43L<SSL_shutdown(3)|SSL_shutdown(3)>, L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>,
44L<ssl(3)|ssl(3)>
45
46=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_SSL_CTX.3 b/src/lib/libssl/src/doc/ssl/SSL_get_SSL_CTX.3
new file mode 100644
index 0000000000..40effb512f
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_get_SSL_CTX.pod b/src/lib/libssl/src/doc/ssl/SSL_get_SSL_CTX.pod
deleted file mode 100644
index 659c482c79..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_get_SSL_CTX.pod
+++ /dev/null
@@ -1,26 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_get_SSL_CTX - get the SSL_CTX from which an SSL is created
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl);
12
13=head1 DESCRIPTION
14
15SSL_get_SSL_CTX() returns a pointer to the SSL_CTX object, from which
16B<ssl> was created with L<SSL_new(3)|SSL_new(3)>.
17
18=head1 RETURN VALUES
19
20The pointer to the SSL_CTX object is returned.
21
22=head1 SEE ALSO
23
24L<ssl(3)|ssl(3)>, L<SSL_new(3)|SSL_new(3)>
25
26=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_ciphers.3 b/src/lib/libssl/src/doc/ssl/SSL_get_ciphers.3
new file mode 100644
index 0000000000..f836988f39
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_get_ciphers.pod b/src/lib/libssl/src/doc/ssl/SSL_get_ciphers.pod
deleted file mode 100644
index aecadd9138..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_get_ciphers.pod
+++ /dev/null
@@ -1,42 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_get_ciphers, SSL_get_cipher_list - get list of available SSL_CIPHERs
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *ssl);
12 const char *SSL_get_cipher_list(const SSL *ssl, int priority);
13
14=head1 DESCRIPTION
15
16SSL_get_ciphers() returns the stack of available SSL_CIPHERs for B<ssl>,
17sorted by preference. If B<ssl> is NULL or no ciphers are available, NULL
18is returned.
19
20SSL_get_cipher_list() returns a pointer to the name of the SSL_CIPHER
21listed for B<ssl> with B<priority>. If B<ssl> is NULL, no ciphers are
22available, or there are less ciphers than B<priority> available, NULL
23is returned.
24
25=head1 NOTES
26
27The details of the ciphers obtained by SSL_get_ciphers() can be obtained using
28the L<SSL_CIPHER_get_name(3)|SSL_CIPHER_get_name(3)> family of functions.
29
30Call SSL_get_cipher_list() with B<priority> starting from 0 to obtain the
31sorted list of available ciphers, until NULL is returned.
32
33=head1 RETURN VALUES
34
35See DESCRIPTION
36
37=head1 SEE ALSO
38
39L<ssl(3)|ssl(3)>, L<SSL_CTX_set_cipher_list(3)|SSL_CTX_set_cipher_list(3)>,
40L<SSL_CIPHER_get_name(3)|SSL_CIPHER_get_name(3)>
41
42=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_client_CA_list.3 b/src/lib/libssl/src/doc/ssl/SSL_get_client_CA_list.3
new file mode 100644
index 0000000000..9c08a8e17d
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_get_client_CA_list.pod b/src/lib/libssl/src/doc/ssl/SSL_get_client_CA_list.pod
deleted file mode 100644
index 8b5ac0df2c..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_get_client_CA_list.pod
+++ /dev/null
@@ -1,53 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_get_client_CA_list, SSL_CTX_get_client_CA_list - get list of client CAs
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 STACK_OF(X509_NAME) *SSL_get_client_CA_list(const SSL *s);
12 STACK_OF(X509_NAME) *SSL_CTX_get_client_CA_list(const SSL_CTX *ctx);
13
14=head1 DESCRIPTION
15
16SSL_CTX_get_client_CA_list() returns the list of client CAs explicitly set for
17B<ctx> using L<SSL_CTX_set_client_CA_list(3)|SSL_CTX_set_client_CA_list(3)>.
18
19SSL_get_client_CA_list() returns the list of client CAs explicitly
20set for B<ssl> using SSL_set_client_CA_list() or B<ssl>'s SSL_CTX object with
21L<SSL_CTX_set_client_CA_list(3)|SSL_CTX_set_client_CA_list(3)>, when in
22server mode. In client mode, SSL_get_client_CA_list returns the list of
23client CAs sent from the server, if any.
24
25=head1 RETURN VALUES
26
27SSL_CTX_set_client_CA_list() and SSL_set_client_CA_list() do not return
28diagnostic information.
29
30SSL_CTX_add_client_CA() and SSL_add_client_CA() have the following return
31values:
32
33=over 4
34
35=item STACK_OF(X509_NAMES)
36
37List of CA names explicitly set (for B<ctx> or in server mode) or send
38by the server (client mode).
39
40=item NULL
41
42No client CA list was explicitly set (for B<ctx> or in server mode) or
43the server did not send a list of CAs (client mode).
44
45=back
46
47=head1 SEE ALSO
48
49L<ssl(3)|ssl(3)>,
50L<SSL_CTX_set_client_CA_list(3)|SSL_CTX_set_client_CA_list(3)>,
51L<SSL_CTX_set_client_cert_cb(3)|SSL_CTX_set_client_cert_cb(3)>
52
53=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_current_cipher.3 b/src/lib/libssl/src/doc/ssl/SSL_get_current_cipher.3
new file mode 100644
index 0000000000..ec1f2bb7df
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_get_current_cipher.pod b/src/lib/libssl/src/doc/ssl/SSL_get_current_cipher.pod
deleted file mode 100644
index 2f69109a7a..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_get_current_cipher.pod
+++ /dev/null
@@ -1,43 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_get_current_cipher, SSL_get_cipher, SSL_get_cipher_name,
6SSL_get_cipher_bits, SSL_get_cipher_version - get SSL_CIPHER of a connection
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 SSL_CIPHER *SSL_get_current_cipher(const SSL *ssl);
13 #define SSL_get_cipher(s) \
14 SSL_CIPHER_get_name(SSL_get_current_cipher(s))
15 #define SSL_get_cipher_name(s) \
16 SSL_CIPHER_get_name(SSL_get_current_cipher(s))
17 #define SSL_get_cipher_bits(s,np) \
18 SSL_CIPHER_get_bits(SSL_get_current_cipher(s),np)
19 #define SSL_get_cipher_version(s) \
20 SSL_CIPHER_get_version(SSL_get_current_cipher(s))
21
22=head1 DESCRIPTION
23
24SSL_get_current_cipher() returns a pointer to an SSL_CIPHER object containing
25the description of the actually used cipher of a connection established with
26the B<ssl> object.
27
28SSL_get_cipher() and SSL_get_cipher_name() are identical macros to obtain the
29name of the currently used cipher. SSL_get_cipher_bits() is a
30macro to obtain the number of secret/algorithm bits used and
31SSL_get_cipher_version() returns the protocol name.
32See L<SSL_CIPHER_get_name(3)|SSL_CIPHER_get_name(3)> for more details.
33
34=head1 RETURN VALUES
35
36SSL_get_current_cipher() returns the cipher actually used or NULL, when
37no session has been established.
38
39=head1 SEE ALSO
40
41L<ssl(3)|ssl(3)>, L<SSL_CIPHER_get_name(3)|SSL_CIPHER_get_name(3)>
42
43=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_default_timeout.3 b/src/lib/libssl/src/doc/ssl/SSL_get_default_timeout.3
new file mode 100644
index 0000000000..28ab34d5e8
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_get_default_timeout.pod b/src/lib/libssl/src/doc/ssl/SSL_get_default_timeout.pod
deleted file mode 100644
index a648a9b82d..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_get_default_timeout.pod
+++ /dev/null
@@ -1,41 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_get_default_timeout - get default session timeout value
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 long SSL_get_default_timeout(const SSL *ssl);
12
13=head1 DESCRIPTION
14
15SSL_get_default_timeout() returns the default timeout value assigned to
16SSL_SESSION objects negotiated for the protocol valid for B<ssl>.
17
18=head1 NOTES
19
20Whenever a new session is negotiated, it is assigned a timeout value,
21after which it will not be accepted for session reuse. If the timeout
22value was not explicitly set using
23L<SSL_CTX_set_timeout(3)|SSL_CTX_set_timeout(3)>, the hardcoded default
24timeout for the protocol will be used.
25
26SSL_get_default_timeout() return this hardcoded value, which is 300 seconds
27for all currently supported protocols (SSLv2, SSLv3, and TLSv1).
28
29=head1 RETURN VALUES
30
31See description.
32
33=head1 SEE ALSO
34
35L<ssl(3)|ssl(3)>,
36L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>,
37L<SSL_SESSION_get_time(3)|SSL_SESSION_get_time(3)>,
38L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)>,
39L<SSL_get_default_timeout(3)|SSL_get_default_timeout(3)>
40
41=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_error.3 b/src/lib/libssl/src/doc/ssl/SSL_get_error.3
new file mode 100644
index 0000000000..ad533f68c5
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_get_error.pod b/src/lib/libssl/src/doc/ssl/SSL_get_error.pod
deleted file mode 100644
index ba430bd18d..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_get_error.pod
+++ /dev/null
@@ -1,113 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_get_error - obtain result code for TLS/SSL I/O operation
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 int SSL_get_error(const SSL *ssl, int ret);
12
13=head1 DESCRIPTION
14
15SSL_get_error() returns a result code (suitable for the C "switch" statement)
16for a preceding call to SSL_connect(), SSL_accept(), SSL_do_handshake(),
17SSL_read(), SSL_peek(), or SSL_write() on B<ssl>. The value returned by that
18TLS/SSL I/O function must be passed to SSL_get_error() in parameter B<ret>.
19
20In addition to B<ssl> and B<ret>, SSL_get_error() inspects the
21current thread's OpenSSL error queue. Thus, SSL_get_error() must be
22used in the same thread that performed the TLS/SSL I/O operation, and no
23other OpenSSL function calls should appear in between. The current
24thread's error queue must be empty before the TLS/SSL I/O operation is
25attempted, or SSL_get_error() will not work reliably.
26
27=head1 RETURN VALUES
28
29The following return values can currently occur:
30
31=over 4
32
33=item SSL_ERROR_NONE
34
35The TLS/SSL I/O operation completed. This result code is returned
36if and only if B<ret E<gt> 0>.
37
38=item SSL_ERROR_ZERO_RETURN
39
40The TLS/SSL connection has been closed. If the protocol version is SSL 3.0
41or TLS 1.0, this result code is returned only if a closure
42alert has occurred in the protocol, i.e. if the connection has been
43closed cleanly. Note that in this case B<SSL_ERROR_ZERO_RETURN>
44does not necessarily indicate that the underlying transport
45has been closed.
46
47=item SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE
48
49The operation did not complete; the same TLS/SSL I/O function should be
50called again later. If, by then, the underlying B<BIO> has data
51available for reading (if the result code is B<SSL_ERROR_WANT_READ>)
52or allows writing data (B<SSL_ERROR_WANT_WRITE>), then some TLS/SSL
53protocol progress will take place, i.e. at least part of an TLS/SSL
54record will be read or written. Note that the retry may again lead to
55a B<SSL_ERROR_WANT_READ> or B<SSL_ERROR_WANT_WRITE> condition.
56There is no fixed upper limit for the number of iterations that
57may be necessary until progress becomes visible at application
58protocol level.
59
60For socket B<BIO>s (e.g. when SSL_set_fd() was used), select() or
61poll() on the underlying socket can be used to find out when the
62TLS/SSL I/O function should be retried.
63
64Caveat: Any TLS/SSL I/O function can lead to either of
65B<SSL_ERROR_WANT_READ> and B<SSL_ERROR_WANT_WRITE>. In particular,
66SSL_read() or SSL_peek() may want to write data and SSL_write() may want
67to read data. This is mainly because TLS/SSL handshakes may occur at any
68time during the protocol (initiated by either the client or the server);
69SSL_read(), SSL_peek(), and SSL_write() will handle any pending handshakes.
70
71=item SSL_ERROR_WANT_CONNECT, SSL_ERROR_WANT_ACCEPT
72
73The operation did not complete; the same TLS/SSL I/O function should be
74called again later. The underlying BIO was not connected yet to the peer
75and the call would block in connect()/accept(). The SSL function should be
76called again when the connection is established. These messages can only
77appear with a BIO_s_connect() or BIO_s_accept() BIO, respectively.
78In order to find out, when the connection has been successfully established,
79on many platforms select() or poll() for writing on the socket file descriptor
80can be used.
81
82=item SSL_ERROR_WANT_X509_LOOKUP
83
84The operation did not complete because an application callback set by
85SSL_CTX_set_client_cert_cb() has asked to be called again.
86The TLS/SSL I/O function should be called again later.
87Details depend on the application.
88
89=item SSL_ERROR_SYSCALL
90
91Some I/O error occurred. The OpenSSL error queue may contain more
92information on the error. If the error queue is empty
93(i.e. ERR_get_error() returns 0), B<ret> can be used to find out more
94about the error: If B<ret == 0>, an EOF was observed that violates
95the protocol. If B<ret == -1>, the underlying B<BIO> reported an
96I/O error (for socket I/O on Unix systems, consult B<errno> for details).
97
98=item SSL_ERROR_SSL
99
100A failure in the SSL library occurred, usually a protocol error. The
101OpenSSL error queue contains more information on the error.
102
103=back
104
105=head1 SEE ALSO
106
107L<ssl(3)|ssl(3)>, L<err(3)|err(3)>
108
109=head1 HISTORY
110
111SSL_get_error() was added in SSLeay 0.8.
112
113=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_ex_data_X509_STORE_CTX_idx.3 b/src/lib/libssl/src/doc/ssl/SSL_get_ex_data_X509_STORE_CTX_idx.3
new file mode 100644
index 0000000000..9151f1d989
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_get_ex_data_X509_STORE_CTX_idx.pod b/src/lib/libssl/src/doc/ssl/SSL_get_ex_data_X509_STORE_CTX_idx.pod
deleted file mode 100644
index 165c6a5b2c..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_get_ex_data_X509_STORE_CTX_idx.pod
+++ /dev/null
@@ -1,61 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_get_ex_data_X509_STORE_CTX_idx - get ex_data index to access SSL structure
6from X509_STORE_CTX
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 int SSL_get_ex_data_X509_STORE_CTX_idx(void);
13
14=head1 DESCRIPTION
15
16SSL_get_ex_data_X509_STORE_CTX_idx() returns the index number under which
17the pointer to the SSL object is stored into the X509_STORE_CTX object.
18
19=head1 NOTES
20
21Whenever a X509_STORE_CTX object is created for the verification of the
22peers certificate during a handshake, a pointer to the SSL object is
23stored into the X509_STORE_CTX object to identify the connection affected.
24To retrieve this pointer the X509_STORE_CTX_get_ex_data() function can
25be used with the correct index. This index is globally the same for all
26X509_STORE_CTX objects and can be retrieved using
27SSL_get_ex_data_X509_STORE_CTX_idx(). The index value is set when
28SSL_get_ex_data_X509_STORE_CTX_idx() is first called either by the application
29program directly or indirectly during other SSL setup functions or during
30the handshake.
31
32The value depends on other index values defined for X509_STORE_CTX objects
33before the SSL index is created.
34
35=head1 RETURN VALUES
36
37=over 4
38
39=item E<gt>=0
40
41The index value to access the pointer.
42
43=item E<lt>0
44
45An error occurred, check the error stack for a detailed error message.
46
47=back
48
49=head1 EXAMPLES
50
51The index returned from SSL_get_ex_data_X509_STORE_CTX_idx() allows to
52access the SSL object for the connection to be accessed during the
53verify_callback() when checking the peers certificate. Please check
54the example in L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>,
55
56=head1 SEE ALSO
57
58L<ssl(3)|ssl(3)>, L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>,
59L<CRYPTO_set_ex_data(3)|CRYPTO_set_ex_data(3)>
60
61=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_ex_new_index.3 b/src/lib/libssl/src/doc/ssl/SSL_get_ex_new_index.3
new file mode 100644
index 0000000000..5b1ff19c54
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_get_ex_new_index.pod b/src/lib/libssl/src/doc/ssl/SSL_get_ex_new_index.pod
deleted file mode 100644
index 394ae1a406..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_get_ex_new_index.pod
+++ /dev/null
@@ -1,60 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_get_ex_new_index, SSL_set_ex_data, SSL_get_ex_data - internal application
6specific data functions
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 int SSL_get_ex_new_index(long argl, void *argp,
13 CRYPTO_EX_new *new_func,
14 CRYPTO_EX_dup *dup_func,
15 CRYPTO_EX_free *free_func);
16
17 int SSL_set_ex_data(SSL *ssl, int idx, void *arg);
18
19 void *SSL_get_ex_data(const SSL *ssl, int idx);
20
21 typedef int new_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
22 int idx, long argl, void *argp);
23 typedef void free_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
24 int idx, long argl, void *argp);
25 typedef int dup_func(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
26 int idx, long argl, void *argp);
27
28=head1 DESCRIPTION
29
30Several OpenSSL structures can have application specific data attached to them.
31These functions are used internally by OpenSSL to manipulate application
32specific data attached to a specific structure.
33
34SSL_get_ex_new_index() is used to register a new index for application
35specific data.
36
37SSL_set_ex_data() is used to store application data at B<arg> for B<idx> into
38the B<ssl> object.
39
40SSL_get_ex_data() is used to retrieve the information for B<idx> from
41B<ssl>.
42
43A detailed description for the B<*_get_ex_new_index()> functionality
44can be found in L<RSA_get_ex_new_index(3)|RSA_get_ex_new_index(3)>.
45The B<*_get_ex_data()> and B<*_set_ex_data()> functionality is described in
46L<CRYPTO_set_ex_data(3)|CRYPTO_set_ex_data(3)>.
47
48=head1 EXAMPLES
49
50An example on how to use the functionality is included in the example
51verify_callback() in L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>.
52
53=head1 SEE ALSO
54
55L<ssl(3)|ssl(3)>,
56L<RSA_get_ex_new_index(3)|RSA_get_ex_new_index(3)>,
57L<CRYPTO_set_ex_data(3)|CRYPTO_set_ex_data(3)>,
58L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>
59
60=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_fd.3 b/src/lib/libssl/src/doc/ssl/SSL_get_fd.3
new file mode 100644
index 0000000000..458e73dacc
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_get_fd.pod b/src/lib/libssl/src/doc/ssl/SSL_get_fd.pod
deleted file mode 100644
index 19e52d68d0..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_get_fd.pod
+++ /dev/null
@@ -1,44 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_get_fd, SSL_get_rfd, SSL_get_wfd - get file descriptor linked to an SSL object
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 int SSL_get_fd(const SSL *ssl);
12 int SSL_get_rfd(const SSL *ssl);
13 int SSL_get_wfd(const SSL *ssl);
14
15=head1 DESCRIPTION
16
17SSL_get_fd() returns the file descriptor which is linked to B<ssl>.
18SSL_get_rfd() and SSL_get_wfd() return the file descriptors for the
19read or the write channel, which can be different. If the read and the
20write channel are different, SSL_get_fd() will return the file descriptor
21of the read channel.
22
23=head1 RETURN VALUES
24
25The following return values can occur:
26
27=over 4
28
29=item -1
30
31The operation failed, because the underlying BIO is not of the correct type
32(suitable for file descriptors).
33
34=item E<gt>=0
35
36The file descriptor linked to B<ssl>.
37
38=back
39
40=head1 SEE ALSO
41
42L<SSL_set_fd(3)|SSL_set_fd(3)>, L<ssl(3)|ssl(3)> , L<bio(3)|bio(3)>
43
44=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_peer_cert_chain.3 b/src/lib/libssl/src/doc/ssl/SSL_get_peer_cert_chain.3
new file mode 100644
index 0000000000..850e8cf913
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_get_peer_cert_chain.pod b/src/lib/libssl/src/doc/ssl/SSL_get_peer_cert_chain.pod
deleted file mode 100644
index 059376c76b..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_get_peer_cert_chain.pod
+++ /dev/null
@@ -1,52 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_get_peer_cert_chain - get the X509 certificate chain of the peer
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 STACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *ssl);
12
13=head1 DESCRIPTION
14
15SSL_get_peer_cert_chain() returns a pointer to STACK_OF(X509) certificates
16forming the certificate chain of the peer. If called on the client side,
17the stack also contains the peer's certificate; if called on the server
18side, the peer's certificate must be obtained separately using
19L<SSL_get_peer_certificate(3)|SSL_get_peer_certificate(3)>.
20If the peer did not present a certificate, NULL is returned.
21
22=head1 NOTES
23
24The peer certificate chain is not necessarily available after reusing
25a session, in which case a NULL pointer is returned.
26
27The reference count of the STACK_OF(X509) object is not incremented.
28If the corresponding session is freed, the pointer must not be used
29any longer.
30
31=head1 RETURN VALUES
32
33The following return values can occur:
34
35=over 4
36
37=item NULL
38
39No certificate was presented by the peer or no connection was established
40or the certificate chain is no longer available when a session is reused.
41
42=item Pointer to a STACK_OF(X509)
43
44The return value points to the certificate chain presented by the peer.
45
46=back
47
48=head1 SEE ALSO
49
50L<ssl(3)|ssl(3)>, L<SSL_get_peer_certificate(3)|SSL_get_peer_certificate(3)>
51
52=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_peer_certificate.3 b/src/lib/libssl/src/doc/ssl/SSL_get_peer_certificate.3
new file mode 100644
index 0000000000..7e4ab3fccf
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_get_peer_certificate.pod b/src/lib/libssl/src/doc/ssl/SSL_get_peer_certificate.pod
deleted file mode 100644
index ef7c8be180..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_get_peer_certificate.pod
+++ /dev/null
@@ -1,55 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_get_peer_certificate - get the X509 certificate of the peer
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 X509 *SSL_get_peer_certificate(const SSL *ssl);
12
13=head1 DESCRIPTION
14
15SSL_get_peer_certificate() returns a pointer to the X509 certificate the
16peer presented. If the peer did not present a certificate, NULL is returned.
17
18=head1 NOTES
19
20Due to the protocol definition, a TLS/SSL server will always send a
21certificate, if present. A client will only send a certificate when
22explicitly requested to do so by the server (see
23L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>). If an anonymous cipher
24is used, no certificates are sent.
25
26That a certificate is returned does not indicate information about the
27verification state, use L<SSL_get_verify_result(3)|SSL_get_verify_result(3)>
28to check the verification state.
29
30The reference count of the X509 object is incremented by one, so that it
31will not be destroyed when the session containing the peer certificate is
32freed. The X509 object must be explicitly freed using X509_free().
33
34=head1 RETURN VALUES
35
36The following return values can occur:
37
38=over 4
39
40=item NULL
41
42No certificate was presented by the peer or no connection was established.
43
44=item Pointer to an X509 certificate
45
46The return value points to the certificate presented by the peer.
47
48=back
49
50=head1 SEE ALSO
51
52L<ssl(3)|ssl(3)>, L<SSL_get_verify_result(3)|SSL_get_verify_result(3)>,
53L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>
54
55=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_psk_identity.3 b/src/lib/libssl/src/doc/ssl/SSL_get_psk_identity.3
new file mode 100644
index 0000000000..b3a72cca29
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_get_psk_identity.pod b/src/lib/libssl/src/doc/ssl/SSL_get_psk_identity.pod
deleted file mode 100644
index 6fc72b31b4..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_get_psk_identity.pod
+++ /dev/null
@@ -1,64 +0,0 @@
1=pod
2
3=begin comment
4
5Copyright 2005 Nokia. All rights reserved.
6
7The portions of the attached software ("Contribution") is developed by
8Nokia Corporation and is licensed pursuant to the OpenSSL open source
9license.
10
11The Contribution, originally written by Mika Kousa and Pasi Eronen of
12Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites
13support (see RFC 4279) to OpenSSL.
14
15No patent licenses or other rights except those expressly stated in
16the OpenSSL open source license shall be deemed granted or received
17expressly, by implication, estoppel, or otherwise.
18
19No assurances are provided by Nokia that the Contribution does not
20infringe the patent or other intellectual property rights of any third
21party or that the license provides you with all the necessary rights
22to make use of the Contribution.
23
24THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN
25ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA
26SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY
27OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR
28OTHERWISE.
29
30=end comment
31
32=head1 NAME
33
34SSL_get_psk_identity, SSL_get_psk_identity_hint - get PSK client identity and
35hint
36
37
38=head1 SYNOPSIS
39
40 #include <openssl/ssl.h>
41
42 const char *SSL_get_psk_identity_hint(const SSL *ssl);
43 const char *SSL_get_psk_identity(const SSL *ssl);
44
45
46=head1 DESCRIPTION
47
48SSL_get_psk_identity_hint() is used to retrieve the PSK identity hint
49used during the connection setup related to SSL object
50B<ssl>. Similarly, SSL_get_psk_identity() is used to retrieve the PSK
51identity used during the connection setup.
52
53
54=head1 RETURN VALUES
55
56If non-B<NULL>, SSL_get_psk_identity_hint() returns the PSK identity
57hint and SSL_get_psk_identity() returns the PSK identity. Both are
58B<NULL>-terminated. SSL_get_psk_identity_hint() may return B<NULL> if
59no PSK identity hint was used during the connection setup.
60
61Note that the return value is valid only during the lifetime of the
62SSL object B<ssl>.
63
64=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_rbio.3 b/src/lib/libssl/src/doc/ssl/SSL_get_rbio.3
new file mode 100644
index 0000000000..a8370d5ef2
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_get_rbio.pod b/src/lib/libssl/src/doc/ssl/SSL_get_rbio.pod
deleted file mode 100644
index 08dea6a6cd..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_get_rbio.pod
+++ /dev/null
@@ -1,40 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_get_rbio, SSL_get_wbio - get BIO linked to an SSL object
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 BIO *SSL_get_rbio(SSL *ssl);
12 BIO *SSL_get_wbio(SSL *ssl);
13
14=head1 DESCRIPTION
15
16SSL_get_rbio() and SSL_get_wbio() return pointers to the BIOs for the
17read or the write channel, which can be different. The reference count
18of the BIO is not incremented.
19
20=head1 RETURN VALUES
21
22The following return values can occur:
23
24=over 4
25
26=item NULL
27
28No BIO was connected to the SSL object
29
30=item Any other pointer
31
32The BIO linked to B<ssl>.
33
34=back
35
36=head1 SEE ALSO
37
38L<SSL_set_bio(3)|SSL_set_bio(3)>, L<ssl(3)|ssl(3)> , L<bio(3)|bio(3)>
39
40=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_session.3 b/src/lib/libssl/src/doc/ssl/SSL_get_session.3
new file mode 100644
index 0000000000..fe9a6d48ef
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_get_session.pod b/src/lib/libssl/src/doc/ssl/SSL_get_session.pod
deleted file mode 100644
index 1a30f7bb5f..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_get_session.pod
+++ /dev/null
@@ -1,73 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_get_session, SSL_get0_session, SSL_get1_session - retrieve TLS/SSL session data
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 SSL_SESSION *SSL_get_session(const SSL *ssl);
12 SSL_SESSION *SSL_get0_session(const SSL *ssl);
13 SSL_SESSION *SSL_get1_session(SSL *ssl);
14
15=head1 DESCRIPTION
16
17SSL_get_session() returns a pointer to the B<SSL_SESSION> actually used in
18B<ssl>. The reference count of the B<SSL_SESSION> is not incremented, so
19that the pointer can become invalid by other operations.
20
21SSL_get0_session() is the same as SSL_get_session().
22
23SSL_get1_session() is the same as SSL_get_session(), but the reference
24count of the B<SSL_SESSION> is incremented by one.
25
26=head1 NOTES
27
28The ssl session contains all information required to re-establish the
29connection without a new handshake.
30
31SSL_get0_session() returns a pointer to the actual session. As the
32reference counter is not incremented, the pointer is only valid while
33the connection is in use. If L<SSL_clear(3)|SSL_clear(3)> or
34L<SSL_free(3)|SSL_free(3)> is called, the session may be removed completely
35(if considered bad), and the pointer obtained will become invalid. Even
36if the session is valid, it can be removed at any time due to timeout
37during L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)>.
38
39If the data is to be kept, SSL_get1_session() will increment the reference
40count, so that the session will not be implicitly removed by other operations
41but stays in memory. In order to remove the session
42L<SSL_SESSION_free(3)|SSL_SESSION_free(3)> must be explicitly called once
43to decrement the reference count again.
44
45SSL_SESSION objects keep internal link information about the session cache
46list, when being inserted into one SSL_CTX object's session cache.
47One SSL_SESSION object, regardless of its reference count, must therefore
48only be used with one SSL_CTX object (and the SSL objects created
49from this SSL_CTX object).
50
51=head1 RETURN VALUES
52
53The following return values can occur:
54
55=over 4
56
57=item NULL
58
59There is no session available in B<ssl>.
60
61=item Pointer to an SSL
62
63The return value points to the data of an SSL session.
64
65=back
66
67=head1 SEE ALSO
68
69L<ssl(3)|ssl(3)>, L<SSL_free(3)|SSL_free(3)>,
70L<SSL_clear(3)|SSL_clear(3)>,
71L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>
72
73=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_verify_result.3 b/src/lib/libssl/src/doc/ssl/SSL_get_verify_result.3
new file mode 100644
index 0000000000..3409dc0698
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_get_verify_result.pod b/src/lib/libssl/src/doc/ssl/SSL_get_verify_result.pod
deleted file mode 100644
index 55b56a53f9..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_get_verify_result.pod
+++ /dev/null
@@ -1,57 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_get_verify_result - get result of peer certificate verification
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 long SSL_get_verify_result(const SSL *ssl);
12
13=head1 DESCRIPTION
14
15SSL_get_verify_result() returns the result of the verification of the
16X509 certificate presented by the peer, if any.
17
18=head1 NOTES
19
20SSL_get_verify_result() can only return one error code while the verification
21of a certificate can fail because of many reasons at the same time. Only
22the last verification error that occurred during the processing is available
23from SSL_get_verify_result().
24
25The verification result is part of the established session and is restored
26when a session is reused.
27
28=head1 BUGS
29
30If no peer certificate was presented, the returned result code is
31X509_V_OK. This is because no verification error occurred, it does however
32not indicate success. SSL_get_verify_result() is only useful in connection
33with L<SSL_get_peer_certificate(3)|SSL_get_peer_certificate(3)>.
34
35=head1 RETURN VALUES
36
37The following return values can currently occur:
38
39=over 4
40
41=item X509_V_OK
42
43The verification succeeded or no peer certificate was presented.
44
45=item Any other value
46
47Documented in L<verify(1)|verify(1)>.
48
49=back
50
51=head1 SEE ALSO
52
53L<ssl(3)|ssl(3)>, L<SSL_set_verify_result(3)|SSL_set_verify_result(3)>,
54L<SSL_get_peer_certificate(3)|SSL_get_peer_certificate(3)>,
55L<verify(1)|verify(1)>
56
57=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_version.3 b/src/lib/libssl/src/doc/ssl/SSL_get_version.3
new file mode 100644
index 0000000000..f8fe406d44
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_get_version.pod b/src/lib/libssl/src/doc/ssl/SSL_get_version.pod
deleted file mode 100644
index 9ae6f25508..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_get_version.pod
+++ /dev/null
@@ -1,54 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_get_version - get the protocol version of a connection.
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 const char *SSL_get_version(const SSL *ssl);
12
13=head1 DESCRIPTION
14
15SSL_get_version() returns the name of the protocol used for the
16connection B<ssl>.
17
18=head1 RETURN VALUES
19
20The following strings can be returned:
21
22=over 4
23
24=item SSLv2
25
26The connection uses the SSLv2 protocol.
27
28=item SSLv3
29
30The connection uses the SSLv3 protocol.
31
32=item TLSv1
33
34The connection uses the TLSv1.0 protocol.
35
36=item TLSv1.1
37
38The connection uses the TLSv1.1 protocol.
39
40=item TLSv1.2
41
42The connection uses the TLSv1.2 protocol.
43
44=item unknown
45
46This indicates that no version has been set (no connection established).
47
48=back
49
50=head1 SEE ALSO
51
52L<ssl(3)|ssl(3)>
53
54=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_library_init.3 b/src/lib/libssl/src/doc/ssl/SSL_library_init.3
new file mode 100644
index 0000000000..0644ebd987
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_library_init.pod b/src/lib/libssl/src/doc/ssl/SSL_library_init.pod
deleted file mode 100644
index 4767c0ba8b..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_library_init.pod
+++ /dev/null
@@ -1,57 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_library_init, OpenSSL_add_ssl_algorithms, SSLeay_add_ssl_algorithms
6- initialize SSL library by registering algorithms
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 int SSL_library_init(void);
13 #define OpenSSL_add_ssl_algorithms() SSL_library_init()
14 #define SSLeay_add_ssl_algorithms() SSL_library_init()
15
16=head1 DESCRIPTION
17
18SSL_library_init() registers the available SSL/TLS ciphers and digests.
19
20OpenSSL_add_ssl_algorithms() and SSLeay_add_ssl_algorithms() are synonyms
21for SSL_library_init().
22
23=head1 NOTES
24
25SSL_library_init() must be called before any other action takes place.
26SSL_library_init() is not reentrant.
27
28=head1 WARNING
29
30SSL_library_init() adds ciphers and digests used directly and indirectly by
31SSL/TLS.
32
33=head1 EXAMPLES
34
35A typical TLS/SSL application will start with the library initialization,
36and provide readable error messages.
37
38 SSL_load_error_strings(); /* readable error messages */
39 SSL_library_init(); /* initialize library */
40
41=head1 RETURN VALUES
42
43SSL_library_init() always returns "1", so it is safe to discard the return
44value.
45
46=head1 NOTES
47
48OpenSSL 0.9.8o and 1.0.0a and later added SHA2 algorithms to SSL_library_init().
49Applications which need to use SHA2 in earlier versions of OpenSSL should call
50OpenSSL_add_all_algorithms() as well.
51
52=head1 SEE ALSO
53
54L<ssl(3)|ssl(3)>, L<SSL_load_error_strings(3)|SSL_load_error_strings(3)>,
55L<RAND_add(3)|RAND_add(3)>
56
57=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_load_client_CA_file.3 b/src/lib/libssl/src/doc/ssl/SSL_load_client_CA_file.3
new file mode 100644
index 0000000000..52d21e8e31
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_load_client_CA_file.pod b/src/lib/libssl/src/doc/ssl/SSL_load_client_CA_file.pod
deleted file mode 100644
index 5aa2b73447..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_load_client_CA_file.pod
+++ /dev/null
@@ -1,62 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_load_client_CA_file - load certificate names from file
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file);
12
13=head1 DESCRIPTION
14
15SSL_load_client_CA_file() reads certificates from B<file> and returns
16a STACK_OF(X509_NAME) with the subject names found.
17
18=head1 NOTES
19
20SSL_load_client_CA_file() reads a file of PEM formatted certificates and
21extracts the X509_NAMES of the certificates found. While the name suggests
22the specific usage as support function for
23L<SSL_CTX_set_client_CA_list(3)|SSL_CTX_set_client_CA_list(3)>,
24it is not limited to CA certificates.
25
26=head1 EXAMPLES
27
28Load names of CAs from file and use it as a client CA list:
29
30 SSL_CTX *ctx;
31 STACK_OF(X509_NAME) *cert_names;
32
33 ...
34 cert_names = SSL_load_client_CA_file("/path/to/CAfile.pem");
35 if (cert_names != NULL)
36 SSL_CTX_set_client_CA_list(ctx, cert_names);
37 else
38 error_handling();
39 ...
40
41=head1 RETURN VALUES
42
43The following return values can occur:
44
45=over 4
46
47=item NULL
48
49The operation failed, check out the error stack for the reason.
50
51=item Pointer to STACK_OF(X509_NAME)
52
53Pointer to the subject names of the successfully read certificates.
54
55=back
56
57=head1 SEE ALSO
58
59L<ssl(3)|ssl(3)>,
60L<SSL_CTX_set_client_CA_list(3)|SSL_CTX_set_client_CA_list(3)>
61
62=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_new.3 b/src/lib/libssl/src/doc/ssl/SSL_new.3
new file mode 100644
index 0000000000..3c5b303bbb
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_new.pod b/src/lib/libssl/src/doc/ssl/SSL_new.pod
deleted file mode 100644
index 25300e978f..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_new.pod
+++ /dev/null
@@ -1,44 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_new - create a new SSL structure for a connection
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 SSL *SSL_new(SSL_CTX *ctx);
12
13=head1 DESCRIPTION
14
15SSL_new() creates a new B<SSL> structure which is needed to hold the
16data for a TLS/SSL connection. The new structure inherits the settings
17of the underlying context B<ctx>: connection method (SSLv2/v3/TLSv1),
18options, verification settings, timeout settings.
19
20=head1 RETURN VALUES
21
22The following return values can occur:
23
24=over 4
25
26=item NULL
27
28The creation of a new SSL structure failed. Check the error stack to
29find out the reason.
30
31=item Pointer to an SSL structure
32
33The return value points to an allocated SSL structure.
34
35=back
36
37=head1 SEE ALSO
38
39L<SSL_free(3)|SSL_free(3)>, L<SSL_clear(3)|SSL_clear(3)>,
40L<SSL_CTX_set_options(3)|SSL_CTX_set_options(3)>,
41L<SSL_get_SSL_CTX(3)|SSL_get_SSL_CTX(3)>,
42L<ssl(3)|ssl(3)>
43
44=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_pending.3 b/src/lib/libssl/src/doc/ssl/SSL_pending.3
new file mode 100644
index 0000000000..e07ba48283
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_pending.pod b/src/lib/libssl/src/doc/ssl/SSL_pending.pod
deleted file mode 100644
index 43f2874e8b..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_pending.pod
+++ /dev/null
@@ -1,43 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_pending - obtain number of readable bytes buffered in an SSL object
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 int SSL_pending(const SSL *ssl);
12
13=head1 DESCRIPTION
14
15SSL_pending() returns the number of bytes which are available inside
16B<ssl> for immediate read.
17
18=head1 NOTES
19
20Data are received in blocks from the peer. Therefore data can be buffered
21inside B<ssl> and are ready for immediate retrieval with
22L<SSL_read(3)|SSL_read(3)>.
23
24=head1 RETURN VALUES
25
26The number of bytes pending is returned.
27
28=head1 BUGS
29
30SSL_pending() takes into account only bytes from the TLS/SSL record
31that is currently being processed (if any). If the B<SSL> object's
32I<read_ahead> flag is set, additional protocol bytes may have been
33read containing more TLS/SSL records; these are ignored by
34SSL_pending().
35
36Up to OpenSSL 0.9.6, SSL_pending() does not check if the record type
37of pending data is application data.
38
39=head1 SEE ALSO
40
41L<SSL_read(3)|SSL_read(3)>, L<ssl(3)|ssl(3)>
42
43=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_read.3 b/src/lib/libssl/src/doc/ssl/SSL_read.3
new file mode 100644
index 0000000000..aed39c300f
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_read.pod b/src/lib/libssl/src/doc/ssl/SSL_read.pod
deleted file mode 100644
index 57dfbdfc28..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_read.pod
+++ /dev/null
@@ -1,124 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_read - read bytes from a TLS/SSL connection.
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 int SSL_read(SSL *ssl, void *buf, int num);
12
13=head1 DESCRIPTION
14
15SSL_read() tries to read B<num> bytes from the specified B<ssl> into the
16buffer B<buf>.
17
18=head1 NOTES
19
20If necessary, SSL_read() will negotiate a TLS/SSL session, if
21not already explicitly performed by L<SSL_connect(3)|SSL_connect(3)> or
22L<SSL_accept(3)|SSL_accept(3)>. If the
23peer requests a re-negotiation, it will be performed transparently during
24the SSL_read() operation. The behaviour of SSL_read() depends on the
25underlying BIO.
26
27For the transparent negotiation to succeed, the B<ssl> must have been
28initialized to client or server mode. This is being done by calling
29L<SSL_set_connect_state(3)|SSL_set_connect_state(3)> or SSL_set_accept_state()
30before the first call to an SSL_read() or L<SSL_write(3)|SSL_write(3)>
31function.
32
33SSL_read() works based on the SSL/TLS records. The data are received in
34records (with a maximum record size of 16kB for SSLv3/TLSv1). Only when a
35record has been completely received, it can be processed (decryption and
36check of integrity). Therefore data that was not retrieved at the last
37call of SSL_read() can still be buffered inside the SSL layer and will be
38retrieved on the next call to SSL_read(). If B<num> is higher than the
39number of bytes buffered, SSL_read() will return with the bytes buffered.
40If no more bytes are in the buffer, SSL_read() will trigger the processing
41of the next record. Only when the record has been received and processed
42completely, SSL_read() will return reporting success. At most the contents
43of the record will be returned. As the size of an SSL/TLS record may exceed
44the maximum packet size of the underlying transport (e.g. TCP), it may
45be necessary to read several packets from the transport layer before the
46record is complete and SSL_read() can succeed.
47
48If the underlying BIO is B<blocking>, SSL_read() will only return, once the
49read operation has been finished or an error occurred, except when a
50renegotiation take place, in which case a SSL_ERROR_WANT_READ may occur.
51This behaviour can be controlled with the SSL_MODE_AUTO_RETRY flag of the
52L<SSL_CTX_set_mode(3)|SSL_CTX_set_mode(3)> call.
53
54If the underlying BIO is B<non-blocking>, SSL_read() will also return
55when the underlying BIO could not satisfy the needs of SSL_read()
56to continue the operation. In this case a call to
57L<SSL_get_error(3)|SSL_get_error(3)> with the
58return value of SSL_read() will yield B<SSL_ERROR_WANT_READ> or
59B<SSL_ERROR_WANT_WRITE>. As at any time a re-negotiation is possible, a
60call to SSL_read() can also cause write operations! The calling process
61then must repeat the call after taking appropriate action to satisfy the
62needs of SSL_read(). The action depends on the underlying BIO. When using a
63non-blocking socket, nothing is to be done, but select() can be used to check
64for the required condition. When using a buffering BIO, like a BIO pair, data
65must be written into or retrieved out of the BIO before being able to continue.
66
67L<SSL_pending(3)|SSL_pending(3)> can be used to find out whether there
68are buffered bytes available for immediate retrieval. In this case
69SSL_read() can be called without blocking or actually receiving new
70data from the underlying socket.
71
72=head1 WARNING
73
74When an SSL_read() operation has to be repeated because of
75B<SSL_ERROR_WANT_READ> or B<SSL_ERROR_WANT_WRITE>, it must be repeated
76with the same arguments.
77
78=head1 RETURN VALUES
79
80The following return values can occur:
81
82=over 4
83
84=item C<E<gt>0>
85
86The read operation was successful; the return value is the number of
87bytes actually read from the TLS/SSL connection.
88
89=item C<0>
90
91The read operation was not successful. The reason may either be a clean
92shutdown due to a "close notify" alert sent by the peer (in which case
93the SSL_RECEIVED_SHUTDOWN flag in the ssl shutdown state is set
94(see L<SSL_shutdown(3)|SSL_shutdown(3)>,
95L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>). It is also possible, that
96the peer simply shut down the underlying transport and the shutdown is
97incomplete. Call SSL_get_error() with the return value B<ret> to find out,
98whether an error occurred or the connection was shut down cleanly
99(SSL_ERROR_ZERO_RETURN).
100
101SSLv2 (deprecated) does not support a shutdown alert protocol, so it can
102only be detected, whether the underlying connection was closed. It cannot
103be checked, whether the closure was initiated by the peer or by something
104else.
105
106=item C<E<lt>0>
107
108The read operation was not successful, because either an error occurred
109or action must be taken by the calling process. Call SSL_get_error() with the
110return value B<ret> to find out the reason.
111
112=back
113
114=head1 SEE ALSO
115
116L<SSL_get_error(3)|SSL_get_error(3)>, L<SSL_write(3)|SSL_write(3)>,
117L<SSL_CTX_set_mode(3)|SSL_CTX_set_mode(3)>, L<SSL_CTX_new(3)|SSL_CTX_new(3)>,
118L<SSL_connect(3)|SSL_connect(3)>, L<SSL_accept(3)|SSL_accept(3)>
119L<SSL_set_connect_state(3)|SSL_set_connect_state(3)>,
120L<SSL_pending(3)|SSL_pending(3)>,
121L<SSL_shutdown(3)|SSL_shutdown(3)>, L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>,
122L<ssl(3)|ssl(3)>, L<bio(3)|bio(3)>
123
124=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_rstate_string.3 b/src/lib/libssl/src/doc/ssl/SSL_rstate_string.3
new file mode 100644
index 0000000000..77fcd06eac
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_rstate_string.pod b/src/lib/libssl/src/doc/ssl/SSL_rstate_string.pod
deleted file mode 100644
index af72642210..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_rstate_string.pod
+++ /dev/null
@@ -1,60 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_rstate_string, SSL_rstate_string_long - get textual description of state of
6an SSL object during read operation
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 const char *SSL_rstate_string(SSL *ssl);
13 const char *SSL_rstate_string_long(SSL *ssl);
14
15=head1 DESCRIPTION
16
17SSL_rstate_string() returns a 2 letter string indicating the current read state
18of the SSL object B<ssl>.
19
20SSL_rstate_string_long() returns a string indicating the current read state of
21the SSL object B<ssl>.
22
23=head1 NOTES
24
25When performing a read operation, the SSL/TLS engine must parse the record,
26consisting of header and body. When working in a blocking environment,
27SSL_rstate_string[_long]() should always return "RD"/"read done".
28
29This function should only seldom be needed in applications.
30
31=head1 RETURN VALUES
32
33SSL_rstate_string() and SSL_rstate_string_long() can return the following
34values:
35
36=over 4
37
38=item "RH"/"read header"
39
40The header of the record is being evaluated.
41
42=item "RB"/"read body"
43
44The body of the record is being evaluated.
45
46=item "RD"/"read done"
47
48The record has been completely processed.
49
50=item "unknown"/"unknown"
51
52The read state is unknown. This should never happen.
53
54=back
55
56=head1 SEE ALSO
57
58L<ssl(3)|ssl(3)>
59
60=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_session_reused.3 b/src/lib/libssl/src/doc/ssl/SSL_session_reused.3
new file mode 100644
index 0000000000..40a88cd881
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_session_reused.pod b/src/lib/libssl/src/doc/ssl/SSL_session_reused.pod
deleted file mode 100644
index ef30d82e3d..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_session_reused.pod
+++ /dev/null
@@ -1,46 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_session_reused - query whether a reused session was negotiated during
6handshake
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 int SSL_session_reused(SSL *ssl);
13
14=head1 DESCRIPTION
15
16Query, whether a reused session was negotiated during the handshake.
17
18=head1 NOTES
19
20During the negotiation, a client can propose to reuse a session. The server
21then looks up the session in its cache. If both client and server agree
22on the session, it will be reused and a flag is being set that can be
23queried by the application.
24
25=head1 RETURN VALUES
26
27The following return values can occur:
28
29=over 4
30
31=item C<0>
32
33A new session was negotiated.
34
35=item C<1>
36
37A session was reused.
38
39=back
40
41=head1 SEE ALSO
42
43L<ssl(3)|ssl(3)>, L<SSL_set_session(3)|SSL_set_session(3)>,
44L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>
45
46=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_set_bio.3 b/src/lib/libssl/src/doc/ssl/SSL_set_bio.3
new file mode 100644
index 0000000000..62bc22370d
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_set_bio.pod b/src/lib/libssl/src/doc/ssl/SSL_set_bio.pod
deleted file mode 100644
index 67c9756d3f..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_set_bio.pod
+++ /dev/null
@@ -1,34 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_set_bio - connect the SSL object with a BIO
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 void SSL_set_bio(SSL *ssl, BIO *rbio, BIO *wbio);
12
13=head1 DESCRIPTION
14
15SSL_set_bio() connects the BIOs B<rbio> and B<wbio> for the read and write
16operations of the TLS/SSL (encrypted) side of B<ssl>.
17
18The SSL engine inherits the behaviour of B<rbio> and B<wbio>, respectively.
19If a BIO is non-blocking, the B<ssl> will also have non-blocking behaviour.
20
21If there was already a BIO connected to B<ssl>, BIO_free() will be called
22(for both the reading and writing side, if different).
23
24=head1 RETURN VALUES
25
26SSL_set_bio() cannot fail.
27
28=head1 SEE ALSO
29
30L<SSL_get_rbio(3)|SSL_get_rbio(3)>,
31L<SSL_connect(3)|SSL_connect(3)>, L<SSL_accept(3)|SSL_accept(3)>,
32L<SSL_shutdown(3)|SSL_shutdown(3)>, L<ssl(3)|ssl(3)>, L<bio(3)|bio(3)>
33
34=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_set_connect_state.3 b/src/lib/libssl/src/doc/ssl/SSL_set_connect_state.3
new file mode 100644
index 0000000000..37e52788a4
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_set_connect_state.pod b/src/lib/libssl/src/doc/ssl/SSL_set_connect_state.pod
deleted file mode 100644
index 1b19067b47..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_set_connect_state.pod
+++ /dev/null
@@ -1,56 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_set_connect_state, SSL_get_accept_state - prepare SSL object to work in
6client or server mode
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 void SSL_set_connect_state(SSL *ssl);
13
14 void SSL_set_accept_state(SSL *ssl);
15
16=head1 DESCRIPTION
17
18SSL_set_connect_state() sets B<ssl> to work in client mode.
19
20SSL_set_accept_state() sets B<ssl> to work in server mode.
21
22=head1 NOTES
23
24When the SSL_CTX object was created with L<SSL_CTX_new(3)|SSL_CTX_new(3)>,
25it was either assigned a dedicated client method, a dedicated server
26method, or a generic method, that can be used for both client and
27server connections. (The method might have been changed with
28L<SSL_CTX_set_ssl_version(3)|SSL_CTX_set_ssl_version(3)> or
29SSL_set_ssl_method().)
30
31When beginning a new handshake, the SSL engine must know whether it must
32call the connect (client) or accept (server) routines. Even though it may
33be clear from the method chosen, whether client or server mode was
34requested, the handshake routines must be explicitly set.
35
36When using the L<SSL_connect(3)|SSL_connect(3)> or
37L<SSL_accept(3)|SSL_accept(3)> routines, the correct handshake
38routines are automatically set. When performing a transparent negotiation
39using L<SSL_write(3)|SSL_write(3)> or L<SSL_read(3)|SSL_read(3)>, the
40handshake routines must be explicitly set in advance using either
41SSL_set_connect_state() or SSL_set_accept_state().
42
43=head1 RETURN VALUES
44
45SSL_set_connect_state() and SSL_set_accept_state() do not return diagnostic
46information.
47
48=head1 SEE ALSO
49
50L<ssl(3)|ssl(3)>, L<SSL_new(3)|SSL_new(3)>, L<SSL_CTX_new(3)|SSL_CTX_new(3)>,
51L<SSL_connect(3)|SSL_connect(3)>, L<SSL_accept(3)|SSL_accept(3)>,
52L<SSL_write(3)|SSL_write(3)>, L<SSL_read(3)|SSL_read(3)>,
53L<SSL_do_handshake(3)|SSL_do_handshake(3)>,
54L<SSL_CTX_set_ssl_version(3)|SSL_CTX_set_ssl_version(3)>
55
56=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_set_fd.3 b/src/lib/libssl/src/doc/ssl/SSL_set_fd.3
new file mode 100644
index 0000000000..94345ae236
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_set_fd.pod b/src/lib/libssl/src/doc/ssl/SSL_set_fd.pod
deleted file mode 100644
index 7f270c9fbc..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_set_fd.pod
+++ /dev/null
@@ -1,54 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_set_fd, SSL_set_rfd, SSL_set_wfd - connect the SSL object with a file descriptor
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 int SSL_set_fd(SSL *ssl, int fd);
12 int SSL_set_rfd(SSL *ssl, int fd);
13 int SSL_set_wfd(SSL *ssl, int fd);
14
15=head1 DESCRIPTION
16
17SSL_set_fd() sets the file descriptor B<fd> as the input/output facility
18for the TLS/SSL (encrypted) side of B<ssl>. B<fd> will typically be the
19socket file descriptor of a network connection.
20
21When performing the operation, a B<socket BIO> is automatically created to
22interface between the B<ssl> and B<fd>. The BIO and hence the SSL engine
23inherit the behaviour of B<fd>. If B<fd> is non-blocking, the B<ssl> will
24also have non-blocking behaviour.
25
26If there was already a BIO connected to B<ssl>, BIO_free() will be called
27(for both the reading and writing side, if different).
28
29SSL_set_rfd() and SSL_set_wfd() perform the respective action, but only
30for the read channel or the write channel, which can be set independently.
31
32=head1 RETURN VALUES
33
34The following return values can occur:
35
36=over 4
37
38=item C<0>
39
40The operation failed. Check the error stack to find out why.
41
42=item C<1>
43
44The operation succeeded.
45
46=back
47
48=head1 SEE ALSO
49
50L<SSL_get_fd(3)|SSL_get_fd(3)>, L<SSL_set_bio(3)|SSL_set_bio(3)>,
51L<SSL_connect(3)|SSL_connect(3)>, L<SSL_accept(3)|SSL_accept(3)>,
52L<SSL_shutdown(3)|SSL_shutdown(3)>, L<ssl(3)|ssl(3)> , L<bio(3)|bio(3)>
53
54=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_set_session.3 b/src/lib/libssl/src/doc/ssl/SSL_set_session.3
new file mode 100644
index 0000000000..3721b0e0e6
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_set_session.pod b/src/lib/libssl/src/doc/ssl/SSL_set_session.pod
deleted file mode 100644
index d35e6d3b7b..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_set_session.pod
+++ /dev/null
@@ -1,57 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_set_session - set a TLS/SSL session to be used during TLS/SSL connect
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 int SSL_set_session(SSL *ssl, SSL_SESSION *session);
12
13=head1 DESCRIPTION
14
15SSL_set_session() sets B<session> to be used when the TLS/SSL connection
16is to be established. SSL_set_session() is only useful for TLS/SSL clients.
17When the session is set, the reference count of B<session> is incremented
18by 1. If the session is not reused, the reference count is decremented
19again during SSL_connect(). Whether the session was reused can be queried
20with the L<SSL_session_reused(3)|SSL_session_reused(3)> call.
21
22If there is already a session set inside B<ssl> (because it was set with
23SSL_set_session() before or because the same B<ssl> was already used for
24a connection), SSL_SESSION_free() will be called for that session.
25
26=head1 NOTES
27
28SSL_SESSION objects keep internal link information about the session cache
29list, when being inserted into one SSL_CTX object's session cache.
30One SSL_SESSION object, regardless of its reference count, must therefore
31only be used with one SSL_CTX object (and the SSL objects created
32from this SSL_CTX object).
33
34=head1 RETURN VALUES
35
36The following return values can occur:
37
38=over 4
39
40=item C<0>
41
42The operation failed; check the error stack to find out the reason.
43
44=item C<1>
45
46The operation succeeded.
47
48=back
49
50=head1 SEE ALSO
51
52L<ssl(3)|ssl(3)>, L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>,
53L<SSL_get_session(3)|SSL_get_session(3)>,
54L<SSL_session_reused(3)|SSL_session_reused(3)>,
55L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>
56
57=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_set_shutdown.3 b/src/lib/libssl/src/doc/ssl/SSL_set_shutdown.3
new file mode 100644
index 0000000000..239bbd6801
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_set_shutdown.pod b/src/lib/libssl/src/doc/ssl/SSL_set_shutdown.pod
deleted file mode 100644
index f84da386a1..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_set_shutdown.pod
+++ /dev/null
@@ -1,73 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_set_shutdown, SSL_get_shutdown - manipulate shutdown state of an SSL
6connection
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 void SSL_set_shutdown(SSL *ssl, int mode);
13
14 int SSL_get_shutdown(const SSL *ssl);
15
16=head1 DESCRIPTION
17
18SSL_set_shutdown() sets the shutdown state of B<ssl> to B<mode>.
19
20SSL_get_shutdown() returns the shutdown mode of B<ssl>.
21
22=head1 NOTES
23
24The shutdown state of an ssl connection is a bitmask of:
25
26=over 4
27
28=item Z<>0
29
30No shutdown setting, yet.
31
32=item SSL_SENT_SHUTDOWN
33
34A "close notify" shutdown alert was sent to the peer, the connection is being
35considered closed and the session is closed and correct.
36
37=item SSL_RECEIVED_SHUTDOWN
38
39A shutdown alert was received form the peer, either a normal "close notify"
40or a fatal error.
41
42=back
43
44SSL_SENT_SHUTDOWN and SSL_RECEIVED_SHUTDOWN can be set at the same time.
45
46The shutdown state of the connection is used to determine the state of
47the ssl session. If the session is still open, when
48L<SSL_clear(3)|SSL_clear(3)> or L<SSL_free(3)|SSL_free(3)> is called,
49it is considered bad and removed according to RFC2246.
50The actual condition for a correctly closed session is SSL_SENT_SHUTDOWN
51(according to the TLS RFC, it is acceptable to only send the "close notify"
52alert but to not wait for the peer's answer, when the underlying connection
53is closed).
54SSL_set_shutdown() can be used to set this state without sending a
55close alert to the peer (see L<SSL_shutdown(3)|SSL_shutdown(3)>).
56
57If a "close notify" was received, SSL_RECEIVED_SHUTDOWN will be set,
58for setting SSL_SENT_SHUTDOWN the application must however still call
59L<SSL_shutdown(3)|SSL_shutdown(3)> or SSL_set_shutdown() itself.
60
61=head1 RETURN VALUES
62
63SSL_set_shutdown() does not return diagnostic information.
64
65SSL_get_shutdown() returns the current setting.
66
67=head1 SEE ALSO
68
69L<ssl(3)|ssl(3)>, L<SSL_shutdown(3)|SSL_shutdown(3)>,
70L<SSL_CTX_set_quiet_shutdown(3)|SSL_CTX_set_quiet_shutdown(3)>,
71L<SSL_clear(3)|SSL_clear(3)>, L<SSL_free(3)|SSL_free(3)>
72
73=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_set_verify_result.3 b/src/lib/libssl/src/doc/ssl/SSL_set_verify_result.3
new file mode 100644
index 0000000000..3c7f0540fb
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_set_verify_result.pod b/src/lib/libssl/src/doc/ssl/SSL_set_verify_result.pod
deleted file mode 100644
index 04ab101aad..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_set_verify_result.pod
+++ /dev/null
@@ -1,38 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_set_verify_result - override result of peer certificate verification
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 void SSL_set_verify_result(SSL *ssl, long verify_result);
12
13=head1 DESCRIPTION
14
15SSL_set_verify_result() sets B<verify_result> of the object B<ssl> to be the
16result of the verification of the X509 certificate presented by the peer,
17if any.
18
19=head1 NOTES
20
21SSL_set_verify_result() overrides the verification result. It only changes
22the verification result of the B<ssl> object. It does not become part of the
23established session, so if the session is to be reused later, the original
24value will reappear.
25
26The valid codes for B<verify_result> are documented in L<verify(1)|verify(1)>.
27
28=head1 RETURN VALUES
29
30SSL_set_verify_result() does not provide a return value.
31
32=head1 SEE ALSO
33
34L<ssl(3)|ssl(3)>, L<SSL_get_verify_result(3)|SSL_get_verify_result(3)>,
35L<SSL_get_peer_certificate(3)|SSL_get_peer_certificate(3)>,
36L<verify(1)|verify(1)>
37
38=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_shutdown.3 b/src/lib/libssl/src/doc/ssl/SSL_shutdown.3
new file mode 100644
index 0000000000..aa8d483b24
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_shutdown.pod b/src/lib/libssl/src/doc/ssl/SSL_shutdown.pod
deleted file mode 100644
index 50f47c20d7..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_shutdown.pod
+++ /dev/null
@@ -1,125 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_shutdown - shut down a TLS/SSL connection
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 int SSL_shutdown(SSL *ssl);
12
13=head1 DESCRIPTION
14
15SSL_shutdown() shuts down an active TLS/SSL connection. It sends the
16"close notify" shutdown alert to the peer.
17
18=head1 NOTES
19
20SSL_shutdown() tries to send the "close notify" shutdown alert to the peer.
21Whether the operation succeeds or not, the SSL_SENT_SHUTDOWN flag is set and
22a currently open session is considered closed and good and will be kept in the
23session cache for further reuse.
24
25The shutdown procedure consists of 2 steps: the sending of the "close notify"
26shutdown alert and the reception of the peer's "close notify" shutdown
27alert. According to the TLS standard, it is acceptable for an application
28to only send its shutdown alert and then close the underlying connection
29without waiting for the peer's response (this way resources can be saved,
30as the process can already terminate or serve another connection).
31When the underlying connection shall be used for more communications, the
32complete shutdown procedure (bidirectional "close notify" alerts) must be
33performed, so that the peers stay synchronized.
34
35SSL_shutdown() supports both uni- and bidirectional shutdown by its 2 step
36behaviour.
37
38=over 4
39
40=item When the application is the first party to send the "close notify"
41alert, SSL_shutdown() will only send the alert and then set the
42SSL_SENT_SHUTDOWN flag (so that the session is considered good and will
43be kept in cache). SSL_shutdown() will then return with 0. If a unidirectional
44shutdown is enough (the underlying connection shall be closed anyway), this
45first call to SSL_shutdown() is sufficient. In order to complete the
46bidirectional shutdown handshake, SSL_shutdown() must be called again.
47The second call will make SSL_shutdown() wait for the peer's "close notify"
48shutdown alert. On success, the second call to SSL_shutdown() will return
49with 1.
50
51=item If the peer already sent the "close notify" alert B<and> it was
52already processed implicitly inside another function
53(L<SSL_read(3)|SSL_read(3)>), the SSL_RECEIVED_SHUTDOWN flag is set.
54SSL_shutdown() will send the "close notify" alert, set the SSL_SENT_SHUTDOWN
55flag and will immediately return with 1.
56Whether SSL_RECEIVED_SHUTDOWN is already set can be checked using the
57SSL_get_shutdown() (see also L<SSL_set_shutdown(3)|SSL_set_shutdown(3)> call.
58
59=back
60
61It is therefore recommended, to check the return value of SSL_shutdown()
62and call SSL_shutdown() again, if the bidirectional shutdown is not yet
63complete (return value of the first call is 0). As the shutdown is not
64specially handled in the SSLv2 protocol, SSL_shutdown() will succeed on
65the first call.
66
67The behaviour of SSL_shutdown() additionally depends on the underlying BIO.
68
69If the underlying BIO is B<blocking>, SSL_shutdown() will only return once the
70handshake step has been finished or an error occurred.
71
72If the underlying BIO is B<non-blocking>, SSL_shutdown() will also return
73when the underlying BIO could not satisfy the needs of SSL_shutdown()
74to continue the handshake. In this case a call to SSL_get_error() with the
75return value of SSL_shutdown() will yield B<SSL_ERROR_WANT_READ> or
76B<SSL_ERROR_WANT_WRITE>. The calling process then must repeat the call after
77taking appropriate action to satisfy the needs of SSL_shutdown().
78The action depends on the underlying BIO. When using a non-blocking socket,
79nothing is to be done, but select() can be used to check for the required
80condition. When using a buffering BIO, like a BIO pair, data must be written
81into or retrieved out of the BIO before being able to continue.
82
83SSL_shutdown() can be modified to only set the connection to "shutdown"
84state but not actually send the "close notify" alert messages,
85see L<SSL_CTX_set_quiet_shutdown(3)|SSL_CTX_set_quiet_shutdown(3)>.
86When "quiet shutdown" is enabled, SSL_shutdown() will always succeed
87and return 1.
88
89=head1 RETURN VALUES
90
91The following return values can occur:
92
93=over 4
94
95=item C<0>
96
97The shutdown is not yet finished. Call SSL_shutdown() for a second time,
98if a bidirectional shutdown shall be performed.
99The output of L<SSL_get_error(3)|SSL_get_error(3)> may be misleading, as an
100erroneous SSL_ERROR_SYSCALL may be flagged even though no error occurred.
101
102=item C<1>
103
104The shutdown was successfully completed. The "close notify" alert was sent
105and the peer's "close notify" alert was received.
106
107=item C<-1>
108
109The shutdown was not successful because a fatal error occurred either
110at the protocol level or a connection failure occurred. It can also occur if
111action is need to continue the operation for non-blocking BIOs.
112Call L<SSL_get_error(3)|SSL_get_error(3)> with the return value B<ret>
113to find out the reason.
114
115=back
116
117=head1 SEE ALSO
118
119L<SSL_get_error(3)|SSL_get_error(3)>, L<SSL_connect(3)|SSL_connect(3)>,
120L<SSL_accept(3)|SSL_accept(3)>, L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>,
121L<SSL_CTX_set_quiet_shutdown(3)|SSL_CTX_set_quiet_shutdown(3)>,
122L<SSL_clear(3)|SSL_clear(3)>, L<SSL_free(3)|SSL_free(3)>,
123L<ssl(3)|ssl(3)>, L<bio(3)|bio(3)>
124
125=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_state_string.3 b/src/lib/libssl/src/doc/ssl/SSL_state_string.3
new file mode 100644
index 0000000000..828b8f351a
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_state_string.pod b/src/lib/libssl/src/doc/ssl/SSL_state_string.pod
deleted file mode 100644
index e7611f1aff..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_state_string.pod
+++ /dev/null
@@ -1,46 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_state_string, SSL_state_string_long - get textual description of state of
6an SSL object
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 const char *SSL_state_string(const SSL *ssl);
13 const char *SSL_state_string_long(const SSL *ssl);
14
15=head1 DESCRIPTION
16
17SSL_state_string() returns a 6 letter string indicating the current state
18of the SSL object B<ssl>.
19
20SSL_state_string_long() returns a string indicating the current state of
21the SSL object B<ssl>.
22
23=head1 NOTES
24
25During its use, an SSL objects passes several states. The state is internally
26maintained. Querying the state information is not very informative before
27or when a connection has been established. It however can be of significant
28interest during the handshake.
29
30When using non-blocking sockets, the function call performing the handshake
31may return with SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE condition,
32so that SSL_state_string[_long]() may be called.
33
34For both blocking or non-blocking sockets, the details state information
35can be used within the info_callback function set with the
36SSL_set_info_callback() call.
37
38=head1 RETURN VALUES
39
40Detailed description of possible states to be included later.
41
42=head1 SEE ALSO
43
44L<ssl(3)|ssl(3)>, L<SSL_CTX_set_info_callback(3)|SSL_CTX_set_info_callback(3)>
45
46=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_want.3 b/src/lib/libssl/src/doc/ssl/SSL_want.3
new file mode 100644
index 0000000000..5f9d89ea92
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_want.pod b/src/lib/libssl/src/doc/ssl/SSL_want.pod
deleted file mode 100644
index 7ef6cf6ffa..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_want.pod
+++ /dev/null
@@ -1,78 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_want, SSL_want_nothing, SSL_want_read, SSL_want_write, SSL_want_x509_lookup
6- obtain state information TLS/SSL I/O operation
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 int SSL_want(const SSL *ssl);
13 int SSL_want_nothing(const SSL *ssl);
14 int SSL_want_read(const SSL *ssl);
15 int SSL_want_write(const SSL *ssl);
16 int SSL_want_x509_lookup(const SSL *ssl);
17
18=head1 DESCRIPTION
19
20SSL_want() returns state information for the SSL object B<ssl>.
21
22The other SSL_want_*() calls are shortcuts for the possible states returned
23by SSL_want().
24
25=head1 NOTES
26
27SSL_want() examines the internal state information of the SSL object. Its
28return values are similar to that of L<SSL_get_error(3)|SSL_get_error(3)>.
29Unlike L<SSL_get_error(3)|SSL_get_error(3)>, which also evaluates the
30error queue, the results are obtained by examining an internal state flag
31only. The information must therefore only be used for normal operation under
32non-blocking I/O. Error conditions are not handled and must be treated
33using L<SSL_get_error(3)|SSL_get_error(3)>.
34
35The result returned by SSL_want() should always be consistent with
36the result of L<SSL_get_error(3)|SSL_get_error(3)>.
37
38=head1 RETURN VALUES
39
40The following return values can currently occur for SSL_want():
41
42=over 4
43
44=item SSL_NOTHING
45
46There is no data to be written or to be read.
47
48=item SSL_WRITING
49
50There are data in the SSL buffer that must be written to the underlying
51B<BIO> layer in order to complete the actual SSL_*() operation.
52A call to L<SSL_get_error(3)|SSL_get_error(3)> should return
53SSL_ERROR_WANT_WRITE.
54
55=item SSL_READING
56
57More data must be read from the underlying B<BIO> layer in order to
58complete the actual SSL_*() operation.
59A call to L<SSL_get_error(3)|SSL_get_error(3)> should return
60SSL_ERROR_WANT_READ.
61
62=item SSL_X509_LOOKUP
63
64The operation did not complete because an application callback set by
65SSL_CTX_set_client_cert_cb() has asked to be called again.
66A call to L<SSL_get_error(3)|SSL_get_error(3)> should return
67SSL_ERROR_WANT_X509_LOOKUP.
68
69=back
70
71SSL_want_nothing(), SSL_want_read(), SSL_want_write(), SSL_want_x509_lookup()
72return 1, when the corresponding condition is true or 0 otherwise.
73
74=head1 SEE ALSO
75
76L<ssl(3)|ssl(3)>, L<err(3)|err(3)>, L<SSL_get_error(3)|SSL_get_error(3)>
77
78=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_write.3 b/src/lib/libssl/src/doc/ssl/SSL_write.3
new file mode 100644
index 0000000000..19dfffae1b
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/SSL_write.pod b/src/lib/libssl/src/doc/ssl/SSL_write.pod
deleted file mode 100644
index f248f7d740..0000000000
--- a/src/lib/libssl/src/doc/ssl/SSL_write.pod
+++ /dev/null
@@ -1,109 +0,0 @@
1=pod
2
3=head1 NAME
4
5SSL_write - write bytes to a TLS/SSL connection.
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 int SSL_write(SSL *ssl, const void *buf, int num);
12
13=head1 DESCRIPTION
14
15SSL_write() writes B<num> bytes from the buffer B<buf> into the specified
16B<ssl> connection.
17
18=head1 NOTES
19
20If necessary, SSL_write() will negotiate a TLS/SSL session, if
21not already explicitly performed by L<SSL_connect(3)|SSL_connect(3)> or
22L<SSL_accept(3)|SSL_accept(3)>. If the
23peer requests a re-negotiation, it will be performed transparently during
24the SSL_write() operation. The behaviour of SSL_write() depends on the
25underlying BIO.
26
27For the transparent negotiation to succeed, the B<ssl> must have been
28initialized to client or server mode. This is being done by calling
29L<SSL_set_connect_state(3)|SSL_set_connect_state(3)> or SSL_set_accept_state()
30before the first call to an L<SSL_read(3)|SSL_read(3)> or SSL_write() function.
31
32If the underlying BIO is B<blocking>, SSL_write() will only return, once the
33write operation has been finished or an error occurred, except when a
34renegotiation take place, in which case a SSL_ERROR_WANT_READ may occur.
35This behaviour can be controlled with the SSL_MODE_AUTO_RETRY flag of the
36L<SSL_CTX_set_mode(3)|SSL_CTX_set_mode(3)> call.
37
38If the underlying BIO is B<non-blocking>, SSL_write() will also return,
39when the underlying BIO could not satisfy the needs of SSL_write()
40to continue the operation. In this case a call to
41L<SSL_get_error(3)|SSL_get_error(3)> with the
42return value of SSL_write() will yield B<SSL_ERROR_WANT_READ> or
43B<SSL_ERROR_WANT_WRITE>. As at any time a re-negotiation is possible, a
44call to SSL_write() can also cause read operations! The calling process
45then must repeat the call after taking appropriate action to satisfy the
46needs of SSL_write(). The action depends on the underlying BIO. When using a
47non-blocking socket, nothing is to be done, but select() can be used to check
48for the required condition. When using a buffering BIO, like a BIO pair, data
49must be written into or retrieved out of the BIO before being able to continue.
50
51SSL_write() will only return with success, when the complete contents
52of B<buf> of length B<num> has been written. This default behaviour
53can be changed with the SSL_MODE_ENABLE_PARTIAL_WRITE option of
54L<SSL_CTX_set_mode(3)|SSL_CTX_set_mode(3)>. When this flag is set,
55SSL_write() will also return with success, when a partial write has been
56successfully completed. In this case the SSL_write() operation is considered
57completed. The bytes are sent and a new SSL_write() operation with a new
58buffer (with the already sent bytes removed) must be started.
59A partial write is performed with the size of a message block, which is
6016kB for SSLv3/TLSv1.
61
62=head1 WARNING
63
64When an SSL_write() operation has to be repeated because of
65B<SSL_ERROR_WANT_READ> or B<SSL_ERROR_WANT_WRITE>, it must be repeated
66with the same arguments.
67
68When calling SSL_write() with num=0 bytes to be sent the behaviour is
69undefined.
70
71=head1 RETURN VALUES
72
73The following return values can occur:
74
75=over 4
76
77=item C<E<gt>0>
78
79The write operation was successful, the return value is the number of
80bytes actually written to the TLS/SSL connection.
81
82=item C<0>
83
84The write operation was not successful. Probably the underlying connection
85was closed. Call SSL_get_error() with the return value B<ret> to find out,
86whether an error occurred or the connection was shut down cleanly
87(SSL_ERROR_ZERO_RETURN).
88
89SSLv2 (deprecated) does not support a shutdown alert protocol, so it can
90only be detected, whether the underlying connection was closed. It cannot
91be checked, why the closure happened.
92
93=item C<E<lt>0>
94
95The write operation was not successful, because either an error occurred
96or action must be taken by the calling process. Call SSL_get_error() with the
97return value B<ret> to find out the reason.
98
99=back
100
101=head1 SEE ALSO
102
103L<SSL_get_error(3)|SSL_get_error(3)>, L<SSL_read(3)|SSL_read(3)>,
104L<SSL_CTX_set_mode(3)|SSL_CTX_set_mode(3)>, L<SSL_CTX_new(3)|SSL_CTX_new(3)>,
105L<SSL_connect(3)|SSL_connect(3)>, L<SSL_accept(3)|SSL_accept(3)>
106L<SSL_set_connect_state(3)|SSL_set_connect_state(3)>,
107L<ssl(3)|ssl(3)>, L<bio(3)|bio(3)>
108
109=cut
diff --git a/src/lib/libssl/src/doc/ssl/d2i_SSL_SESSION.3 b/src/lib/libssl/src/doc/ssl/d2i_SSL_SESSION.3
new file mode 100644
index 0000000000..3a40c32e69
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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/src/doc/ssl/d2i_SSL_SESSION.pod b/src/lib/libssl/src/doc/ssl/d2i_SSL_SESSION.pod
deleted file mode 100644
index d817f72b54..0000000000
--- a/src/lib/libssl/src/doc/ssl/d2i_SSL_SESSION.pod
+++ /dev/null
@@ -1,80 +0,0 @@
1=pod
2
3=head1 NAME
4
5d2i_SSL_SESSION, i2d_SSL_SESSION - convert SSL_SESSION object from/to ASN1
6representation
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp, long length);
13 int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp);
14
15=head1 DESCRIPTION
16
17d2i_SSL_SESSION() transforms the external ASN1 representation of an SSL/TLS
18session, stored as binary data at location B<pp> with length B<length>, into
19an SSL_SESSION object.
20
21i2d_SSL_SESSION() transforms the SSL_SESSION object B<in> into the ASN1
22representation and stores it into the memory location pointed to by B<pp>.
23The length of the resulting ASN1 representation is returned. If B<pp> is
24the NULL pointer, only the length is calculated and returned.
25
26=head1 NOTES
27
28The SSL_SESSION object is built from several malloc()ed parts, it can
29therefore not be moved, copied or stored directly. In order to store
30session data on disk or into a database, it must be transformed into
31a binary ASN1 representation.
32
33When using d2i_SSL_SESSION(), the SSL_SESSION object is automatically
34allocated. The reference count is 1, so that the session must be
35explicitly removed using L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>,
36unless the SSL_SESSION object is completely taken over, when being called
37inside the get_session_cb() (see
38L<SSL_CTX_sess_set_get_cb(3)|SSL_CTX_sess_set_get_cb(3)>).
39
40SSL_SESSION objects keep internal link information about the session cache
41list, when being inserted into one SSL_CTX object's session cache.
42One SSL_SESSION object, regardless of its reference count, must therefore
43only be used with one SSL_CTX object (and the SSL objects created
44from this SSL_CTX object).
45
46When using i2d_SSL_SESSION(), the memory location pointed to by B<pp> must be
47large enough to hold the binary representation of the session. There is no
48known limit on the size of the created ASN1 representation, so the necessary
49amount of space should be obtained by first calling i2d_SSL_SESSION() with
50B<pp=NULL>, and obtain the size needed, then allocate the memory and
51call i2d_SSL_SESSION() again.
52Note that this will advance the value contained in B<*pp> so it is necessary
53to save a copy of the original allocation.
54For example:
55 int i, j;
56 char *p, *temp;
57
58 i = i2d_SSL_SESSION(sess, NULL);
59 p = temp = malloc(i);
60 if (temp != NULL) {
61 j = i2d_SSL_SESSION(sess, &temp);
62 assert(i == j);
63 assert(p + i == temp);
64 }
65
66=head1 RETURN VALUES
67
68d2i_SSL_SESSION() returns a pointer to the newly allocated SSL_SESSION
69object. In case of failure the NULL-pointer is returned and the error message
70can be retrieved from the error stack.
71
72i2d_SSL_SESSION() returns the size of the ASN1 representation in bytes.
73When the session is not valid, B<0> is returned and no operation is performed.
74
75=head1 SEE ALSO
76
77L<ssl(3)|ssl(3)>, L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>,
78L<SSL_CTX_sess_set_get_cb(3)|SSL_CTX_sess_set_get_cb(3)>
79
80=cut
diff --git a/src/lib/libssl/src/doc/ssl/ssl.3 b/src/lib/libssl/src/doc/ssl/ssl.3
new file mode 100644
index 0000000000..901e1fdfc1
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/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.
diff --git a/src/lib/libssl/src/doc/ssl/ssl.pod b/src/lib/libssl/src/doc/ssl/ssl.pod
deleted file mode 100644
index 6d3ee24e4e..0000000000
--- a/src/lib/libssl/src/doc/ssl/ssl.pod
+++ /dev/null
@@ -1,758 +0,0 @@
1
2=pod
3
4=head1 NAME
5
6SSL - OpenSSL SSL/TLS library
7
8=head1 SYNOPSIS
9
10=head1 DESCRIPTION
11
12The OpenSSL B<ssl> library implements the Secure Sockets Layer (SSL v2/v3) and
13Transport Layer Security (TLS v1) protocols. It provides a rich API which is
14documented here.
15
16At first the library must be initialized; see
17L<SSL_library_init(3)|SSL_library_init(3)>.
18
19Then an B<SSL_CTX> object is created as a framework to establish
20TLS/SSL enabled connections (see L<SSL_CTX_new(3)|SSL_CTX_new(3)>).
21Various options regarding certificates, algorithms etc. can be set
22in this object.
23
24When a network connection has been created, it can be assigned to an
25B<SSL> object. After the B<SSL> object has been created using
26L<SSL_new(3)|SSL_new(3)>, L<SSL_set_fd(3)|SSL_set_fd(3)> or
27L<SSL_set_bio(3)|SSL_set_bio(3)> can be used to associate the network
28connection with the object.
29
30Then the TLS/SSL handshake is performed using
31L<SSL_accept(3)|SSL_accept(3)> or L<SSL_connect(3)|SSL_connect(3)>
32respectively.
33L<SSL_read(3)|SSL_read(3)> and L<SSL_write(3)|SSL_write(3)> are used
34to read and write data on the TLS/SSL connection.
35L<SSL_shutdown(3)|SSL_shutdown(3)> can be used to shut down the
36TLS/SSL connection.
37
38=head1 DATA STRUCTURES
39
40Currently the OpenSSL B<ssl> library functions deals with the following data
41structures:
42
43=over 4
44
45=item B<SSL_METHOD> (SSL Method)
46
47That's a dispatch structure describing the internal B<ssl> library
48methods/functions which implement the various protocol versions (SSLv1, SSLv2
49and TLSv1). It's needed to create an B<SSL_CTX>.
50
51=item B<SSL_CIPHER> (SSL Cipher)
52
53This structure holds the algorithm information for a particular cipher which
54are a core part of the SSL/TLS protocol. The available ciphers are configured
55on a B<SSL_CTX> basis and the actually used ones are then part of the
56B<SSL_SESSION>.
57
58=item B<SSL_CTX> (SSL Context)
59
60That's the global context structure which is created by a server or client
61once per program life-time and which holds mainly default values for the
62B<SSL> structures which are later created for the connections.
63
64=item B<SSL_SESSION> (SSL Session)
65
66This is a structure containing the current TLS/SSL session details for a
67connection: B<SSL_CIPHER>s, client and server certificates, keys, etc.
68
69=item B<SSL> (SSL Connection)
70
71That's the main SSL/TLS structure which is created by a server or client per
72established connection. This actually is the core structure in the SSL API.
73Under run-time the application usually deals with this structure which has
74links to mostly all other structures.
75
76=back
77
78
79=head1 HEADER FILES
80
81Currently the OpenSSL B<ssl> library provides the following C header files
82containing the prototypes for the data structures and and functions:
83
84=over 4
85
86=item B<ssl.h>
87
88That's the common header file for the SSL/TLS API. Include it into your
89program to make the API of the B<ssl> library available. It internally
90includes both more private SSL headers and headers from the B<crypto> library.
91Whenever you need hard-core details on the internals of the SSL API, look
92inside this header file.
93
94=item B<ssl2.h>
95
96That's the sub header file dealing with the SSLv2 protocol only.
97I<Usually you don't have to include it explicitly because
98it's already included by ssl.h>.
99
100=item B<ssl3.h>
101
102That's the sub header file dealing with the SSLv3 protocol only.
103I<Usually you don't have to include it explicitly because
104it's already included by ssl.h>.
105
106=item B<ssl23.h>
107
108That's the sub header file dealing with the combined use of the SSLv2 and
109SSLv3 protocols.
110I<Usually you don't have to include it explicitly because
111it's already included by ssl.h>.
112
113=item B<tls1.h>
114
115That's the sub header file dealing with the TLSv1 protocol only.
116I<Usually you don't have to include it explicitly because
117it's already included by ssl.h>.
118
119=back
120
121=head1 API FUNCTIONS
122
123Currently the OpenSSL B<ssl> library exports 214 API functions.
124They are documented in the following:
125
126=head2 DEALING WITH PROTOCOL METHODS
127
128Here we document the various API functions which deal with the SSL/TLS
129protocol methods defined in B<SSL_METHOD> structures.
130
131=over 4
132
133=item const SSL_METHOD *B<SSLv2_client_method>(void);
134
135Constructor for the SSLv2 SSL_METHOD structure for a dedicated client.
136
137=item const SSL_METHOD *B<SSLv2_server_method>(void);
138
139Constructor for the SSLv2 SSL_METHOD structure for a dedicated server.
140
141=item const SSL_METHOD *B<SSLv2_method>(void);
142
143Constructor for the SSLv2 SSL_METHOD structure for combined client and server.
144
145=item const SSL_METHOD *B<SSLv3_client_method>(void);
146
147Constructor for the SSLv3 SSL_METHOD structure for a dedicated client.
148
149=item const SSL_METHOD *B<SSLv3_server_method>(void);
150
151Constructor for the SSLv3 SSL_METHOD structure for a dedicated server.
152
153=item const SSL_METHOD *B<SSLv3_method>(void);
154
155Constructor for the SSLv3 SSL_METHOD structure for combined client and server.
156
157=item const SSL_METHOD *B<TLSv1_client_method>(void);
158
159Constructor for the TLSv1 SSL_METHOD structure for a dedicated client.
160
161=item const SSL_METHOD *B<TLSv1_server_method>(void);
162
163Constructor for the TLSv1 SSL_METHOD structure for a dedicated server.
164
165=item const SSL_METHOD *B<TLSv1_method>(void);
166
167Constructor for the TLSv1 SSL_METHOD structure for combined client and server.
168
169=back
170
171=head2 DEALING WITH CIPHERS
172
173Here we document the various API functions which deal with the SSL/TLS
174ciphers defined in B<SSL_CIPHER> structures.
175
176=over 4
177
178=item char *B<SSL_CIPHER_description>(SSL_CIPHER *cipher, char *buf, int len);
179
180Write a string to I<buf> (with a maximum size of I<len>) containing a human
181readable description of I<cipher>. Returns I<buf>.
182
183=item int B<SSL_CIPHER_get_bits>(SSL_CIPHER *cipher, int *alg_bits);
184
185Determine the number of bits in I<cipher>. Because of export crippled ciphers
186there are two bits: The bits the algorithm supports in general (stored to
187I<alg_bits>) and the bits which are actually used (the return value).
188
189=item const char *B<SSL_CIPHER_get_name>(SSL_CIPHER *cipher);
190
191Return the internal name of I<cipher> as a string. These are the various
192strings defined by the I<SSL2_TXT_xxx>, I<SSL3_TXT_xxx> and I<TLS1_TXT_xxx>
193definitions in the header files.
194
195=item char *B<SSL_CIPHER_get_version>(SSL_CIPHER *cipher);
196
197Returns a string like "C<TLSv1/SSLv3>" or "C<SSLv2>" which indicates the
198SSL/TLS protocol version to which I<cipher> belongs (i.e. where it was defined
199in the specification the first time).
200
201=back
202
203=head2 DEALING WITH PROTOCOL CONTEXTS
204
205Here we document the various API functions which deal with the SSL/TLS
206protocol context defined in the B<SSL_CTX> structure.
207
208=over 4
209
210=item int B<SSL_CTX_add_client_CA>(SSL_CTX *ctx, X509 *x);
211
212=item long B<SSL_CTX_add_extra_chain_cert>(SSL_CTX *ctx, X509 *x509);
213
214=item int B<SSL_CTX_add_session>(SSL_CTX *ctx, SSL_SESSION *c);
215
216=item int B<SSL_CTX_check_private_key>(const SSL_CTX *ctx);
217
218=item long B<SSL_CTX_ctrl>(SSL_CTX *ctx, int cmd, long larg, char *parg);
219
220=item void B<SSL_CTX_flush_sessions>(SSL_CTX *s, long t);
221
222=item void B<SSL_CTX_free>(SSL_CTX *a);
223
224=item char *B<SSL_CTX_get_app_data>(SSL_CTX *ctx);
225
226=item X509_STORE *B<SSL_CTX_get_cert_store>(SSL_CTX *ctx);
227
228=item STACK *B<SSL_CTX_get_client_CA_list>(const SSL_CTX *ctx);
229
230=item int (*B<SSL_CTX_get_client_cert_cb>(SSL_CTX *ctx))(SSL *ssl, X509 **x509, EVP_PKEY **pkey);
231
232=item char *B<SSL_CTX_get_ex_data>(const SSL_CTX *s, int idx);
233
234=item int B<SSL_CTX_get_ex_new_index>(long argl, char *argp, int (*new_func);(void), int (*dup_func)(void), void (*free_func)(void))
235
236=item void (*B<SSL_CTX_get_info_callback>(SSL_CTX *ctx))(SSL *ssl, int cb, int ret);
237
238=item int B<SSL_CTX_get_quiet_shutdown>(const SSL_CTX *ctx);
239
240=item int B<SSL_CTX_get_session_cache_mode>(SSL_CTX *ctx);
241
242=item long B<SSL_CTX_get_timeout>(const SSL_CTX *ctx);
243
244=item int (*B<SSL_CTX_get_verify_callback>(const SSL_CTX *ctx))(int ok, X509_STORE_CTX *ctx);
245
246=item int B<SSL_CTX_get_verify_mode>(SSL_CTX *ctx);
247
248=item int B<SSL_CTX_load_verify_locations>(SSL_CTX *ctx, char *CAfile, char *CApath);
249
250=item long B<SSL_CTX_need_tmp_RSA>(SSL_CTX *ctx);
251
252=item SSL_CTX *B<SSL_CTX_new>(const SSL_METHOD *meth);
253
254=item int B<SSL_CTX_remove_session>(SSL_CTX *ctx, SSL_SESSION *c);
255
256=item int B<SSL_CTX_sess_accept>(SSL_CTX *ctx);
257
258=item int B<SSL_CTX_sess_accept_good>(SSL_CTX *ctx);
259
260=item int B<SSL_CTX_sess_accept_renegotiate>(SSL_CTX *ctx);
261
262=item int B<SSL_CTX_sess_cache_full>(SSL_CTX *ctx);
263
264=item int B<SSL_CTX_sess_cb_hits>(SSL_CTX *ctx);
265
266=item int B<SSL_CTX_sess_connect>(SSL_CTX *ctx);
267
268=item int B<SSL_CTX_sess_connect_good>(SSL_CTX *ctx);
269
270=item int B<SSL_CTX_sess_connect_renegotiate>(SSL_CTX *ctx);
271
272=item int B<SSL_CTX_sess_get_cache_size>(SSL_CTX *ctx);
273
274=item SSL_SESSION *(*B<SSL_CTX_sess_get_get_cb>(SSL_CTX *ctx))(SSL *ssl, unsigned char *data, int len, int *copy);
275
276=item int (*B<SSL_CTX_sess_get_new_cb>(SSL_CTX *ctx)(SSL *ssl, SSL_SESSION *sess);
277
278=item void (*B<SSL_CTX_sess_get_remove_cb>(SSL_CTX *ctx)(SSL_CTX *ctx, SSL_SESSION *sess);
279
280=item int B<SSL_CTX_sess_hits>(SSL_CTX *ctx);
281
282=item int B<SSL_CTX_sess_misses>(SSL_CTX *ctx);
283
284=item int B<SSL_CTX_sess_number>(SSL_CTX *ctx);
285
286=item void B<SSL_CTX_sess_set_cache_size>(SSL_CTX *ctx,t);
287
288=item void B<SSL_CTX_sess_set_get_cb>(SSL_CTX *ctx, SSL_SESSION *(*cb)(SSL *ssl, unsigned char *data, int len, int *copy));
289
290=item void B<SSL_CTX_sess_set_new_cb>(SSL_CTX *ctx, int (*cb)(SSL *ssl, SSL_SESSION *sess));
291
292=item void B<SSL_CTX_sess_set_remove_cb>(SSL_CTX *ctx, void (*cb)(SSL_CTX *ctx, SSL_SESSION *sess));
293
294=item int B<SSL_CTX_sess_timeouts>(SSL_CTX *ctx);
295
296=item LHASH *B<SSL_CTX_sessions>(SSL_CTX *ctx);
297
298=item void B<SSL_CTX_set_app_data>(SSL_CTX *ctx, void *arg);
299
300=item void B<SSL_CTX_set_cert_store>(SSL_CTX *ctx, X509_STORE *cs);
301
302=item void B<SSL_CTX_set_cert_verify_cb>(SSL_CTX *ctx, int (*cb)(), char *arg)
303
304=item int B<SSL_CTX_set_cipher_list>(SSL_CTX *ctx, char *str);
305
306=item void B<SSL_CTX_set_client_CA_list>(SSL_CTX *ctx, STACK *list);
307
308=item void B<SSL_CTX_set_client_cert_cb>(SSL_CTX *ctx, int (*cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey));
309
310=item void B<SSL_CTX_set_default_passwd_cb>(SSL_CTX *ctx, int (*cb);(void))
311
312=item void B<SSL_CTX_set_default_read_ahead>(SSL_CTX *ctx, int m);
313
314=item int B<SSL_CTX_set_default_verify_paths>(SSL_CTX *ctx);
315
316=item int B<SSL_CTX_set_ex_data>(SSL_CTX *s, int idx, char *arg);
317
318=item void B<SSL_CTX_set_info_callback>(SSL_CTX *ctx, void (*cb)(SSL *ssl, int cb, int ret));
319
320=item void B<SSL_CTX_set_msg_callback>(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg));
321
322=item void B<SSL_CTX_set_msg_callback_arg>(SSL_CTX *ctx, void *arg);
323
324=item void B<SSL_CTX_set_options>(SSL_CTX *ctx, unsigned long op);
325
326=item void B<SSL_CTX_set_quiet_shutdown>(SSL_CTX *ctx, int mode);
327
328=item void B<SSL_CTX_set_session_cache_mode>(SSL_CTX *ctx, int mode);
329
330=item int B<SSL_CTX_set_ssl_version>(SSL_CTX *ctx, const SSL_METHOD *meth);
331
332=item void B<SSL_CTX_set_timeout>(SSL_CTX *ctx, long t);
333
334=item long B<SSL_CTX_set_tmp_dh>(SSL_CTX* ctx, DH *dh);
335
336=item long B<SSL_CTX_set_tmp_dh_callback>(SSL_CTX *ctx, DH *(*cb)(void));
337
338=item long B<SSL_CTX_set_tmp_rsa>(SSL_CTX *ctx, RSA *rsa);
339
340=item SSL_CTX_set_tmp_rsa_callback
341
342C<long B<SSL_CTX_set_tmp_rsa_callback>(SSL_CTX *B<ctx>, RSA *(*B<cb>)(SSL *B<ssl>, int B<export>, int B<keylength>));>
343
344Sets the callback which will be called when a temporary private key is
345required. The B<C<export>> flag will be set if the reason for needing
346a temp key is that an export ciphersuite is in use, in which case,
347B<C<keylength>> will contain the required keylength in bits. Generate a key of
348appropriate size (using ???) and return it.
349
350=item SSL_set_tmp_rsa_callback
351
352long B<SSL_set_tmp_rsa_callback>(SSL *ssl, RSA *(*cb)(SSL *ssl, int export, int keylength));
353
354The same as B<SSL_CTX_set_tmp_rsa_callback>, except it operates on an SSL
355session instead of a context.
356
357=item void B<SSL_CTX_set_verify>(SSL_CTX *ctx, int mode, int (*cb);(void))
358
359=item int B<SSL_CTX_use_PrivateKey>(SSL_CTX *ctx, EVP_PKEY *pkey);
360
361=item int B<SSL_CTX_use_PrivateKey_ASN1>(int type, SSL_CTX *ctx, unsigned char *d, long len);
362
363=item int B<SSL_CTX_use_PrivateKey_file>(SSL_CTX *ctx, char *file, int type);
364
365=item int B<SSL_CTX_use_RSAPrivateKey>(SSL_CTX *ctx, RSA *rsa);
366
367=item int B<SSL_CTX_use_RSAPrivateKey_ASN1>(SSL_CTX *ctx, unsigned char *d, long len);
368
369=item int B<SSL_CTX_use_RSAPrivateKey_file>(SSL_CTX *ctx, char *file, int type);
370
371=item int B<SSL_CTX_use_certificate>(SSL_CTX *ctx, X509 *x);
372
373=item int B<SSL_CTX_use_certificate_ASN1>(SSL_CTX *ctx, int len, unsigned char *d);
374
375=item int B<SSL_CTX_use_certificate_file>(SSL_CTX *ctx, char *file, int type);
376
377=item void B<SSL_CTX_set_psk_client_callback>(SSL_CTX *ctx, unsigned int (*callback)(SSL *ssl, const char *hint, char *identity, unsigned int max_identity_len, unsigned char *psk, unsigned int max_psk_len));
378
379=item int B<SSL_CTX_use_psk_identity_hint>(SSL_CTX *ctx, const char *hint);
380
381=item void B<SSL_CTX_set_psk_server_callback>(SSL_CTX *ctx, unsigned int (*callback)(SSL *ssl, const char *identity, unsigned char *psk, int max_psk_len));
382
383
384
385
386=back
387
388=head2 DEALING WITH SESSIONS
389
390Here we document the various API functions which deal with the SSL/TLS
391sessions defined in the B<SSL_SESSION> structures.
392
393=over 4
394
395=item int B<SSL_SESSION_cmp>(const SSL_SESSION *a, const SSL_SESSION *b);
396
397=item void B<SSL_SESSION_free>(SSL_SESSION *ss);
398
399=item char *B<SSL_SESSION_get_app_data>(SSL_SESSION *s);
400
401=item char *B<SSL_SESSION_get_ex_data>(const SSL_SESSION *s, int idx);
402
403=item int B<SSL_SESSION_get_ex_new_index>(long argl, char *argp, int (*new_func);(void), int (*dup_func)(void), void (*free_func)(void))
404
405=item long B<SSL_SESSION_get_time>(const SSL_SESSION *s);
406
407=item long B<SSL_SESSION_get_timeout>(const SSL_SESSION *s);
408
409=item unsigned long B<SSL_SESSION_hash>(const SSL_SESSION *a);
410
411=item SSL_SESSION *B<SSL_SESSION_new>(void);
412
413=item int B<SSL_SESSION_print>(BIO *bp, const SSL_SESSION *x);
414
415=item int B<SSL_SESSION_print_fp>(FILE *fp, const SSL_SESSION *x);
416
417=item void B<SSL_SESSION_set_app_data>(SSL_SESSION *s, char *a);
418
419=item int B<SSL_SESSION_set_ex_data>(SSL_SESSION *s, int idx, char *arg);
420
421=item long B<SSL_SESSION_set_time>(SSL_SESSION *s, long t);
422
423=item long B<SSL_SESSION_set_timeout>(SSL_SESSION *s, long t);
424
425=back
426
427=head2 DEALING WITH CONNECTIONS
428
429Here we document the various API functions which deal with the SSL/TLS
430connection defined in the B<SSL> structure.
431
432=over 4
433
434=item int B<SSL_accept>(SSL *ssl);
435
436=item int B<SSL_add_dir_cert_subjects_to_stack>(STACK *stack, const char *dir);
437
438=item int B<SSL_add_file_cert_subjects_to_stack>(STACK *stack, const char *file);
439
440=item int B<SSL_add_client_CA>(SSL *ssl, X509 *x);
441
442=item char *B<SSL_alert_desc_string>(int value);
443
444=item char *B<SSL_alert_desc_string_long>(int value);
445
446=item char *B<SSL_alert_type_string>(int value);
447
448=item char *B<SSL_alert_type_string_long>(int value);
449
450=item int B<SSL_check_private_key>(const SSL *ssl);
451
452=item void B<SSL_clear>(SSL *ssl);
453
454=item long B<SSL_clear_num_renegotiations>(SSL *ssl);
455
456=item int B<SSL_connect>(SSL *ssl);
457
458=item void B<SSL_copy_session_id>(SSL *t, const SSL *f);
459
460=item long B<SSL_ctrl>(SSL *ssl, int cmd, long larg, char *parg);
461
462=item int B<SSL_do_handshake>(SSL *ssl);
463
464=item SSL *B<SSL_dup>(SSL *ssl);
465
466=item STACK *B<SSL_dup_CA_list>(STACK *sk);
467
468=item void B<SSL_free>(SSL *ssl);
469
470=item SSL_CTX *B<SSL_get_SSL_CTX>(const SSL *ssl);
471
472=item char *B<SSL_get_app_data>(SSL *ssl);
473
474=item X509 *B<SSL_get_certificate>(const SSL *ssl);
475
476=item const char *B<SSL_get_cipher>(const SSL *ssl);
477
478=item int B<SSL_get_cipher_bits>(const SSL *ssl, int *alg_bits);
479
480=item char *B<SSL_get_cipher_list>(const SSL *ssl, int n);
481
482=item char *B<SSL_get_cipher_name>(const SSL *ssl);
483
484=item char *B<SSL_get_cipher_version>(const SSL *ssl);
485
486=item STACK *B<SSL_get_ciphers>(const SSL *ssl);
487
488=item STACK *B<SSL_get_client_CA_list>(const SSL *ssl);
489
490=item SSL_CIPHER *B<SSL_get_current_cipher>(SSL *ssl);
491
492=item long B<SSL_get_default_timeout>(const SSL *ssl);
493
494=item int B<SSL_get_error>(const SSL *ssl, int i);
495
496=item char *B<SSL_get_ex_data>(const SSL *ssl, int idx);
497
498=item int B<SSL_get_ex_data_X509_STORE_CTX_idx>(void);
499
500=item int B<SSL_get_ex_new_index>(long argl, char *argp, int (*new_func);(void), int (*dup_func)(void), void (*free_func)(void))
501
502=item int B<SSL_get_fd>(const SSL *ssl);
503
504=item void (*B<SSL_get_info_callback>(const SSL *ssl);)()
505
506=item STACK *B<SSL_get_peer_cert_chain>(const SSL *ssl);
507
508=item X509 *B<SSL_get_peer_certificate>(const SSL *ssl);
509
510=item EVP_PKEY *B<SSL_get_privatekey>(SSL *ssl);
511
512=item int B<SSL_get_quiet_shutdown>(const SSL *ssl);
513
514=item BIO *B<SSL_get_rbio>(const SSL *ssl);
515
516=item int B<SSL_get_read_ahead>(const SSL *ssl);
517
518=item SSL_SESSION *B<SSL_get_session>(const SSL *ssl);
519
520=item char *B<SSL_get_shared_ciphers>(const SSL *ssl, char *buf, int len);
521
522=item int B<SSL_get_shutdown>(const SSL *ssl);
523
524=item const SSL_METHOD *B<SSL_get_ssl_method>(SSL *ssl);
525
526=item int B<SSL_get_state>(const SSL *ssl);
527
528=item long B<SSL_get_time>(const SSL *ssl);
529
530=item long B<SSL_get_timeout>(const SSL *ssl);
531
532=item int (*B<SSL_get_verify_callback>(const SSL *ssl))(int,X509_STORE_CTX *)
533
534=item int B<SSL_get_verify_mode>(const SSL *ssl);
535
536=item long B<SSL_get_verify_result>(const SSL *ssl);
537
538=item char *B<SSL_get_version>(const SSL *ssl);
539
540=item BIO *B<SSL_get_wbio>(const SSL *ssl);
541
542=item int B<SSL_in_accept_init>(SSL *ssl);
543
544=item int B<SSL_in_before>(SSL *ssl);
545
546=item int B<SSL_in_connect_init>(SSL *ssl);
547
548=item int B<SSL_in_init>(SSL *ssl);
549
550=item int B<SSL_is_init_finished>(SSL *ssl);
551
552=item STACK *B<SSL_load_client_CA_file>(char *file);
553
554=item void B<SSL_load_error_strings>(void);
555
556=item SSL *B<SSL_new>(SSL_CTX *ctx);
557
558=item long B<SSL_num_renegotiations>(SSL *ssl);
559
560=item int B<SSL_peek>(SSL *ssl, void *buf, int num);
561
562=item int B<SSL_pending>(const SSL *ssl);
563
564=item int B<SSL_read>(SSL *ssl, void *buf, int num);
565
566=item int B<SSL_renegotiate>(SSL *ssl);
567
568=item char *B<SSL_rstate_string>(SSL *ssl);
569
570=item char *B<SSL_rstate_string_long>(SSL *ssl);
571
572=item long B<SSL_session_reused>(SSL *ssl);
573
574=item void B<SSL_set_accept_state>(SSL *ssl);
575
576=item void B<SSL_set_app_data>(SSL *ssl, char *arg);
577
578=item void B<SSL_set_bio>(SSL *ssl, BIO *rbio, BIO *wbio);
579
580=item int B<SSL_set_cipher_list>(SSL *ssl, char *str);
581
582=item void B<SSL_set_client_CA_list>(SSL *ssl, STACK *list);
583
584=item void B<SSL_set_connect_state>(SSL *ssl);
585
586=item int B<SSL_set_ex_data>(SSL *ssl, int idx, char *arg);
587
588=item int B<SSL_set_fd>(SSL *ssl, int fd);
589
590=item void B<SSL_set_info_callback>(SSL *ssl, void (*cb);(void))
591
592=item void B<SSL_set_msg_callback>(SSL *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg));
593
594=item void B<SSL_set_msg_callback_arg>(SSL *ctx, void *arg);
595
596=item void B<SSL_set_options>(SSL *ssl, unsigned long op);
597
598=item void B<SSL_set_quiet_shutdown>(SSL *ssl, int mode);
599
600=item void B<SSL_set_read_ahead>(SSL *ssl, int yes);
601
602=item int B<SSL_set_rfd>(SSL *ssl, int fd);
603
604=item int B<SSL_set_session>(SSL *ssl, SSL_SESSION *session);
605
606=item void B<SSL_set_shutdown>(SSL *ssl, int mode);
607
608=item int B<SSL_set_ssl_method>(SSL *ssl, const SSL_METHOD *meth);
609
610=item void B<SSL_set_time>(SSL *ssl, long t);
611
612=item void B<SSL_set_timeout>(SSL *ssl, long t);
613
614=item void B<SSL_set_verify>(SSL *ssl, int mode, int (*callback);(void))
615
616=item void B<SSL_set_verify_result>(SSL *ssl, long arg);
617
618=item int B<SSL_set_wfd>(SSL *ssl, int fd);
619
620=item int B<SSL_shutdown>(SSL *ssl);
621
622=item int B<SSL_state>(const SSL *ssl);
623
624=item char *B<SSL_state_string>(const SSL *ssl);
625
626=item char *B<SSL_state_string_long>(const SSL *ssl);
627
628=item long B<SSL_total_renegotiations>(SSL *ssl);
629
630=item int B<SSL_use_PrivateKey>(SSL *ssl, EVP_PKEY *pkey);
631
632=item int B<SSL_use_PrivateKey_ASN1>(int type, SSL *ssl, unsigned char *d, long len);
633
634=item int B<SSL_use_PrivateKey_file>(SSL *ssl, char *file, int type);
635
636=item int B<SSL_use_RSAPrivateKey>(SSL *ssl, RSA *rsa);
637
638=item int B<SSL_use_RSAPrivateKey_ASN1>(SSL *ssl, unsigned char *d, long len);
639
640=item int B<SSL_use_RSAPrivateKey_file>(SSL *ssl, char *file, int type);
641
642=item int B<SSL_use_certificate>(SSL *ssl, X509 *x);
643
644=item int B<SSL_use_certificate_ASN1>(SSL *ssl, int len, unsigned char *d);
645
646=item int B<SSL_use_certificate_file>(SSL *ssl, char *file, int type);
647
648=item int B<SSL_version>(const SSL *ssl);
649
650=item int B<SSL_want>(const SSL *ssl);
651
652=item int B<SSL_want_nothing>(const SSL *ssl);
653
654=item int B<SSL_want_read>(const SSL *ssl);
655
656=item int B<SSL_want_write>(const SSL *ssl);
657
658=item int B<SSL_want_x509_lookup>(const SSL *ssl);
659
660=item int B<SSL_write>(SSL *ssl, const void *buf, int num);
661
662=item void B<SSL_set_psk_client_callback>(SSL *ssl, unsigned int (*callback)(SSL *ssl, const char *hint, char *identity, unsigned int max_identity_len, unsigned char *psk, unsigned int max_psk_len));
663
664=item int B<SSL_use_psk_identity_hint>(SSL *ssl, const char *hint);
665
666=item void B<SSL_set_psk_server_callback>(SSL *ssl, unsigned int (*callback)(SSL *ssl, const char *identity, unsigned char *psk, int max_psk_len));
667
668=item const char *B<SSL_get_psk_identity_hint>(SSL *ssl);
669
670=item const char *B<SSL_get_psk_identity>(SSL *ssl);
671
672=back
673
674=head1 SEE ALSO
675
676L<openssl(1)|openssl(1)>, L<crypto(3)|crypto(3)>,
677L<SSL_accept(3)|SSL_accept(3)>, L<SSL_clear(3)|SSL_clear(3)>,
678L<SSL_connect(3)|SSL_connect(3)>,
679L<SSL_CIPHER_get_name(3)|SSL_CIPHER_get_name(3)>,
680L<SSL_COMP_add_compression_method(3)|SSL_COMP_add_compression_method(3)>,
681L<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)>,
682L<SSL_CTX_add_session(3)|SSL_CTX_add_session(3)>,
683L<SSL_CTX_ctrl(3)|SSL_CTX_ctrl(3)>,
684L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)>,
685L<SSL_CTX_get_ex_new_index(3)|SSL_CTX_get_ex_new_index(3)>,
686L<SSL_CTX_get_verify_mode(3)|SSL_CTX_get_verify_mode(3)>,
687L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>
688L<SSL_CTX_new(3)|SSL_CTX_new(3)>,
689L<SSL_CTX_sess_number(3)|SSL_CTX_sess_number(3)>,
690L<SSL_CTX_sess_set_cache_size(3)|SSL_CTX_sess_set_cache_size(3)>,
691L<SSL_CTX_sess_set_get_cb(3)|SSL_CTX_sess_set_get_cb(3)>,
692L<SSL_CTX_sessions(3)|SSL_CTX_sessions(3)>,
693L<SSL_CTX_set_cert_store(3)|SSL_CTX_set_cert_store(3)>,
694L<SSL_CTX_set_cert_verify_callback(3)|SSL_CTX_set_cert_verify_callback(3)>,
695L<SSL_CTX_set_cipher_list(3)|SSL_CTX_set_cipher_list(3)>,
696L<SSL_CTX_set_client_CA_list(3)|SSL_CTX_set_client_CA_list(3)>,
697L<SSL_CTX_set_client_cert_cb(3)|SSL_CTX_set_client_cert_cb(3)>,
698L<SSL_CTX_set_default_passwd_cb(3)|SSL_CTX_set_default_passwd_cb(3)>,
699L<SSL_CTX_set_generate_session_id(3)|SSL_CTX_set_generate_session_id(3)>,
700L<SSL_CTX_set_info_callback(3)|SSL_CTX_set_info_callback(3)>,
701L<SSL_CTX_set_max_cert_list(3)|SSL_CTX_set_max_cert_list(3)>,
702L<SSL_CTX_set_mode(3)|SSL_CTX_set_mode(3)>,
703L<SSL_CTX_set_msg_callback(3)|SSL_CTX_set_msg_callback(3)>,
704L<SSL_CTX_set_options(3)|SSL_CTX_set_options(3)>,
705L<SSL_CTX_set_quiet_shutdown(3)|SSL_CTX_set_quiet_shutdown(3)>,
706L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>,
707L<SSL_CTX_set_session_id_context(3)|SSL_CTX_set_session_id_context(3)>,
708L<SSL_CTX_set_ssl_version(3)|SSL_CTX_set_ssl_version(3)>,
709L<SSL_CTX_set_timeout(3)|SSL_CTX_set_timeout(3)>,
710L<SSL_CTX_set_tmp_rsa_callback(3)|SSL_CTX_set_tmp_rsa_callback(3)>,
711L<SSL_CTX_set_tmp_dh_callback(3)|SSL_CTX_set_tmp_dh_callback(3)>,
712L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>,
713L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>,
714L<SSL_alert_type_string(3)|SSL_alert_type_string(3)>,
715L<SSL_do_handshake(3)|SSL_do_handshake(3)>,
716L<SSL_get_SSL_CTX(3)|SSL_get_SSL_CTX(3)>,
717L<SSL_get_ciphers(3)|SSL_get_ciphers(3)>,
718L<SSL_get_client_CA_list(3)|SSL_get_client_CA_list(3)>,
719L<SSL_get_default_timeout(3)|SSL_get_default_timeout(3)>,
720L<SSL_get_error(3)|SSL_get_error(3)>,
721L<SSL_get_ex_data_X509_STORE_CTX_idx(3)|SSL_get_ex_data_X509_STORE_CTX_idx(3)>,
722L<SSL_get_ex_new_index(3)|SSL_get_ex_new_index(3)>,
723L<SSL_get_fd(3)|SSL_get_fd(3)>,
724L<SSL_get_peer_cert_chain(3)|SSL_get_peer_cert_chain(3)>,
725L<SSL_get_rbio(3)|SSL_get_rbio(3)>,
726L<SSL_get_session(3)|SSL_get_session(3)>,
727L<SSL_get_verify_result(3)|SSL_get_verify_result(3)>,
728L<SSL_get_version(3)|SSL_get_version(3)>,
729L<SSL_library_init(3)|SSL_library_init(3)>,
730L<SSL_load_client_CA_file(3)|SSL_load_client_CA_file(3)>,
731L<SSL_new(3)|SSL_new(3)>,
732L<SSL_pending(3)|SSL_pending(3)>,
733L<SSL_read(3)|SSL_read(3)>,
734L<SSL_rstate_string(3)|SSL_rstate_string(3)>,
735L<SSL_session_reused(3)|SSL_session_reused(3)>,
736L<SSL_set_bio(3)|SSL_set_bio(3)>,
737L<SSL_set_connect_state(3)|SSL_set_connect_state(3)>,
738L<SSL_set_fd(3)|SSL_set_fd(3)>,
739L<SSL_set_session(3)|SSL_set_session(3)>,
740L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>,
741L<SSL_shutdown(3)|SSL_shutdown(3)>,
742L<SSL_state_string(3)|SSL_state_string(3)>,
743L<SSL_want(3)|SSL_want(3)>,
744L<SSL_write(3)|SSL_write(3)>,
745L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>,
746L<SSL_SESSION_get_ex_new_index(3)|SSL_SESSION_get_ex_new_index(3)>,
747L<SSL_SESSION_get_time(3)|SSL_SESSION_get_time(3)>,
748L<d2i_SSL_SESSION(3)|d2i_SSL_SESSION(3)>,
749L<SSL_CTX_set_psk_client_callback(3)|SSL_CTX_set_psk_client_callback(3)>,
750L<SSL_CTX_use_psk_identity_hint(3)|SSL_CTX_use_psk_identity_hint(3)>,
751L<SSL_get_psk_identity(3)|SSL_get_psk_identity(3)>
752
753=head1 HISTORY
754
755The L<ssl(3)|ssl(3)> document appeared in OpenSSL 0.9.2
756
757=cut
758