CertificateToString(): allow raw pointer input

This commit is contained in:
Alexander A. Klimov 2023-12-08 10:35:14 +01:00
parent bc778116e9
commit 551c3afa60
2 changed files with 8 additions and 3 deletions

View File

@ -787,10 +787,10 @@ bool IsCaUptodate(X509* cert)
return !CertExpiresWithin(cert, LEAF_VALID_FOR);
}
String CertificateToString(const std::shared_ptr<X509>& cert)
String CertificateToString(X509* cert)
{
BIO *mem = BIO_new(BIO_s_mem());
PEM_write_bio_X509(mem, cert.get());
PEM_write_bio_X509(mem, cert);
char *data;
long len = BIO_get_mem_data(mem, &data);

View File

@ -58,7 +58,12 @@ int MakeX509CSR(const String& cn, const String& keyfile, const String& csrfile =
std::shared_ptr<X509> CreateCert(EVP_PKEY *pubkey, X509_NAME *subject, X509_NAME *issuer, EVP_PKEY *cakey, bool ca);
String GetIcingaCADir();
String CertificateToString(const std::shared_ptr<X509>& cert);
String CertificateToString(X509* cert);
inline String CertificateToString(const std::shared_ptr<X509>& cert)
{
return CertificateToString(cert.get());
}
std::shared_ptr<X509> StringToCertificate(const String& cert);
std::shared_ptr<X509> CreateCertIcingaCA(EVP_PKEY *pubkey, X509_NAME *subject, bool ca = false);