22 #if OPENSSL_VERSION_NUMBER >= 0x1000105fL 23 #define OPENSSL_GE_101 1 24 #include <openssl/asn1.h> 25 #include <openssl/x509v3.h> 26 #include <openssl/bio.h> 35 std::chrono::milliseconds
const& latency,
38 "SSL error: {}; Elapsed time: {} ms; Bytes read: {}",
39 static_cast<int>(error),
42 error_(error), latency_(latency), bytesRead_(bytesRead) {}
55 X509_NAME* subject = X509_get_subject_name((X509*)cert);
59 char cn[ub_common_name + 1];
60 int res = X509_NAME_get_text_by_NID(subject, NID_commonName,
65 cn[ub_common_name] =
'\0';
66 return std::make_unique<std::string>(cn);
73 auto nameList = std::make_unique<std::list<std::string>>();
74 GENERAL_NAMES* names = (GENERAL_NAMES*)X509_get_ext_d2i(
75 (X509*)cert, NID_subject_alt_name,
nullptr,
nullptr);
78 size_t count = sk_GENERAL_NAME_num(names);
80 for (
int i = 0;
i < (int)count; ++
i) {
81 GENERAL_NAME* generalName = sk_GENERAL_NAME_value(names,
i);
82 if (generalName->type == GEN_DNS) {
83 ASN1_STRING*
s = generalName->d.dNSName;
87 auto len = ASN1_STRING_length(s);
89 if (
size_t(len) != strlen(name)) {
94 nameList->emplace_back(name);
109 BIO_new_mem_buf((
void*)certificateData.data(), certificateData.length()));
111 throw std::runtime_error(
"Cannot create mem BIO");
115 PEM_read_bio_X509(bio.get(),
nullptr,
nullptr,
nullptr));
117 throw std::runtime_error(
"Cannot read X509 from PEM bio");
bool sessionIDResumed() const
static std::unique_ptr< std::list< std::string > > getSubjectAltName(const X509 *cert)
SSLException(int sslError, unsigned long errError, int sslOperationReturnValue, int errno_copy)
static folly::ssl::X509UniquePtr getX509FromCertificate(const std::string &certificateData)
std::unique_ptr< X509, X509Deleter > X509UniquePtr
std::unique_ptr< BIO, BioDeleter > BioUniquePtr
std::string sformat(StringPiece fmt, Args &&...args)
unsigned char * ASN1_STRING_get0_data(const ASN1_STRING *x)
—— Concurrent Priority Queue Implementation ——
requires And< SemiMovable< VN >... > &&SemiMovable< E > auto error(E e)
static SSLResumeEnum getResumeState(folly::AsyncSSLSocket *sslSocket)
GuardImpl guard(ErrorHandler &&handler)
static std::unique_ptr< std::string > getCommonName(const X509 *cert)
virtual bool getSSLSessionReused() const
FOLLY_NODISCARD detail::ScopeGuardImplDecay< F, true > makeGuard(F &&f) noexcept(noexcept(detail::ScopeGuardImplDecay< F, true >(static_cast< F && >(f))))
static std::mutex sIndexLock_