Commit ad46f381 authored by Mingtao Yang's avatar Mingtao Yang Committed by Facebook GitHub Bot

Fix SSLCertificateIdentityVerifierTest for OpenSSL 1.1.1h

Summary:
This test was written in a way that relied on an internal OpenSSL implementation
detail -- that OpenSSL would invoke the `handshakeVer` callback on the
root certificate.

OpenSSL commit https://github.com/openssl/openssl/commit/e2590c3a162eb118c36b09c2168164283aa099b4, which
is part of OpenSSL 1.1.1h, alters the control flow of the X509_verify routine
such that the handshakeVer callback is no longer called on self-signed
certificates in the trust store (aka CA certificates).

The purpose of this test was to ensure that a forced failed verification on the
end entity certificate would elicit a particular behavior. This diff adjusts
the implementation to match the original intention and removes the reliance
on implementation detail specifics.

Differential Revision: D24183002

fbshipit-source-id: abc8337f76d3529966d276cae2337ad136456199
parent c03ff623
...@@ -1449,15 +1449,22 @@ TEST( ...@@ -1449,15 +1449,22 @@ TEST(
serverSock->sslAccept(nullptr, std::chrono::milliseconds::zero()); serverSock->sslAccept(nullptr, std::chrono::milliseconds::zero());
StrictMock<MockHandshakeCB> clientHandshakeCB; StrictMock<MockHandshakeCB> clientHandshakeCB;
// Force the end entity certificate, which normally is successfully verified,
// to be considered as unsuccessful
EXPECT_CALL(clientHandshakeCB, handshakeVerImpl(clientSock.get(), true, _)) EXPECT_CALL(clientHandshakeCB, handshakeVerImpl(clientSock.get(), true, _))
// CA root certificate succeeds .Times(AtLeast(1))
.WillOnce(Return(true)) .WillRepeatedly(Invoke([&](auto&&, bool preverifyOk, auto&& ctx) {
// leaf fails auto currentDepth = X509_STORE_CTX_get_error_depth(ctx);
.WillOnce(Return(false)); if (currentDepth == 0) {
EXPECT_TRUE(preverifyOk);
return false;
}
return preverifyOk;
}));
// failure callback to verify handshake failed // failure callback to verify handshake failed
EXPECT_CALL(clientHandshakeCB, handshakeErrImpl(clientSock.get(), _)) EXPECT_CALL(clientHandshakeCB, handshakeErrImpl(clientSock.get(), _));
.WillOnce(Return());
clientSock->sslConn(&clientHandshakeCB); clientSock->sslConn(&clientHandshakeCB);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment