diff --git a/tool/server.cc b/tool/server.cc index b6ed284a..0061cb34 100644 --- a/tool/server.cc +++ b/tool/server.cc @@ -79,6 +79,10 @@ static const struct argument kArguments[] = { "-debug", kBooleanArgument, "Print debug information about the handshake", }, + { + "-require-any-client-cert", kBooleanArgument, + "The server will require a client certificate.", + }, { "", kOptionalArgument, "", }, @@ -320,6 +324,14 @@ bool Server(const std::vector &args) { SSL_CTX_set_info_callback(ctx.get(), InfoCallback); } + if (args_map.count("-require-any-client-cert") != 0) { + SSL_CTX_set_verify( + ctx.get(), SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, nullptr); + SSL_CTX_set_cert_verify_callback( + ctx.get(), [](X509_STORE_CTX *store, void *arg) -> int { return 1; }, + nullptr); + } + Listener listener; if (!listener.Init(args_map["-accept"])) { return false;