MCPcopy Create free account
hub / github.com/3rdparty/libprocess / pem_to_rsa

Function pem_to_rsa

src/ssl/utilities.cpp:381–395  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

379
380template<typename Reader>
381Try<shared_ptr<RSA>> pem_to_rsa(const string& pem, Reader reader)
382{
383 // We cast away constness from `pem`'s data since in older SSL versions
384 // `BIO_new_mem_buf` took a non-const `char*` which was semantically `const`.
385 BIO *bio = BIO_new_mem_buf(const_cast<char*>(pem.c_str()), -1);
386 if (bio == nullptr) {
387 return Error("Failed to create RSA key bio");
388 }
389 RSA *rsa = reader(bio, nullptr, nullptr, nullptr);
390 BIO_free(bio);
391 if (rsa == nullptr) {
392 return Error("Failed to create RSA from key bio");
393 }
394 return shared_ptr<RSA>(rsa, RSA_free);
395}
396
397
398Try<shared_ptr<RSA>> pem_to_rsa_private_key(const string& pem)

Callers 2

pem_to_rsa_private_keyFunction · 0.85
pem_to_rsa_public_keyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected