| 847 | } |
| 848 | |
| 849 | void |
| 850 | SSLInitializeLibrary() |
| 851 | { |
| 852 | if (!open_ssl_initialized) { |
| 853 | // BoringSSL does not have the memory functions |
| 854 | #ifdef HAVE_CRYPTO_SET_MEM_FUNCTIONS |
| 855 | if (res_track_memory >= 2) { |
| 856 | CRYPTO_set_mem_functions(ssl_track_malloc, ssl_track_realloc, ssl_track_free); |
| 857 | } else { |
| 858 | CRYPTO_set_mem_functions(ssl_malloc, ssl_realloc, ssl_free); |
| 859 | } |
| 860 | #endif |
| 861 | |
| 862 | SSL_load_error_strings(); |
| 863 | SSL_library_init(); |
| 864 | |
| 865 | #ifdef OPENSSL_FIPS |
| 866 | // calling FIPS_mode_set() will force FIPS to POST (Power On Self Test) |
| 867 | // After POST we don't have to lock for FIPS |
| 868 | int mode = FIPS_mode(); |
| 869 | FIPS_mode_set(mode); |
| 870 | Dbg(dbg_ctl_ssl_load, "FIPS_mode: %d", mode); |
| 871 | #endif |
| 872 | |
| 873 | mutex_buf = static_cast<ink_mutex *>(OPENSSL_malloc(CRYPTO_num_locks() * sizeof(ink_mutex))); |
| 874 | |
| 875 | for (int i = 0; i < CRYPTO_num_locks(); i++) { |
| 876 | ink_mutex_init(&mutex_buf[i]); |
| 877 | } |
| 878 | |
| 879 | CRYPTO_set_locking_callback(SSL_locking_callback); |
| 880 | #if !defined(CRYPTO_THREADID_set_callback) |
| 881 | CRYPTO_THREADID_set_callback(SSL_pthreads_thread_id); |
| 882 | #endif |
| 883 | CRYPTO_set_dynlock_create_callback(ssl_dyn_create_callback); |
| 884 | CRYPTO_set_dynlock_lock_callback(ssl_dyn_lock_callback); |
| 885 | CRYPTO_set_dynlock_destroy_callback(ssl_dyn_destroy_callback); |
| 886 | } |
| 887 | |
| 888 | ssl_stapling_ex_init(); |
| 889 | |
| 890 | // Reserve an application data index so that we can attach |
| 891 | // the SSLNetVConnection to the SSL session. |
| 892 | ssl_vc_index = SSL_get_ex_new_index(0, (void *)"NetVC index", nullptr, nullptr, nullptr); |
| 893 | |
| 894 | TLSBasicSupport::initialize(); |
| 895 | TLSEventSupport::initialize(); |
| 896 | ALPNSupport::initialize(); |
| 897 | TLSSessionResumptionSupport::initialize(); |
| 898 | TLSSNISupport::initialize(); |
| 899 | TLSEarlyDataSupport::initialize(); |
| 900 | TLSTunnelSupport::initialize(); |
| 901 | TLSCertSwitchSupport::initialize(); |
| 902 | #if TS_USE_QUIC == 1 |
| 903 | QUICSupport::initialize(); |
| 904 | #endif |
| 905 | |
| 906 | open_ssl_initialized = true; |
no test coverage detected