Skip to content

Commit

Permalink
More X509View
Browse files Browse the repository at this point in the history
  • Loading branch information
timja committed Jan 16, 2025
1 parent 69d176c commit 19d30a0
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/crypto/crypto_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -446,19 +446,16 @@ void ReadMacOSKeychainCertificates(
CFRelease(currAnchors);

for (size_t i = 0; i < system_root_certificates_X509.size(); i++) {
BIOPointer bio(BIO_new(BIO_s_mem()));
CHECK(bio);

BUF_MEM* mem = nullptr;
int result = PEM_write_bio_X509(bio.get(),
system_root_certificates_X509[i]);
if (!result) {
fprintf(stderr, "Warning: PEM_write_bio_X509 failed with: %d", result);
ncrypto::X509View x509_view(system_root_certificates_X509[i]);

auto pemBio = x509_view.toPEM();
if (!pemBio) {
fprintf(stderr, "Warning: converting to pem failed");
continue;
}

BIO_get_mem_ptr(bio.get(), &mem);
std::string certificate_string_pem(mem->data, mem->length);
auto pemCString = bioToCString(&pemBio);
std::string certificate_string_pem = pemCString;

system_root_certificates->emplace_back(certificate_string_pem);
}
Expand Down

0 comments on commit 19d30a0

Please sign in to comment.