0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-02 18:18:56 +02:00

ircd::openssl: Add wrapper to print certificate subject from a PEM buffer.

This commit is contained in:
Jason Volk 2018-01-26 18:35:08 -08:00
parent 9c91f8d772
commit 638843ade1
2 changed files with 15 additions and 0 deletions

View file

@ -108,6 +108,7 @@ namespace ircd::openssl
string_view genX509_rsa(const mutable_buffer &out, const json::object &opts);
string_view genX509_ec(const mutable_buffer &out, const json::object &opts);
string_view print_subject(const mutable_buffer &buf, const X509 &, ulong flags = -1);
string_view print_subject(const mutable_buffer &buf, const string_view &pem, ulong flags = -1);
string_view subject_common_name(const mutable_buffer &out, const X509 &);
const X509 &peer_cert(const SSL &);
X509 &peer_cert(SSL &);

View file

@ -373,6 +373,20 @@ ircd::openssl::subject_common_name(const mutable_buffer &out,
return { data(out), size_t(len) };
}
ircd::string_view
ircd::openssl::print_subject(const mutable_buffer &buf,
const string_view &pem,
ulong flags)
{
const custom_ptr<X509> x509
{
X509_new(),
[](X509 *const x509) { X509_free(x509); }
};
return print_subject(buf, read_pem(*x509, pem), flags);
}
ircd::string_view
ircd::openssl::print_subject(const mutable_buffer &buf,
const X509 &cert,