Lines Matching refs:ssl
57 static int handle_io_failure(SSL *ssl, int res);
209 static void wait_for_activity(SSL *ssl) in wait_for_activity() argument
217 sock = SSL_get_fd(ssl); in wait_for_activity()
226 if (SSL_net_write_desired(ssl)) in wait_for_activity()
228 if (SSL_net_read_desired(ssl)) in wait_for_activity()
236 if (SSL_get_event_timeout(ssl, &tv, &isinfinite) && !isinfinite) in wait_for_activity()
283 static int handle_io_failure(SSL *ssl, int res) in handle_io_failure() argument
285 switch (SSL_get_error(ssl, res)) { in handle_io_failure()
289 wait_for_activity(ssl); in handle_io_failure()
305 switch (SSL_get_stream_read_state(ssl)) { in handle_io_failure()
327 if (SSL_get_verify_result(ssl) != X509_V_OK) in handle_io_failure()
329 X509_verify_cert_error_string(SSL_get_verify_result(ssl))); in handle_io_failure()
364 static int cache_new_session(struct ssl_st *ssl, SSL_SESSION *sess) in cache_new_session() argument
398 static int setup_session_cache(SSL *ssl, SSL_CTX *ctx, const char *filename) in setup_session_cache() argument
431 if (!SSL_set_session(ssl, sess)) in setup_session_cache()
524 static size_t build_request_set(SSL *ssl) in build_request_set() argument
541 SSL_free(poll_list[poll_idx].desc.value.ssl); in build_request_set()
619 new_stream = SSL_new_stream(ssl, 0); in build_request_set()
628 SSL_handle_events(ssl); in build_request_set()
652 while (!SSL_write_ex2(poll_list[poll_idx].desc.value.ssl, in build_request_set()
655 if (handle_io_failure(poll_list[poll_idx].desc.value.ssl, 0) == 1) in build_request_set()
668 SSL_free(poll_list[poll_idx].desc.value.ssl); in build_request_set()
702 SSL_CTX **ctx, SSL **ssl) in setup_connection() argument
749 *ssl = SSL_new(*ctx); in setup_connection()
750 if (*ssl == NULL) { in setup_connection()
756 if (!setup_session_cache(*ssl, *ctx, getenv("SSL_SESSION_FILE"))) { in setup_connection()
771 SSL_set_bio(*ssl, bio, bio); in setup_connection()
777 if (!SSL_set_tlsext_host_name(*ssl, hostname)) { in setup_connection()
788 if (!SSL_set1_host(*ssl, hostname)) { in setup_connection()
794 if (SSL_set_alpn_protos(*ssl, alpn, sizeof(alpn)) != 0) { in setup_connection()
800 if (!SSL_set1_initial_peer_addr(*ssl, peer_addr)) { in setup_connection()
810 if (!SSL_set_blocking_mode(*ssl, 0)) { in setup_connection()
816 while ((ret = SSL_connect(*ssl)) != 1) { in setup_connection()
817 if (handle_io_failure(*ssl, ret) == 1) in setup_connection()
826 SSL_free(*ssl); in setup_connection()
829 *ssl = NULL; in setup_connection()
861 SSL *ssl = NULL; in main() local
916 if (!setup_connection(hostname, port, &ctx, &ssl)) { in main()
934 this_poll_count = build_request_set(ssl); in main()
974 if (!SSL_read_ex(poll_list[poll_idx].desc.value.ssl, buf, in main()
976 switch (handle_io_failure(poll_list[poll_idx].desc.value.ssl, in main()
1011 this_poll_count = build_request_set(ssl); in main()
1021 while ((ret = SSL_shutdown(ssl)) != 1) { in main()
1022 if (ret < 0 && handle_io_failure(ssl, ret) == 1) in main()
1048 SSL_free(poll_list[poll_idx].desc.value.ssl); in main()
1050 SSL_free(ssl); in main()