24typedef struct ssl_st
SSL;
36#define SSL_CTRL_OPTIONS (32)
37#define SSL_CTRL_CLEAR_OPTIONS (77)
38#define SSL_CTRL_SET_ECDH_AUTO (94)
40#define OPENSSL_INIT_NO_LOAD_SSL_STRINGS 0x00100000L
41#define OPENSSL_INIT_LOAD_SSL_STRINGS 0x00200000L
42#define OPENSSL_INIT_LOAD_CRYPTO_STRINGS 0x00000002L
44#define SSL_VERIFY_NONE (0)
45#define SSL_VERIFY_PEER (1)
46#define SSL_VERIFY_FAIL_IF_NO_PEER_CERT (2)
47#define SSL_VERIFY_CLIENT_ONCE (4)
49#define SSL_OP_ALL (0x80000BFFul)
51#define SSL_OP_NO_SSLv2 (0x01000000ul)
52#define SSL_OP_NO_SSLv3 (0x02000000ul)
53#define SSL_OP_NO_TLSv1 (0x04000000ul)
54#define SSL_OP_NO_TLSv1_2 (0x08000000ul)
55#define SSL_OP_NO_TLSv1_1 (0x10000000ul)
56#define SSL_OP_NO_TLSv1_3 (0x20000000ul)
57#define SSL_OP_SINGLE_DH_USE (0x00100000ul)
58#define SSL_OP_CIPHER_SERVER_PREFERENCE (0x00400000ul)
59#define SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION (0x00010000ul)
60#define SSL_OP_NO_COMPRESSION (0x00020000ul)
61#define SSL_OP_NO_RENEGOTIATION (0x40000000ul)
63#define SSL_CB_HANDSHAKE_START (0x10)
64#define SSL_CB_HANDSHAKE_DONE (0x20)
66#define SSL_ERROR_NONE (0)
67#define SSL_ERROR_SSL (1)
68#define SSL_ERROR_WANT_READ (2)
69#define SSL_ERROR_WANT_WRITE (3)
70#define SSL_ERROR_WANT_X509_LOOKUP (4)
71#define SSL_ERROR_SYSCALL (5)
72#define SSL_ERROR_ZERO_RETURN (6)
73#define SSL_ERROR_WANT_CONNECT (7)
74#define SSL_ERROR_WANT_ACCEPT (8)
76#define TLSEXT_TYPE_server_name (0)
77#define TLSEXT_NAMETYPE_host_name (0)
78#define SSL_TLSEXT_ERR_OK (0)
79#define SSL_TLSEXT_ERR_ALERT_WARNING (1)
80#define SSL_TLSEXT_ERR_ALERT_FATAL (2)
81#define SSL_TLSEXT_ERR_NOACK (3)
83#define SSL_SESS_CACHE_BOTH (3)
101#if (defined(OPENSSL_API_1_1) || defined(OPENSSL_API_3_0)) \
102 && !defined(NO_SSL_DL)
104#define SSL_free (*(void (*)(SSL *))ssl_sw[0].ptr)
105#define SSL_accept (*(int (*)(SSL *))ssl_sw[1].ptr)
106#define SSL_connect (*(int (*)(SSL *))ssl_sw[2].ptr)
107#define SSL_read (*(int (*)(SSL *, void *, int))ssl_sw[3].ptr)
108#define SSL_write (*(int (*)(SSL *, const void *, int))ssl_sw[4].ptr)
109#define SSL_get_error (*(int (*)(SSL *, int))ssl_sw[5].ptr)
110#define SSL_set_fd (*(int (*)(SSL *, SOCKET))ssl_sw[6].ptr)
111#define SSL_new (*(SSL * (*)(SSL_CTX *)) ssl_sw[7].ptr)
112#define SSL_CTX_new (*(SSL_CTX * (*)(SSL_METHOD *)) ssl_sw[8].ptr)
113#define TLS_server_method (*(SSL_METHOD * (*)(void)) ssl_sw[9].ptr)
114#define OPENSSL_init_ssl \
115 (*(int (*)(uint64_t opts, \
116 const OPENSSL_INIT_SETTINGS *settings))ssl_sw[10] \
118#define SSL_CTX_use_PrivateKey_file \
119 (*(int (*)(SSL_CTX *, const char *, int))ssl_sw[11].ptr)
120#define SSL_CTX_use_certificate_file \
121 (*(int (*)(SSL_CTX *, const char *, int))ssl_sw[12].ptr)
122#define SSL_CTX_set_default_passwd_cb \
123 (*(void (*)(SSL_CTX *, mg_callback_t))ssl_sw[13].ptr)
124#define SSL_CTX_free (*(void (*)(SSL_CTX *))ssl_sw[14].ptr)
125#define SSL_CTX_use_certificate_chain_file \
126 (*(int (*)(SSL_CTX *, const char *))ssl_sw[15].ptr)
127#define TLS_client_method (*(SSL_METHOD * (*)(void)) ssl_sw[16].ptr)
128#define SSL_pending (*(int (*)(SSL *))ssl_sw[17].ptr)
129#define SSL_CTX_set_verify \
130 (*(void (*)(SSL_CTX *, \
132 int (*verify_callback)(int, X509_STORE_CTX *)))ssl_sw[18] \
134#define SSL_shutdown (*(int (*)(SSL *))ssl_sw[19].ptr)
135#define SSL_CTX_load_verify_locations \
136 (*(int (*)(SSL_CTX *, const char *, const char *))ssl_sw[20].ptr)
137#define SSL_CTX_set_default_verify_paths (*(int (*)(SSL_CTX *))ssl_sw[21].ptr)
138#define SSL_CTX_set_verify_depth (*(void (*)(SSL_CTX *, int))ssl_sw[22].ptr)
139#define SSL_get_peer_certificate (*(X509 * (*)(SSL *)) ssl_sw[23].ptr)
140#define SSL_get_version (*(const char *(*)(SSL *))ssl_sw[24].ptr)
141#define SSL_get_current_cipher (*(SSL_CIPHER * (*)(SSL *)) ssl_sw[25].ptr)
142#define SSL_CIPHER_get_name \
143 (*(const char *(*)(const SSL_CIPHER *))ssl_sw[26].ptr)
144#define SSL_CTX_check_private_key (*(int (*)(SSL_CTX *))ssl_sw[27].ptr)
145#define SSL_CTX_set_session_id_context \
146 (*(int (*)(SSL_CTX *, const unsigned char *, unsigned int))ssl_sw[28].ptr)
147#define SSL_CTX_ctrl (*(long (*)(SSL_CTX *, int, long, void *))ssl_sw[29].ptr)
148#define SSL_CTX_set_cipher_list \
149 (*(int (*)(SSL_CTX *, const char *))ssl_sw[30].ptr)
150#define SSL_CTX_set_options \
151 (*(unsigned long (*)(SSL_CTX *, unsigned long))ssl_sw[31].ptr)
152#define SSL_CTX_set_info_callback \
153 (*(void (*)(SSL_CTX * ctx, void (*callback)(const SSL *, int, int))) \
156#define SSL_get_ex_data (*(char *(*)(const SSL *, int))ssl_sw[33].ptr)
157#define SSL_set_ex_data (*(void (*)(SSL *, int, char *))ssl_sw[34].ptr)
158#define SSL_CTX_callback_ctrl \
159 (*(long (*)(SSL_CTX *, int, void (*)(void)))ssl_sw[35].ptr)
160#define SSL_get_servername \
161 (*(const char *(*)(const SSL *, int type))ssl_sw[36].ptr)
162#define SSL_set_SSL_CTX (*(SSL_CTX * (*)(SSL *, SSL_CTX *)) ssl_sw[37].ptr)
163#define SSL_ctrl (*(long (*)(SSL *, int, long, void *))ssl_sw[38].ptr)
164#define SSL_CTX_set_alpn_protos \
165 (*(int (*)(SSL_CTX *, const unsigned char *, unsigned))ssl_sw[39].ptr)
166typedef int (*tSSL_alpn_select_cb)(
SSL *ssl,
167 const unsigned char **out,
168 unsigned char *outlen,
169 const unsigned char *in,
172#define SSL_CTX_set_alpn_select_cb \
173 (*(void (*)(SSL_CTX *, tSSL_alpn_select_cb, void *))ssl_sw[40].ptr)
174typedef int (*tSSL_next_protos_advertised_cb)(
SSL *ssl,
175 const unsigned char **out,
176 unsigned int *outlen,
178#define SSL_CTX_set_next_protos_advertised_cb \
179 (*(void (*)(SSL_CTX *, tSSL_next_protos_advertised_cb, void *))ssl_sw[41] \
182#define SSL_CTX_set_timeout (*(long (*)(SSL_CTX *, long))ssl_sw[42].ptr)
184#define SSL_CTX_clear_options(ctx, op) \
185 SSL_CTX_ctrl((ctx), SSL_CTRL_CLEAR_OPTIONS, (op), NULL)
186#define SSL_CTX_set_ecdh_auto(ctx, onoff) \
187 SSL_CTX_ctrl(ctx, SSL_CTRL_SET_ECDH_AUTO, onoff, NULL)
189#define SSL_CTRL_SET_TLSEXT_SERVERNAME_CB 53
190#define SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG 54
191#define SSL_CTRL_SET_TLSEXT_HOSTNAME 55
192#define SSL_CTX_set_tlsext_servername_callback(ctx, cb) \
193 SSL_CTX_callback_ctrl(ctx, \
194 SSL_CTRL_SET_TLSEXT_SERVERNAME_CB, \
196#define SSL_set_tlsext_host_name(ctx, arg) \
197 SSL_ctrl(ctx, SSL_CTRL_SET_TLSEXT_HOSTNAME, 0, (void *)arg)
199#define X509_get_notBefore(x) ((x)->cert_info->validity->notBefore)
200#define X509_get_notAfter(x) ((x)->cert_info->validity->notAfter)
202#define SSL_set_app_data(s, arg) (SSL_set_ex_data(s, 0, (char *)arg))
203#define SSL_get_app_data(s) (SSL_get_ex_data(s, 0))
205#define SSL_CTX_sess_set_cache_size(ctx, size) SSL_CTX_ctrl(ctx, 42, size, NULL)
206#define SSL_CTX_set_session_cache_mode(ctx, mode) \
207 SSL_CTX_ctrl(ctx, 44, mode, NULL)
210#define ERR_get_error (*(unsigned long (*)(void))crypto_sw[0].ptr)
211#define ERR_error_string (*(char *(*)(unsigned long, char *))crypto_sw[1].ptr)
212#define CONF_modules_unload (*(void (*)(int))crypto_sw[2].ptr)
213#define X509_free (*(void (*)(X509 *))crypto_sw[3].ptr)
214#define X509_get_subject_name (*(X509_NAME * (*)(X509 *)) crypto_sw[4].ptr)
215#define X509_get_issuer_name (*(X509_NAME * (*)(X509 *)) crypto_sw[5].ptr)
216#define X509_NAME_oneline \
217 (*(char *(*)(X509_NAME *, char *, int))crypto_sw[6].ptr)
218#define X509_get_serialNumber (*(ASN1_INTEGER * (*)(X509 *)) crypto_sw[7].ptr)
219#define EVP_get_digestbyname \
220 (*(const EVP_MD *(*)(const char *))crypto_sw[8].ptr)
223 const void *, size_t, void *, unsigned int *, const EVP_MD *, void *)) \
226#define i2d_X509 (*(int (*)(X509 *, unsigned char **))crypto_sw[10].ptr)
227#define BN_bn2hex (*(char *(*)(const BIGNUM *a))crypto_sw[11].ptr)
228#define ASN1_INTEGER_to_BN \
229 (*(BIGNUM * (*)(const ASN1_INTEGER *ai, BIGNUM *bn)) crypto_sw[12].ptr)
230#define BN_free (*(void (*)(const BIGNUM *a))crypto_sw[13].ptr)
231#define CRYPTO_free (*(void (*)(void *addr))crypto_sw[14].ptr)
232#define ERR_clear_error (*(void (*)(void))crypto_sw[15].ptr)
234#define OPENSSL_free(a) CRYPTO_free(a)
236#define OPENSSL_REMOVE_THREAD_STATE()
266#if defined(OPENSSL_API_3_0)
286 {
"SSL_CTX_set_alpn_protos",
TLS_ALPN, NULL},
287 {
"SSL_CTX_set_alpn_select_cb",
TLS_ALPN, NULL},
288 {
"SSL_CTX_set_next_protos_advertised_cb",
TLS_ALPN, NULL},
295static struct ssl_func crypto_sw[] = {
316#if defined(OPENSSL_API_1_0)
318#define SSL_free (*(void (*)(SSL *))ssl_sw[0].ptr)
319#define SSL_accept (*(int (*)(SSL *))ssl_sw[1].ptr)
320#define SSL_connect (*(int (*)(SSL *))ssl_sw[2].ptr)
321#define SSL_read (*(int (*)(SSL *, void *, int))ssl_sw[3].ptr)
322#define SSL_write (*(int (*)(SSL *, const void *, int))ssl_sw[4].ptr)
323#define SSL_get_error (*(int (*)(SSL *, int))ssl_sw[5].ptr)
324#define SSL_set_fd (*(int (*)(SSL *, SOCKET))ssl_sw[6].ptr)
325#define SSL_new (*(SSL * (*)(SSL_CTX *)) ssl_sw[7].ptr)
326#define SSL_CTX_new (*(SSL_CTX * (*)(SSL_METHOD *)) ssl_sw[8].ptr)
327#define SSLv23_server_method (*(SSL_METHOD * (*)(void)) ssl_sw[9].ptr)
328#define SSL_library_init (*(int (*)(void))ssl_sw[10].ptr)
329#define SSL_CTX_use_PrivateKey_file \
330 (*(int (*)(SSL_CTX *, const char *, int))ssl_sw[11].ptr)
331#define SSL_CTX_use_certificate_file \
332 (*(int (*)(SSL_CTX *, const char *, int))ssl_sw[12].ptr)
333#define SSL_CTX_set_default_passwd_cb \
334 (*(void (*)(SSL_CTX *, mg_callback_t))ssl_sw[13].ptr)
335#define SSL_CTX_free (*(void (*)(SSL_CTX *))ssl_sw[14].ptr)
336#define SSL_load_error_strings (*(void (*)(void))ssl_sw[15].ptr)
337#define SSL_CTX_use_certificate_chain_file \
338 (*(int (*)(SSL_CTX *, const char *))ssl_sw[16].ptr)
339#define SSLv23_client_method (*(SSL_METHOD * (*)(void)) ssl_sw[17].ptr)
340#define SSL_pending (*(int (*)(SSL *))ssl_sw[18].ptr)
341#define SSL_CTX_set_verify \
342 (*(void (*)(SSL_CTX *, \
344 int (*verify_callback)(int, X509_STORE_CTX *)))ssl_sw[19] \
346#define SSL_shutdown (*(int (*)(SSL *))ssl_sw[20].ptr)
347#define SSL_CTX_load_verify_locations \
348 (*(int (*)(SSL_CTX *, const char *, const char *))ssl_sw[21].ptr)
349#define SSL_CTX_set_default_verify_paths (*(int (*)(SSL_CTX *))ssl_sw[22].ptr)
350#define SSL_CTX_set_verify_depth (*(void (*)(SSL_CTX *, int))ssl_sw[23].ptr)
351#define SSL_get_peer_certificate (*(X509 * (*)(SSL *)) ssl_sw[24].ptr)
352#define SSL_get_version (*(const char *(*)(SSL *))ssl_sw[25].ptr)
353#define SSL_get_current_cipher (*(SSL_CIPHER * (*)(SSL *)) ssl_sw[26].ptr)
354#define SSL_CIPHER_get_name \
355 (*(const char *(*)(const SSL_CIPHER *))ssl_sw[27].ptr)
356#define SSL_CTX_check_private_key (*(int (*)(SSL_CTX *))ssl_sw[28].ptr)
357#define SSL_CTX_set_session_id_context \
358 (*(int (*)(SSL_CTX *, const unsigned char *, unsigned int))ssl_sw[29].ptr)
359#define SSL_CTX_ctrl (*(long (*)(SSL_CTX *, int, long, void *))ssl_sw[30].ptr)
360#define SSL_CTX_set_cipher_list \
361 (*(int (*)(SSL_CTX *, const char *))ssl_sw[31].ptr)
362#define SSL_CTX_set_info_callback \
363 (*(void (*)(SSL_CTX *, void (*callback)(const SSL *, int, int)))ssl_sw[32] \
365#define SSL_get_ex_data (*(char *(*)(const SSL *, int))ssl_sw[33].ptr)
366#define SSL_set_ex_data (*(void (*)(SSL *, int, char *))ssl_sw[34].ptr)
367#define SSL_CTX_callback_ctrl \
368 (*(long (*)(SSL_CTX *, int, void (*)(void)))ssl_sw[35].ptr)
369#define SSL_get_servername \
370 (*(const char *(*)(const SSL *, int type))ssl_sw[36].ptr)
371#define SSL_set_SSL_CTX (*(SSL_CTX * (*)(SSL *, SSL_CTX *)) ssl_sw[37].ptr)
372#define SSL_ctrl (*(long (*)(SSL *, int, long, void *))ssl_sw[38].ptr)
373#define SSL_CTX_set_alpn_protos \
374 (*(int (*)(SSL_CTX *, const unsigned char *, unsigned))ssl_sw[39].ptr)
375typedef int (*tSSL_alpn_select_cb)(
SSL *ssl,
376 const unsigned char **
out,
377 unsigned char *outlen,
378 const unsigned char *in,
381#define SSL_CTX_set_alpn_select_cb \
382 (*(void (*)(SSL_CTX *, tSSL_alpn_select_cb, void *))ssl_sw[40].ptr)
383typedef int (*tSSL_next_protos_advertised_cb)(
SSL *ssl,
384 const unsigned char **
out,
385 unsigned int *outlen,
387#define SSL_CTX_set_next_protos_advertised_cb \
388 (*(void (*)(SSL_CTX *, tSSL_next_protos_advertised_cb, void *))ssl_sw[41] \
391#define SSL_CTX_set_timeout (*(long (*)(SSL_CTX *, long))ssl_sw[42].ptr)
394#define SSL_CTX_set_options(ctx, op) \
395 SSL_CTX_ctrl((ctx), SSL_CTRL_OPTIONS, (op), NULL)
396#define SSL_CTX_clear_options(ctx, op) \
397 SSL_CTX_ctrl((ctx), SSL_CTRL_CLEAR_OPTIONS, (op), NULL)
398#define SSL_CTX_set_ecdh_auto(ctx, onoff) \
399 SSL_CTX_ctrl(ctx, SSL_CTRL_SET_ECDH_AUTO, onoff, NULL)
401#define SSL_CTRL_SET_TLSEXT_SERVERNAME_CB 53
402#define SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG 54
403#define SSL_CTRL_SET_TLSEXT_HOSTNAME 55
404#define SSL_CTX_set_tlsext_servername_callback(ctx, cb) \
405 SSL_CTX_callback_ctrl(ctx, \
406 SSL_CTRL_SET_TLSEXT_SERVERNAME_CB, \
408#define SSL_set_tlsext_host_name(ctx, arg) \
409 SSL_ctrl(ctx, SSL_CTRL_SET_TLSEXT_HOSTNAME, 0, (void *)arg)
411#define X509_get_notBefore(x) ((x)->cert_info->validity->notBefore)
412#define X509_get_notAfter(x) ((x)->cert_info->validity->notAfter)
414#define SSL_set_app_data(s, arg) (SSL_set_ex_data(s, 0, (char *)arg))
415#define SSL_get_app_data(s) (SSL_get_ex_data(s, 0))
417#define SSL_CTX_sess_set_cache_size(ctx, size) SSL_CTX_ctrl(ctx, 42, size, NULL)
418#define SSL_CTX_set_session_cache_mode(ctx, mode) \
419 SSL_CTX_ctrl(ctx, 44, mode, NULL)
422#define CRYPTO_num_locks (*(int (*)(void))crypto_sw[0].ptr)
423#define CRYPTO_set_locking_callback \
424 (*(void (*)(void (*)(int, int, const char *, int)))crypto_sw[1].ptr)
425#define CRYPTO_set_id_callback \
426 (*(void (*)(unsigned long (*)(void)))crypto_sw[2].ptr)
427#define ERR_get_error (*(unsigned long (*)(void))crypto_sw[3].ptr)
428#define ERR_error_string (*(char *(*)(unsigned long, char *))crypto_sw[4].ptr)
429#define ERR_remove_state (*(void (*)(unsigned long))crypto_sw[5].ptr)
430#define ERR_free_strings (*(void (*)(void))crypto_sw[6].ptr)
431#define ENGINE_cleanup (*(void (*)(void))crypto_sw[7].ptr)
432#define CONF_modules_unload (*(void (*)(int))crypto_sw[8].ptr)
433#define CRYPTO_cleanup_all_ex_data (*(void (*)(void))crypto_sw[9].ptr)
434#define EVP_cleanup (*(void (*)(void))crypto_sw[10].ptr)
435#define X509_free (*(void (*)(X509 *))crypto_sw[11].ptr)
436#define X509_get_subject_name (*(X509_NAME * (*)(X509 *)) crypto_sw[12].ptr)
437#define X509_get_issuer_name (*(X509_NAME * (*)(X509 *)) crypto_sw[13].ptr)
438#define X509_NAME_oneline \
439 (*(char *(*)(X509_NAME *, char *, int))crypto_sw[14].ptr)
440#define X509_get_serialNumber (*(ASN1_INTEGER * (*)(X509 *)) crypto_sw[15].ptr)
441#define i2c_ASN1_INTEGER \
442 (*(int (*)(ASN1_INTEGER *, unsigned char **))crypto_sw[16].ptr)
443#define EVP_get_digestbyname \
444 (*(const EVP_MD *(*)(const char *))crypto_sw[17].ptr)
447 const void *, size_t, void *, unsigned int *, const EVP_MD *, void *)) \
450#define i2d_X509 (*(int (*)(X509 *, unsigned char **))crypto_sw[19].ptr)
451#define BN_bn2hex (*(char *(*)(const BIGNUM *a))crypto_sw[20].ptr)
452#define ASN1_INTEGER_to_BN \
453 (*(BIGNUM * (*)(const ASN1_INTEGER *ai, BIGNUM *bn)) crypto_sw[21].ptr)
454#define BN_free (*(void (*)(const BIGNUM *a))crypto_sw[22].ptr)
455#define CRYPTO_free (*(void (*)(void *addr))crypto_sw[23].ptr)
456#define ERR_clear_error (*(void (*)(void))crypto_sw[24].ptr)
458#define OPENSSL_free(a) CRYPTO_free(a)
463#define OPENSSL_REMOVE_THREAD_STATE() ERR_remove_state(0)
509 {
"SSL_CTX_set_alpn_protos",
TLS_ALPN, NULL},
510 {
"SSL_CTX_set_alpn_select_cb",
TLS_ALPN, NULL},
511 {
"SSL_CTX_set_next_protos_advertised_cb",
TLS_ALPN, NULL},
518static struct ssl_func crypto_sw[] = {
struct asn1_integer ASN1_INTEGER
struct ssl_ctx_st SSL_CTX
struct ssl_method_st SSL_METHOD
struct ossl_init_settings_st OPENSSL_INIT_SETTINGS
struct x509_name X509_NAME
struct x509_store_ctx_st X509_STORE_CTX
static int tls_feature_missing[TLS_END_OF_LIST]
enum ssl_func_category required