mirror of
https://github.com/vlang/v.git
synced 2025-09-07 22:30:57 -04:00
net.openssl: replace SSL_get1_peer_certificate by SSL_get_peer_certificate for OpenBSD (#24556)
OpenBSD uses LibreSSL (OpenSSL fork) by default for libssl/libcrypto. SSL_get1_peer_certificate is not supported by LibreSSL, replace it by SSL_get_peer_certificate.
This commit is contained in:
parent
ddb15646a7
commit
a8aeae2111
5
vlib/net/openssl/openssl_openbsd.c.v
Normal file
5
vlib/net/openssl/openssl_openbsd.c.v
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
module openssl
|
||||||
|
|
||||||
|
// SSL_get_peer1_certificate not defined in LibreSSL (OpenSSL fork) on OpenBSD,
|
||||||
|
// use SSL_get_peer_certificate instead.
|
||||||
|
fn C.SSL_get_peer_certificate(ssl &SSL) &C.X509
|
@ -223,6 +223,7 @@ fn (mut s SSLConn) complete_connect() ! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if s.config.validate {
|
if s.config.validate {
|
||||||
|
mut pcert := &C.X509(unsafe { nil })
|
||||||
for {
|
for {
|
||||||
mut res := C.SSL_do_handshake(voidptr(s.ssl))
|
mut res := C.SSL_do_handshake(voidptr(s.ssl))
|
||||||
if res == 1 {
|
if res == 1 {
|
||||||
@ -239,7 +240,11 @@ fn (mut s SSLConn) complete_connect() ! {
|
|||||||
}
|
}
|
||||||
return error('Could not validate SSL certificate. (${err_res}),err')
|
return error('Could not validate SSL certificate. (${err_res}),err')
|
||||||
}
|
}
|
||||||
pcert := C.SSL_get1_peer_certificate(voidptr(s.ssl))
|
$if openbsd {
|
||||||
|
pcert = C.SSL_get_peer_certificate(voidptr(s.ssl))
|
||||||
|
} $else {
|
||||||
|
pcert = C.SSL_get1_peer_certificate(voidptr(s.ssl))
|
||||||
|
}
|
||||||
defer {
|
defer {
|
||||||
if pcert != 0 {
|
if pcert != 0 {
|
||||||
C.X509_free(pcert)
|
C.X509_free(pcert)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user