net.openssl, net.mbedtls: add support for -d trace_ssl, for easier tracing of binary protocol problems to https servers

This commit is contained in:
Delyan Angelov 2023-01-15 15:49:31 +02:00
parent 7f3531077d
commit bfb47005c8
No known key found for this signature in database
GPG key ID: 66886C0F12D595ED
4 changed files with 136 additions and 15 deletions

View file

@ -3,6 +3,9 @@ module openssl
// ssl_error returns non error ssl code or error if unrecoverable and we should panic
fn ssl_error(ret int, ssl voidptr) !SSLError {
res := C.SSL_get_error(ssl, ret)
$if trace_ssl ? {
eprintln('${@METHOD} ret: ${ret} | ssl: ${ssl:x} | res: ${res}')
}
match unsafe { SSLError(res) } {
.ssl_error_syscall {
return error_with_code('unrecoverable syscall (${res})', res)