Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
Attempt to support pre-1.1.0 openssl.
Browse files Browse the repository at this point in the history
Despite that the website claims that "these functions are available in
all versions of OpenSSL."

Signed-off-by: Patrick Vacek <[email protected]>
  • Loading branch information
pattivacek committed Feb 13, 2020
1 parent b7adc45 commit 115b298
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/libaktualizr/crypto/keymanager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,22 @@ void KeyManager::getCertInfo(std::string *subject, std::string *issuer, std::str
}
*issuer = std::string(issuer_buf, static_cast<size_t>(issuer_len));

#if AKTUALIZR_OPENSSL_PRE_11
const ASN1_TIME *nb_asn1 = X509_get_notBefore(x.get());
#else
const ASN1_TIME *nb_asn1 = X509_get0_notBefore(x.get());
#endif
StructGuard<BIO> nb_bio(BIO_new(BIO_s_mem()), BIO_vfree);
ASN1_TIME_print(nb_bio.get(), nb_asn1);
char *nb_buf;
auto nb_len = BIO_get_mem_data(nb_bio.get(), &nb_buf); // NOLINT(cppcoreguidelines-pro-type-cstyle-cast)
*not_before = std::string(nb_buf, static_cast<size_t>(nb_len));

#if AKTUALIZR_OPENSSL_PRE_11
const ASN1_TIME *na_asn1 = X509_get_notAfter(x.get());
#else
const ASN1_TIME *na_asn1 = X509_get0_notAfter(x.get());
#endif
StructGuard<BIO> na_bio(BIO_new(BIO_s_mem()), BIO_vfree);
ASN1_TIME_print(na_bio.get(), na_asn1);
char *na_buf;
Expand Down

0 comments on commit 115b298

Please sign in to comment.