Go to the documentation of this file.
31 "The port of the server to bind on; eg 45102",
35 "An OpenSSL-style cipher suite string that configures the offered "
40 "An OpenSSL-style ECDH curves list that configures the offered curves",
44 "The maximum acceptable protocol version",
48 "The minimum acceptable protocol version",
52 "PEM-encoded file containing the private key. A self-signed "
53 "certificate is generated at runtime if this argument is not provided.",
57 "PEM-encoded file containing the leaf certificate and optional "
58 "certificate chain. This is taken from the -key argument if this "
59 "argument is not provided.",
67 "File containing the private key corresponding to the ECHConfig.",
72 "File containing one ECHConfig.",
76 "The server will continue accepting new sequential connections.",
83 "The server will print connection information in response to a "
88 "Print debug information about the handshake",
92 "The server will require a client certificate.",
96 "Enable the JDK 11 workaround",
105 std::vector<uint8_t>
data;
122 fprintf(
stderr,
"Failed to generate key pair.\n");
127 fprintf(
stderr,
"Failed to assign key pair.\n");
134 const int valid_days) {
135 bssl::UniquePtr<X509> x509(
X509_new());
144 reinterpret_cast<const uint8_t *
>(
"US"), -1, -1,
147 reinterpret_cast<const uint8_t *
>(
"BoringSSL"), -1,
152 fprintf(
stderr,
"Failed to set public key.\n");
156 fprintf(
stderr,
"Failed to sign certificate.\n");
165 fprintf(
stderr,
"Handshake started.\n");
168 fprintf(
stderr,
"Handshake done.\n");
186 fprintf(
stderr,
"Cannot create BIO for response\n");
190 BIO_puts(bio.get(),
"HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\n\r\n");
194 size_t request_len = 0;
195 while (request_len <
sizeof(
request)) {
203 request_len +=
static_cast<size_t>(ssl_ret);
207 if (memcmp(
request,
"GET ", 4) == 0) {
222 std::map<std::string, std::string> args_map;
231 const char *keylog_file =
getenv(
"SSLKEYLOGFILE");
242 if (args_map.count(
"-key") != 0) {
246 fprintf(
stderr,
"Failed to load private key: %s\n",
key.c_str());
250 args_map.count(
"-cert") != 0 ? args_map[
"-cert"] :
key;
252 fprintf(
stderr,
"Failed to load cert chain: %s\n", cert.c_str());
260 bssl::UniquePtr<X509> cert =
266 fprintf(
stderr,
"Failed to set private key.\n");
270 fprintf(
stderr,
"Failed to set certificate.\n");
275 if (args_map.count(
"-ech-key") + args_map.count(
"-ech-config") == 1) {
277 "-ech-config and -ech-key must be specified together.\n");
281 if (args_map.count(
"-ech-key") != 0) {
284 ScopedFILE ech_key_file(fopen(ech_key_path.c_str(),
"rb"));
285 std::vector<uint8_t> ech_key;
286 if (ech_key_file ==
nullptr ||
287 !
ReadAll(&ech_key, ech_key_file.get())) {
288 fprintf(
stderr,
"Error reading %s\n", ech_key_path.c_str());
293 std::string ech_config_path = args_map[
"-ech-config"];
294 ScopedFILE ech_config_file(fopen(ech_config_path.c_str(),
"rb"));
295 std::vector<uint8_t> ech_config;
296 if (ech_config_file ==
nullptr ||
297 !
ReadAll(&ech_config, ech_config_file.get())) {
298 fprintf(
stderr,
"Error reading %s\n", ech_config_path.c_str());
306 ech_key.data(), ech_key.size()) ||
308 1, ech_config.data(),
309 ech_config.size(),
key.get()) ||
311 fprintf(
stderr,
"Error setting server's ECHConfig and private key\n");
316 if (args_map.count(
"-cipher") != 0 &&
318 fprintf(
stderr,
"Failed setting cipher list\n");
322 if (args_map.count(
"-curves") != 0 &&
324 fprintf(
stderr,
"Failed setting curves list\n");
329 if (args_map.count(
"-max-version") != 0 &&
331 fprintf(
stderr,
"Unknown protocol version: '%s'\n",
332 args_map[
"-max-version"].
c_str());
340 if (args_map.count(
"-min-version") != 0) {
343 fprintf(
stderr,
"Unknown protocol version: '%s'\n",
344 args_map[
"-min-version"].
c_str());
352 if (args_map.count(
"-ocsp-response") != 0 &&
354 fprintf(
stderr,
"Failed to load OCSP response: %s\n", args_map[
"-ocsp-response"].
c_str());
358 if (args_map.count(
"-early-data") != 0) {
362 if (args_map.count(
"-debug") != 0) {
366 if (args_map.count(
"-require-any-client-cert") != 0) {
375 if (!listener.
Init(args_map[
"-accept"])) {
382 if (!listener.
Accept(&sock)) {
390 if (args_map.count(
"-jdk11-workaround") != 0) {
402 fprintf(
stderr,
"Connected.\n");
406 if (args_map.count(
"-www") != 0) {
411 }
while (args_map.count(
"-loop") != 0);
#define SSL_CB_HANDSHAKE_START
bool ParseKeyValueArguments(std::map< std::string, std::string > *out_args, const std::vector< std::string > &args, const struct argument *templates)
#define SSL_CTX_set_verify
#define EC_KEY_new_by_curve_name
#define X509_get_subject_name
#define NID_X9_62_prime256v1
#define SSL_CTX_set_strict_cipher_list
#define EC_KEY_generate_key
#define SSL_CB_HANDSHAKE_DONE
#define X509_get_notBefore
#define SSL_CTX_set_cert_verify_callback
bool VersionFromString(uint16_t *out_version, const std::string &version)
bool Accept(int *out_sock)
static struct test_ctx ctx
const OPENSSL_EXPORT EVP_MD * EVP_sha256(void)
#define SSL_CB_ACCEPT_LOOP
#define SSL_CTX_set_max_proto_version
#define SSL_CTX_set1_curves_list
#define SSL_CTX_set_ocsp_response
void PrintSSLError(FILE *file, const char *msg, int ssl_err, int ret)
def c_str(s, encoding='ascii')
#define EVP_HPKE_KEY_init
#define X509_set_issuer_name
#define X509_get_notAfter
#define SSL_CTX_set_keylog_callback
OPENSSL_EXPORT size_t const uint8_t size_t response_len
bool Init(const std::string &port)
#define SSL_CTX_set_info_callback
void PrintUsage(const struct argument *templates)
#define SSL_CTX_set_early_data_enabled
#define SSL_CTX_use_certificate_chain_file
void PrintConnectionInfo(BIO *bio, const SSL *ssl)
#define EVP_hpke_x25519_hkdf_sha256
UniquePtr< SSL_SESSION > ret
#define SSL_VERIFY_FAIL_IF_NO_PEER_CERT
#define EVP_PKEY_assign_EC_KEY
internal::StackAllocated< EVP_HPKE_KEY, void, EVP_HPKE_KEY_zero, EVP_HPKE_KEY_cleanup > ScopedEVP_HPKE_KEY
#define X509_NAME_add_entry_by_txt
#define SSL_CTX_set1_ech_keys
#define SSL_CTX_use_certificate
#define SSL_CTX_use_PrivateKey_file
#define SSL_CTX_use_PrivateKey
#define X509_get_serialNumber
#define SSL_CTX_set_min_proto_version
#define SSL_state_string_long
bool TransferData(SSL *ssl, int sock)
#define SSL_set_jdk11_workaround
grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:10