MCPcopy Create free account
hub / github.com/Icinga/icinga2 / SignCsr

Method SignCsr

lib/remote/pkiutility.cpp:57–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55}
56
57int PkiUtility::SignCsr(const String& csrfile, const String& certfile)
58{
59 char errbuf[256];
60
61 InitializeOpenSSL();
62
63 BIO *csrbio = BIO_new_file(csrfile.CStr(), "r");
64 X509_REQ *req = PEM_read_bio_X509_REQ(csrbio, nullptr, nullptr, nullptr);
65
66 if (!req) {
67 ERR_error_string_n(ERR_peek_error(), errbuf, sizeof errbuf);
68 Log(LogCritical, "SSL")
69 << "Could not read X509 certificate request from '" << csrfile << "': " << ERR_peek_error() << ", \"" << errbuf << "\"";
70 return 1;
71 }
72
73 BIO_free(csrbio);
74
75 std::shared_ptr<EVP_PKEY> pubkey = std::shared_ptr<EVP_PKEY>(X509_REQ_get_pubkey(req), EVP_PKEY_free);
76 std::shared_ptr<X509> cert = CreateCertIcingaCA(pubkey.get(), X509_REQ_get_subject_name(req), 0, LEAF_VALID_FOR);
77
78 X509_REQ_free(req);
79
80 WriteCert(cert, certfile);
81
82 return 0;
83}
84
85std::shared_ptr<X509> PkiUtility::FetchCert(const String& host, const String& port)
86{

Callers

nothing calls this directly

Calls 5

InitializeOpenSSLFunction · 0.85
LogClass · 0.85
CreateCertIcingaCAFunction · 0.85
CStrMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected