9 #include <gtest/gtest.h> 14 using namespace folly;
24 OpenSSL_add_all_algorithms();
27 rootCertAndKey_ =
createCert(
"root",
true,
nullptr);
28 leafCertAndKey_ =
createCert(
"leaf",
false, &rootCertAndKey_);
29 ASSERT_EQ(X509_STORE_add_cert(store.get(), rootCertAndKey_.cert.get()), 1);
30 verifier_ = std::make_unique<DefaultCertificateVerifier>(
31 VerificationContext::Client,
std::move(store));
37 if (X509_STORE_CTX_get_error(ctx) ==
38 X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT) {
47 std::unique_ptr<DefaultCertificateVerifier>
verifier_;
55 auto subauth =
createCert(
"subauth",
true, &rootCertAndKey_);
56 auto subleaf =
createCert(
"subleaf",
false, &subauth);
61 auto selfsigned =
createCert(
"self",
false,
nullptr);
63 verifier_->verify({getPeerCert(selfsigned)}), std::runtime_error);
67 auto selfsigned =
createCert(
"self",
false,
nullptr);
69 &DefaultCertificateVerifierTest::allowSelfSignedLeafCertCallback);
75 auto subauth =
createCert(
"subauth",
true, &rootCertAndKey_);
76 auto subleaf =
createCert(
"subleaf",
false, &subauth);
82 TestVerifyWithIntermediateMissingWithOverride) {
83 auto subauth =
createCert(
"subauth",
true, &rootCertAndKey_);
84 auto subleaf =
createCert(
"subleaf",
false, &subauth);
86 &DefaultCertificateVerifierTest::allowSelfSignedLeafCertCallback);
92 auto subauth =
createCert(
"badsubauth",
false, &rootCertAndKey_);
93 auto subleaf =
createCert(
"badsubleaf",
false, &subauth);
98 auto newroot =
createCert(
"root2",
true,
nullptr);
99 auto subauth =
createCert(
"subauth2",
true, &newroot);
100 auto subleaf =
createCert(
"leaf2",
false, &subauth);
102 verifier_->verify({getPeerCert(subleaf), getPeerCert(subauth)}),
static int allowSelfSignedLeafCertCallback(int ok, X509_STORE_CTX *ctx)
#define EXPECT_THROW(statement, expected_exception)
#define ASSERT_EQ(val1, val2)
CertAndKey rootCertAndKey_
constexpr detail::Map< Move > move
std::unique_ptr< DefaultCertificateVerifier > verifier_
—— Concurrent Priority Queue Implementation ——
CertAndKey leafCertAndKey_
std::unique_ptr< X509_STORE, X509StoreDeleter > X509StoreUniquePtr
TEST_F(AsyncSSLSocketWriteTest, write_coalescing1)
std::shared_ptr< PeerCert > getPeerCert(const CertAndKey &cert)
CertAndKey createCert(std::string cn, bool ca, CertAndKey *issuer)
std::shared_ptr< const CertificateVerifier > verifier_
#define ASSERT_TRUE(condition)