16#include "proto_fuzzer/tls_test_credentials.h"
18namespace proto_fuzzer {
28 mode_(protocol == curl::fuzzer::proto::PROXY_PROTOCOL_HTTP1 ?
H2ProxyMode::
kTunnel : mode),
29 protocol_(protocol) {}
44 static constexpr char kProxyUrl[] =
"https://127.0.0.1:443";
45 struct curl_blob trust_anchor = {
const_cast<char*
>(tls_test_credentials::kCertificatePem),
46 sizeof(tls_test_credentials::kCertificatePem) - 1, CURL_BLOB_NOCOPY};
52 (void)curl_easy_setopt(easy, CURLOPT_CONNECT_TO,
nullptr);
53 (void)curl_easy_setopt(easy, CURLOPT_PROXY, kProxyUrl);
54 const long proxy_type = protocol_ == curl::fuzzer::proto::PROXY_PROTOCOL_HTTP1 ?
static_cast<long>(CURLPROXY_HTTPS)
55 :
static_cast<long>(CURLPROXY_HTTPS2);
56 (void)curl_easy_setopt(easy, CURLOPT_PROXYTYPE, proxy_type);
57 (void)curl_easy_setopt(easy, CURLOPT_NOPROXY,
"");
59 (void)curl_easy_setopt(easy, CURLOPT_PROXY_CAINFO_BLOB, &trust_anchor);
60 (void)curl_easy_setopt(easy, CURLOPT_PROXY_SSL_VERIFYPEER, 1L);
61 (void)curl_easy_setopt(easy, CURLOPT_PROXY_SSL_VERIFYHOST, 0L);
76void H2ProxyMockServer::ObserveIncomingData(
const unsigned char* data, std::size_t size) {
80 const std::size_t remaining = scenario_limits::kMaxHttp2ObservedBytes - client_transcript_.size();
81 client_transcript_.append(
reinterpret_cast<const char*
>(data), std::min(size, remaining));
H2ProxyMockServer(H2ProxyMode mode=H2ProxyMode::kTunnel, curl::fuzzer::proto::ProxyProtocol protocol=curl::fuzzer::proto::PROXY_PROTOCOL_HTTP2)
Select the closed proxy protocol profile before any connection opens.
void Install(CURL *easy) override
Install the socket transport and force one verified HTTPS proxy.
const std::string & client_transcript() const
std::unique_ptr< MockConnection > CreateConnection() override
Attach a bounded observer after TLS decoding so tests can verify the real CONNECT request rather than...
virtual void Install(CURL *easy)
Install the common OPENSOCKETFUNCTION / OPENSOCKETDATA / SOCKOPTFUNCTION callbacks on 'easy'.
MockConnection * connection()
TlsMockServer()
Build one reusable in-process server context per fuzz iteration.
std::unique_ptr< MockConnection > CreateConnection() override
Wrap one socketpair server endpoint in an OpenSSL acceptor consumed by MockServer.
Deterministic HTTPS/HTTP2 proxy for structured scenarios.
H2ProxyMode
Origin-request shape carried by the fixed HTTPS/HTTP2 proxy transport.
@ kTunnel
Establish CONNECT, then carry a plaintext HTTP/1.1 origin exchange.
constexpr std::size_t kMaxHttp2ObservedBytes
Client tracking only needs frame headers and one maximum ordinary payload.
TlsApplicationProtocol
Application protocol selected by the in-process TLS peer.
@ kHttp2
The dedicated proxy peer exchanges HTTP/2 frames after its handshake.
@ kHttp11
Ordinary HTTPS scripts contain HTTP/1.1 response bytes.