Skip to content

Commit

Permalink
Add ALPN and better auth to SSLContext used for raw Thrift client
Browse files Browse the repository at this point in the history
Summary:
This was found from logs like https://fburl.com/scuba/thrift_connection_events/4ki5vhy2, showing an empty "Client Alpns" list.

Rocket should be used with an "rs" ALPN value. Most of these changes come from https://www.internalfb.com/intern/wiki/Secure_Thrift/User_Guide/TLS/Special_Cases/

Reviewed By: xiangxu1121

Differential Revision: D52699658

fbshipit-source-id: 3775047f5fad390fcfa43bd68ac817dfdde9ed8c
  • Loading branch information
Sotirios Delimanolis authored and facebook-github-bot committed Jan 19, 2024
1 parent 08b27ed commit f5e4a78
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
7 changes: 3 additions & 4 deletions openr/common/OpenrClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,7 @@ getOpenrCtrlPlainTextClient(
/*
* Create secured client for OpenrCtrlCpp service over AsyncSSLSocket.
*/
template <
typename ClientType,
typename ClientChannel = apache::thrift::RocketClientChannel>
template <typename ClientType>
static std::unique_ptr<ClientType>
getOpenrCtrlSecureClient(
folly::EventBase& evb,
Expand Down Expand Up @@ -183,7 +181,8 @@ getOpenrCtrlSecureClient(
}

// Create channel and set timeout
auto channel = ClientChannel::newChannel(std::move(transport));
auto channel =
apache::thrift::RocketClientChannel::newChannel(std::move(transport));
channel->setTimeout(processingTimeout.count());

// Enable compression for efficient transport when available. This will
Expand Down
4 changes: 1 addition & 3 deletions openr/kvstore/KvStore-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1128,9 +1128,7 @@ KvStoreDb<ClientType>::KvStorePeer::getOrCreateThriftClient(
folly::ssl::SSLCommonOptions::setClientOptions(*context);
// Since we are suggesting support for rocket in ALPN,
// we should use RocketClientChannel to match what is negotiated
secureClient = getOpenrCtrlSecureClient<
ClientType,
apache::thrift::RocketClientChannel>(
secureClient = getOpenrCtrlSecureClient<ClientType>(
*(evb->getEvb()),
context,
folly::IPAddress(*peerSpec.peerAddr()), /* v6LinkLocal */
Expand Down

0 comments on commit f5e4a78

Please sign in to comment.