19#include <openssl/ssl.h>
20#include <openssl/bio.h>
44 x509_ = {x509, ::X509_free};
55 :
x509_(std::move(other.x509_))
72 x509_ = std::move(other.x509_);
79 return static_cast<bool>(
x509_);
94 BIO *bio = ::BIO_new_mem_buf(
const_cast<char *
>(
cert_txt.c_str()), numeric_cast<int>(
cert_txt.length()));
98 ::X509 *cert = ::PEM_read_bio_X509(bio,
nullptr,
nullptr,
nullptr);
101 throw OpenSSLException(std::string(
"X509::parse_pem: error in ") + title + std::string(
":"));
103 x509_ = {cert, X509_free};
110 BIO *bio = ::BIO_new(BIO_s_mem());
111 const int ret = ::PEM_write_bio_X509(bio,
x509_.get());
120 const auto buf_len = ::BIO_get_mem_data(bio, &temp);
121 std::string
ret = std::string(temp, buf_len);
138 return {
dup, ::X509_free};
142 return {
nullptr, ::X509_free};
145 static ::X509 *
dup(const ::X509 *x509)
148 return ::X509_dup(
const_cast<::
X509 *
>(x509));
169 for (
const auto &e : *
this)
170 ret += e.render_pem();
std::string render_pem() const
std::unique_ptr<::X509, decltype(&::X509_free)> X509_unique_ptr
X509(::X509 *x509, const bool create=true)
X509(X509 &&other) noexcept
X509 & operator=(const X509 &other)
static X509_unique_ptr dup(const X509_unique_ptr &x509)
X509 & operator=(X509 &&other) noexcept
::X509 * dup(const ::X509 *x509)
void parse_pem(const std::string &cert_txt, const std::string &title)
X509(const std::string &cert_txt, const std::string &title)
std::string render_pem() const
const std::string cert_txt