1
0
mirror of https://github.com/facebook/proxygen.git synced 2026-10-24 01:33:54 +03:00

Include cert verify logging directly in HTTPCoroConnector

Summary:
# If this diff is causing a binary size regression, use D124217395 to exclude the additional dependency.

Previously,
- the `CertVerifyLogFn` was set through [ConnectionParams](https://www.internalfb.com/code/fbsource/[46fc8abb7ed7755e15fdfe51a4be37085bbde2ce]/fbcode/proxygen/lib/http/coro/client/HTTPCoroConnector.h?lines=181) exposed to the client. The top level API [HttpService.cpp](https://www.internalfb.com/code/fbsource/[bb37dfa277d43b4f3b5957f6f8d7e5bba8379b0b]/fbcode/proxygen/facebook/lib/http/client/HttpService.cpp?lines=354-355) sets this field, because that's where this library on all internal the facebook dependencies.

This diff
- Makes use of the `CertVerificationHooks`, which has different content for
  - `coro/facebook/CertVerificationHooks.cpp` and
  - `coro/client/CertVerificationHooks.cpp`

- so `HTTPCoroConnector.cpp` can directly use facebook scuba logger for fbcode builds. This way all fbcode builds of this library will have scuba logging, not just the clients directly using `HttpService.cpp`, to prevent things like S713385 from happening.

This diff might cause some clients to have increase binary size because off added binary dependency. D124217395 allows clients to opt out from this dependency.
- This change is necessary for us to have comprehensive logging coverage.
- The usual trick of "weak symbol that is set in //common/init or pulled in through configerator" _may_ miss some things.

Reviewed By: mingtaoy

Differential Revision: D123730004

fbshipit-source-id: dc71bc8001a4c4f2480b267efda6d0b94c5f8738
This commit is contained in:
Huilin Chen
2026-10-12 10:44:48 -07:00
committed by meta-codesync[bot]
parent 31ab450ed7
commit d527d18c74
7 changed files with 10 additions and 14 deletions

View File

@@ -43,8 +43,8 @@ proxygen_add_library(proxygen_http_coro_client_tls
proxygen_add_library(proxygen_http_coro_client_http_connector
SRCS
CertVerificationHooks.cpp
HTTPCoroConnector.cpp
ValidationPolicy.cpp
DEPS
proxygen_http_codec_codec_factory
proxygen_http_codec_h3_early_data_handler

View File

@@ -6,12 +6,16 @@
* LICENSE file in the root directory of this source tree.
*/
#include "proxygen/lib/http/coro/client/ValidationPolicy.h"
#include "proxygen/lib/http/coro/client/CertVerificationHooks.h"
#include <stdexcept>
namespace proxygen::coro {
CertVerifyLogFn getCertVerifyLogFn() noexcept {
return nullptr;
}
std::optional<ValidationPolicy> getValidationPolicy(
HTTPCoroConnector::IdentityValidation identityValidation) {
switch (identityValidation) {

View File

@@ -18,4 +18,6 @@ namespace proxygen::coro {
std::optional<ValidationPolicy> getValidationPolicy(
HTTPCoroConnector::IdentityValidation identityValidation);
CertVerifyLogFn getCertVerifyLogFn() noexcept;
} // namespace proxygen::coro

View File

@@ -193,9 +193,6 @@ proxygen::coro::HTTPCoroSessionPool &HTTPClientConnectionCache::getPool(
connParams.fizzContextAndVerifier.fizzContext = std::move(newFizzCtx);
}
}
if (certVerifyLogFn_ && !connParams.certVerifyLogFn) {
connParams.certVerifyLogFn = certVerifyLogFn_;
}
auto poolParams =
poolParams_.value_or(proxygen::coro::HTTPCoroSessionPool::PoolParams{
kMaxConnections,

View File

@@ -89,10 +89,6 @@ class HTTPClientConnectionCache : public HTTPSessionFactory {
dnsResolver_ = std::move(dnsResolver);
}
void setCertVerifyLogFn(CertVerifyLogFn certVerifyLogFn) {
certVerifyLogFn_ = std::move(certVerifyLogFn);
}
folly::coro::Task<GetSessionResult> getSessionWithReservation(
std::string url,
std::chrono::milliseconds timeout,
@@ -175,7 +171,6 @@ class HTTPClientConnectionCache : public HTTPSessionFactory {
folly::Optional<HTTPCoroSessionPool::PoolParams> poolParams_;
folly::Optional<HTTPCoroConnector::ConnectionParams> connParams_;
folly::Optional<HTTPCoroConnector::SessionParams> sessionParams_;
CertVerifyLogFn certVerifyLogFn_;
std::shared_ptr<HTTPCoroSessionPool> proxyPool_;
HTTPCoroConnector::ProxyParameters::ConnectHeaderMap proxyConnectHeaders_;
folly::CancellationSource cancellationSource_;

View File

@@ -7,8 +7,8 @@
*/
#include "proxygen/lib/http/coro/client/HTTPCoroConnector.h"
#include "proxygen/lib/http/coro/client/CertVerificationHooks.h"
#include "proxygen/lib/http/coro/client/TLS.h"
#include "proxygen/lib/http/coro/client/ValidationPolicy.h"
#include <folly/logging/xlog.h>
#include <proxygen/lib/http/codec/H3EarlyDataHandler.h>
@@ -272,7 +272,7 @@ folly::coro::Task<std::unique_ptr<CoroTransportIf>> connectFizz(
makeVerifier(connParams.fizzContextAndVerifier.fizzCertVerifier,
std::move(expectedIdentity.value()),
*policy,
connParams.certVerifyLogFn);
getCertVerifyLogFn());
} else {
proxygenVerifier = connParams.fizzContextAndVerifier.fizzCertVerifier;
}

View File

@@ -186,8 +186,6 @@ class HTTPCoroConnector {
std::string plaintextProtocol;
IdentityValidation identityValidation{IdentityValidation::Logging};
CertVerifyLogFn certVerifyLogFn;
};
static const ConnectionParams& defaultConnectionParams() {