mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
net.mbedtls: define MBEDTLS_THREADING_PTHREAD, in mbedtls_config.h; call C.mbedtls_ssl_conf_read_timeout explicitly in the wrapper, with a shorter timeout value of 317ms (determined experimentally)
This commit is contained in:
parent
fbc3fc6fcf
commit
4b015c8bc0
3 changed files with 9 additions and 3 deletions
|
@ -1903,7 +1903,7 @@
|
||||||
*
|
*
|
||||||
* Uncomment this to enable pthread mutexes.
|
* Uncomment this to enable pthread mutexes.
|
||||||
*/
|
*/
|
||||||
//#define MBEDTLS_THREADING_PTHREAD
|
#define MBEDTLS_THREADING_PTHREAD
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \def MBEDTLS_USE_PSA_CRYPTO
|
* \def MBEDTLS_USE_PSA_CRYPTO
|
||||||
|
@ -3283,7 +3283,7 @@
|
||||||
*
|
*
|
||||||
* Enable this layer to allow use of mutexes within mbed TLS
|
* Enable this layer to allow use of mutexes within mbed TLS
|
||||||
*/
|
*/
|
||||||
//#define MBEDTLS_THREADING_C
|
#define MBEDTLS_THREADING_C
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \def MBEDTLS_TIMING_C
|
* \def MBEDTLS_TIMING_C
|
||||||
|
|
|
@ -208,3 +208,7 @@ fn C.mbedtls_x509_crt_parse(&C.mbedtls_x509_crt, &u8, usize) int
|
||||||
fn C.mbedtls_x509_crt_parse_file(&C.mbedtls_x509_crt, &char) int
|
fn C.mbedtls_x509_crt_parse_file(&C.mbedtls_x509_crt, &char) int
|
||||||
|
|
||||||
fn C.mbedtls_high_level_strerr(int) &char
|
fn C.mbedtls_high_level_strerr(int) &char
|
||||||
|
|
||||||
|
fn C.mbedtls_debug_set_threshold(level int)
|
||||||
|
|
||||||
|
fn C.mbedtls_ssl_conf_read_timeout(conf &C.mbedtls_ssl_config, timeout u32)
|
||||||
|
|
|
@ -21,6 +21,7 @@ fn init() {
|
||||||
C.mbedtls_ctr_drbg_free(&ctr_drbg)
|
C.mbedtls_ctr_drbg_free(&ctr_drbg)
|
||||||
panic('Failed to seed ssl context: ${ret}')
|
panic('Failed to seed ssl context: ${ret}')
|
||||||
}
|
}
|
||||||
|
// C.mbedtls_debug_set_threshold(5)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,6 +176,7 @@ fn (mut l SSLListener) init() ! {
|
||||||
C.mbedtls_net_init(&l.server_fd)
|
C.mbedtls_net_init(&l.server_fd)
|
||||||
C.mbedtls_ssl_init(&l.ssl)
|
C.mbedtls_ssl_init(&l.ssl)
|
||||||
C.mbedtls_ssl_config_init(&l.conf)
|
C.mbedtls_ssl_config_init(&l.conf)
|
||||||
|
C.mbedtls_ssl_conf_read_timeout(&l.conf, 41_000)
|
||||||
l.certs = &SSLCerts{}
|
l.certs = &SSLCerts{}
|
||||||
C.mbedtls_x509_crt_init(&l.certs.client_cert)
|
C.mbedtls_x509_crt_init(&l.certs.client_cert)
|
||||||
C.mbedtls_pk_init(&l.certs.client_key)
|
C.mbedtls_pk_init(&l.certs.client_key)
|
||||||
|
@ -363,13 +365,13 @@ fn (mut s SSLConn) init() ! {
|
||||||
C.mbedtls_net_init(&s.server_fd)
|
C.mbedtls_net_init(&s.server_fd)
|
||||||
C.mbedtls_ssl_init(&s.ssl)
|
C.mbedtls_ssl_init(&s.ssl)
|
||||||
C.mbedtls_ssl_config_init(&s.conf)
|
C.mbedtls_ssl_config_init(&s.conf)
|
||||||
|
|
||||||
mut ret := 0
|
mut ret := 0
|
||||||
ret = C.mbedtls_ssl_config_defaults(&s.conf, C.MBEDTLS_SSL_IS_CLIENT, C.MBEDTLS_SSL_TRANSPORT_STREAM,
|
ret = C.mbedtls_ssl_config_defaults(&s.conf, C.MBEDTLS_SSL_IS_CLIENT, C.MBEDTLS_SSL_TRANSPORT_STREAM,
|
||||||
C.MBEDTLS_SSL_PRESET_DEFAULT)
|
C.MBEDTLS_SSL_PRESET_DEFAULT)
|
||||||
if ret != 0 {
|
if ret != 0 {
|
||||||
return error_with_code('Failed to set SSL configuration', ret)
|
return error_with_code('Failed to set SSL configuration', ret)
|
||||||
}
|
}
|
||||||
|
C.mbedtls_ssl_conf_read_timeout(&s.conf, 317)
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
C.mbedtls_ssl_conf_rng(&s.conf, C.mbedtls_ctr_drbg_random, &ctr_drbg)
|
C.mbedtls_ssl_conf_rng(&s.conf, C.mbedtls_ctr_drbg_random, &ctr_drbg)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue