Commit 3fa19ab2 authored by Andrew Huang's avatar Andrew Huang Committed by Facebook GitHub Bot

Migrate AsyncSSLSocketTest to V2 Session API

Summary: Migrate AsyncSSLSocketTest to new AsyncSSLSocket session API

Reviewed By: mingtaoy

Differential Revision: D24240249

fbshipit-source-id: ea9bd7669f377c738e44d3348400a2cfbd3c2580
parent 08ee18c5
......@@ -3189,7 +3189,7 @@ TEST(AsyncSSLSocketTest, TestSNIClientHelloBehavior) {
clientCtx->setSessionCacheContext("test context");
clientCtx->setVerificationOption(SSLContext::SSLVerifyPeerEnum::NO_VERIFY);
SSL_SESSION* resumptionSession = nullptr;
std::shared_ptr<folly::ssl::SSLSession> resumptionSession = nullptr;
{
std::array<NetworkSocket, 2> fds;
......@@ -3217,7 +3217,7 @@ TEST(AsyncSSLSocketTest, TestSNIClientHelloBehavior) {
// create another client, resuming with the prior session, but under a
// different common name.
clientSock = std::move(client).moveSocket();
resumptionSession = clientSock->getSSLSession();
resumptionSession = clientSock->getSSLSessionV2();
}
{
......@@ -3229,7 +3229,7 @@ TEST(AsyncSSLSocketTest, TestSNIClientHelloBehavior) {
AsyncSSLSocket::UniquePtr serverSock(
new AsyncSSLSocket(serverCtx, &eventBase, fds[1], true));
clientSock->setSSLSession(resumptionSession, true);
clientSock->setSSLSessionV2(resumptionSession);
clientSock->setServerName("Baz");
SSLHandshakeServerParseClientHello server(
std::move(serverSock), true, true);
......
......@@ -1142,7 +1142,7 @@ class SSLClient : public AsyncSocket::ConnectCallback,
private:
EventBase* eventBase_;
std::shared_ptr<AsyncSSLSocket> sslSocket_;
SSL_SESSION* session_;
std::shared_ptr<folly::ssl::SSLSession> session_;
std::shared_ptr<folly::SSLContext> ctx_;
uint32_t requests_;
folly::SocketAddress address_;
......@@ -1186,9 +1186,6 @@ class SSLClient : public AsyncSocket::ConnectCallback,
}
~SSLClient() override {
if (session_) {
SSL_SESSION_free(session_);
}
if (errors_ == 0) {
EXPECT_EQ(bytesRead_, sizeof(buf_));
}
......@@ -1213,7 +1210,7 @@ class SSLClient : public AsyncSocket::ConnectCallback,
void connect(bool writeNow = false) {
sslSocket_ = AsyncSSLSocket::newSocket(ctx_, eventBase_);
if (session_ != nullptr) {
sslSocket_->setSSLSession(session_);
sslSocket_->setSSLSessionV2(session_);
}
requests_--;
sslSocket_->connect(this, address_, timeout_);
......@@ -1229,10 +1226,7 @@ class SSLClient : public AsyncSocket::ConnectCallback,
hit_++;
} else {
miss_++;
if (session_ != nullptr) {
SSL_SESSION_free(session_);
}
session_ = sslSocket_->getSSLSession();
session_ = sslSocket_->getSSLSessionV2();
}
// write()
......
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