Skip to content

Commit 0df2e0a

Browse files
excelle08facebook-github-bot
authored andcommitted
Force AES-GCM on mock_services TLS client for hardware crypto
Differential Revision: D112460168
1 parent 63e3781 commit 0df2e0a

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

packages/feedsim/third_party/src/workloads/ranking/MockServicesClient.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include <folly/io/async/AsyncSocket.h>
2929
#include <folly/io/async/SSLContext.h>
3030

31+
#include <openssl/ssl.h>
32+
3133
#include <thrift/lib/cpp2/async/RocketClientChannel.h>
3234
#include <thrift/lib/thrift/gen-cpp2/RpcMetadata_types.h>
3335

@@ -191,6 +193,17 @@ MockServicesClient::MockServicesClient(
191193
// pinned fbthrift v2026.01.05.00). Without ALPN, the server may
192194
// reject the connection or fall back to the header-upgrade path.
193195
ssl_ctx->setAdvertisedNextProtocols({"rs"});
196+
// Restrict the offered ciphers to AES-GCM so the connection negotiates
197+
// hardware AES (ARMv8 crypto extensions via libcrypto), matching prod's
198+
// cipher. Without this, OpenSSL may pick ChaCha20-Poly1305 (a NEON/integer
199+
// cipher with no AES instructions), which reads as ~0% in the crypto
200+
// instruction mix vs prod's ~0.88% and runs the AEAD un-accelerated.
201+
SSL_CTX_set_ciphersuites(
202+
ssl_ctx->getSSLCtx(),
203+
"TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256"); // TLS 1.3
204+
ssl_ctx->setCiphersOrThrow(
205+
"ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:"
206+
"ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256"); // TLS 1.2
194207
folly::AsyncSSLSocket::UniquePtr ssl_sock(
195208
new folly::AsyncSSLSocket(ssl_ctx, evb_));
196209
// AsyncSSLSocket buffers writes until the TLS handshake completes,

0 commit comments

Comments
 (0)