curl-fuzzer C++ reference
Loading...
Searching...
No Matches
tls_websocket_mock_server.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) Max Dymond, <cmeister2@gmail.com>, et al.
3 *
4 * SPDX-License-Identifier: curl
5 */
6
9
11
12namespace proto_fuzzer {
13
16TlsWebSocketMockServer::TlsWebSocketMockServer(curl::fuzzer::proto::TlsCertificateChainProfile certificate_chain)
17 : transport_(TlsApplicationProtocol::kHttp11, certificate_chain) {}
18
19TlsWebSocketMockServer::~TlsWebSocketMockServer() {
20 // The connection borrows transport_'s server context. Release it before the
21 // derived member is destroyed rather than relying on OpenSSL ref-counting.
22 connection_.reset();
23}
24
30 transport_.Install(easy);
31}
32
35std::unique_ptr<MockConnection> TlsWebSocketMockServer::CreateConnection() { return transport_.CreateConnection(); }
36
41 return connection_ == nullptr ? 0 : connection_->DrainIncoming();
42}
43
47 if (connection_ != nullptr) {
48 (void)connection_->DrainIncoming();
49 }
50}
51
53std::size_t TlsWebSocketMockServer::completed_handshake_count() const { return transport_.completed_handshake_count(); }
54
57#if defined(PROTO_FUZZER_OBSERVE_STATE)
59 const volatile std::size_t tls_websocket_observation = completed_handshake_count();
60 (void)tls_websocket_observation;
61#endif
62}
63
64} // namespace proto_fuzzer
std::unique_ptr< MockConnection > connection_
The per-scenario MockConnection, lazily created by HandleOpenSocket().
void ObserveState() override
Retain protocol outcomes in coverage and introspector builds.
TlsWebSocketMockServer(curl::fuzzer::proto::TlsCertificateChainProfile certificate_chain=curl::fuzzer::proto::TLS_CERTIFICATE_CHAIN_DEFAULT_EC)
Construct a secure WebSocket peer with the selected certificate chain.
std::size_t DrainHandshakeData() override
Advance TLS and expose only decrypted application bytes to the inherited WebSocket observer.
std::unique_ptr< MockConnection > CreateConnection() override
Create one TLS-wrapped socketpair for the WebSocket exchange.
void FlushTransport() override
Turn queued application plaintext into TLS records before curl's next receive call,...
void Install(CURL *easy) override
Install the common WebSocket callbacks, then require verification against the checked-in TLS test cer...
void Install(CURL *easy) override
Install the shared socket trampolines via the base, then layer a WebSocket-aware WRITEFUNCTION / HEAD...
void ObserveState() override
Retain protocol outcomes in coverage and introspector builds.
TlsApplicationProtocol
Application protocol selected by the in-process TLS peer.
@ kHttp11
Ordinary HTTPS scripts contain HTTP/1.1 response bytes.
Secure WebSocket peer carried by the in-process TLS transport.