Skip to content

Instantly share code, notes, and snippets.

@Habbie
Created May 9, 2019
Embed
What would you like to do?
diff --git a/pdns/dnsdistdist/doh.cc b/pdns/dnsdistdist/doh.cc
index 9b183e5f1..1f83c17e7 100644
--- a/pdns/dnsdistdist/doh.cc
+++ b/pdns/dnsdistdist/doh.cc
@@ -577,7 +577,9 @@ static void on_accept(h2o_socket_t *listener, const char *err)
auto accept_ctx = dsc->accept_ctx->get();
sock->on_close.data = dsc->accept_ctx;
++dsc->df->d_httpconnects;
+ cerr<<"calling h2o_accept"<<endl;
h2o_accept(accept_ctx, sock);
+ cerr<<"called h2o_accept"<<endl;
}
static int create_listener(const ComboAddress& addr, std::shared_ptr<DOHServerConfig>& dsc, int fd)
@@ -589,6 +591,18 @@ static int create_listener(const ComboAddress& addr, std::shared_ptr<DOHServerCo
return 0;
}
+static int on_sni_callback(SSL *ssl, int *ad, void *arg)
+{
+ const char *server_name = SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name);
+
+ if (server_name != NULL) {
+ cerr<<"got sni="<<server_name<<endl;
+ }
+
+ return SSL_TLSEXT_ERR_OK;
+}
+
+
static std::unique_ptr<SSL_CTX, void(*)(SSL_CTX*)> getTLSContext(const std::vector<std::pair<std::string, std::string>>& pairs, const std::string& ciphers, const std::string& ciphers13)
{
auto ctx = std::unique_ptr<SSL_CTX, void(*)(SSL_CTX*)>(SSL_CTX_new(SSLv23_server_method()), SSL_CTX_free);
@@ -631,6 +645,9 @@ static std::unique_ptr<SSL_CTX, void(*)(SSL_CTX*)> getTLSContext(const std::vect
h2o_ssl_register_alpn_protocols(ctx.get(), h2o_http2_alpn_protocols);
+ SSL_CTX_set_tlsext_servername_callback(ctx.get(), on_sni_callback);
+ SSL_CTX_set_tlsext_servername_arg(ctx.get(), NULL);
+
return ctx;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment