blob: 1bcfbf75c922238652a666af08d9f9407eb4a937 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001--- a/src/dtls.c
2+++ b/src/dtls.c
3@@ -698,8 +698,10 @@ dtls dtls_create(uint16_t port)
4 if (!_ssl_initialized)
5 {
6 _ssl_initialized = true;
7+#if OPENSSL_VERSION_NUMBER < 0x10100000L
8 SSL_load_error_strings();
9 SSL_library_init();
10+#endif
11 }
12 if (!d)
13 goto fail;
14@@ -711,9 +713,9 @@ dtls dtls_create(uint16_t port)
15 goto fail;
16
17 #ifdef USE_ONE_CONTEXT
18- SSL_CTX *ctx = SSL_CTX_new(DTLSv1_method());
19+ SSL_CTX *ctx = SSL_CTX_new(DTLS_method());
20 #else
21- SSL_CTX *ctx = SSL_CTX_new(DTLSv1_server_method());
22+ SSL_CTX *ctx = SSL_CTX_new(DTLS_server_method());
23 #endif /* USE_ONE_CONTEXT */
24 if (!ctx)
25 {
26@@ -1002,6 +1004,7 @@ _client_psk(SSL *ssl,
27
28 bool dtls_set_psk(dtls d, const char *psk, size_t psk_len)
29 {
30+#ifndef OPENSSL_NO_PSK
31 free(d->psk);
32 d->psk = malloc(psk_len);
33 if (!d->psk)
34@@ -1011,6 +1014,9 @@ bool dtls_set_psk(dtls d, const char *ps
35 SSL_CTX_set_psk_client_callback(d->ssl_client_ctx, _client_psk);
36 SSL_CTX_set_psk_server_callback(d->ssl_server_ctx, _server_psk);
37 return true;
38+#else
39+ return false;
40+#endif
41 }
42
43 bool dtls_cert_to_pem_buf(dtls_cert cert, char *buf, int buf_len)