diff --git a/include/ircd/openssl.h b/include/ircd/openssl.h index 008b18f5f..55ed4eee3 100644 --- a/include/ircd/openssl.h +++ b/include/ircd/openssl.h @@ -90,8 +90,8 @@ namespace ircd::openssl string_view write_pem(const mutable_buffer &out, const X509 &); string_view print(const mutable_buffer &buf, const X509 &); string_view genX509(const mutable_buffer &out, const json::object &opts); - const X509 &get_peer_cert(const SSL &); - X509 &get_peer_cert(SSL &); + const X509 &peer_cert(const SSL &); + X509 &peer_cert(SSL &); } /// OpenSSL BIO convenience utils and wraps; also secure file IO closures diff --git a/ircd/net.cc b/ircd/net.cc index a37c96183..2599e1989 100644 --- a/ircd/net.cc +++ b/ircd/net.cc @@ -201,7 +201,7 @@ ircd::net::peer_cert_der(const mutable_raw_buffer &buf, const socket &socket) { const SSL &ssl(socket); - const X509 &cert(openssl::get_peer_cert(ssl)); + const X509 &cert{openssl::peer_cert(ssl)}; return openssl::i2d(buf, cert); } diff --git a/ircd/openssl.cc b/ircd/openssl.cc index 83b481045..601c43353 100644 --- a/ircd/openssl.cc +++ b/ircd/openssl.cc @@ -57,6 +57,30 @@ namespace ircd::openssl void append_entries(X509 &cert, const json::object &opts); } +X509 & +ircd::openssl::peer_cert(SSL &ssl) +{ + auto *const ret + { + SSL_get_peer_certificate(&ssl) + }; + + assert(ret); + return *ret; +} + +const X509 & +ircd::openssl::peer_cert(const SSL &ssl) +{ + const auto *const ret + { + SSL_get_peer_certificate(&ssl) + }; + + assert(ret); + return *ret; +} + ircd::string_view ircd::openssl::genX509(const mutable_buffer &out, const json::object &opts) @@ -316,30 +340,6 @@ ircd::openssl::i2d(const mutable_raw_buffer &buf, return ret; } -X509 & -ircd::openssl::get_peer_cert(SSL &ssl) -{ - auto *const ret - { - SSL_get_peer_certificate(&ssl) - }; - - assert(ret); - return *ret; -} - -const X509 & -ircd::openssl::get_peer_cert(const SSL &ssl) -{ - const auto *const ret - { - SSL_get_peer_certificate(&ssl) - }; - - assert(ret); - return *ret; -} - // // RSA //