v2 / vlib / net / openssl / openssl_compat.h
24 lines · 23 sloc · 804 bytes · f06f8e99575d9db0b490c620f6e15562e80b0c75
Raw
1// Match the init API to the OpenSSL headers that are actually available.
2#if defined(LIBRESSL_VERSION_NUMBER) || !defined(OPENSSL_VERSION_NUMBER) \
3 || OPENSSL_VERSION_NUMBER < 0x10100000L
4static int v_net_openssl_init_ssl(void) {
5 SSL_load_error_strings();
6 return SSL_library_init();
7}
8#else
9static int v_net_openssl_init_ssl(void) {
10 return OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS, 0);
11}
12#endif
13
14// SSL_get1_peer_certificate is only available in OpenSSL 3.x.
15#if defined(LIBRESSL_VERSION_NUMBER) || !defined(OPENSSL_VERSION_NUMBER) \
16 || OPENSSL_VERSION_NUMBER < 0x30000000L
17static X509 *v_net_openssl_get1_peer_certificate(SSL *ssl) {
18 return SSL_get_peer_certificate(ssl);
19}
20#else
21static X509 *v_net_openssl_get1_peer_certificate(SSL *ssl) {
22 return SSL_get1_peer_certificate(ssl);
23}
24#endif
25