diff --git a/deps/tquic b/deps/tquic index cc948f5..1d631c8 160000 --- a/deps/tquic +++ b/deps/tquic @@ -1 +1 @@ -Subproject commit cc948f529291fcbb0d5ab52b45be712d78da265b +Subproject commit 1d631c88289587ea6b95f82a3dd6a3ac0591f4cc diff --git a/simple_client.c b/simple_client.c index 2541523..0570283 100644 --- a/simple_client.c +++ b/simple_client.c @@ -40,6 +40,7 @@ struct simple_client { struct sockaddr_storage local_addr; socklen_t local_addr_len; SSL_CTX *ssl_ctx; + struct quic_tls_config_t *tls_config; struct quic_conn_t *conn; struct ev_loop *loop; }; @@ -146,6 +147,7 @@ int client_load_ssl_ctx(struct simple_client *client) { fprintf(stderr, "set alpn failed\n"); return -1; } + client->tls_config = quic_tls_config_new_with_ssl_ctx(client->ssl_ctx); return 0; } @@ -295,7 +297,7 @@ int main(int argc, char *argv[]) { ret = -1; goto EXIT; } - quic_config_set_tls_config(config, client.ssl_ctx); + quic_config_set_tls_config(config, client.tls_config); // Create quic endpoint client.quic_endpoint = @@ -340,6 +342,9 @@ int main(int argc, char *argv[]) { if (client.ssl_ctx != NULL) { SSL_CTX_free(client.ssl_ctx); } + if (client.tls_config != NULL) { + quic_tls_config_free(client.tls_config); + } if (client.sock > 0) { close(client.sock); } diff --git a/simple_server.c b/simple_server.c index ce8a0e3..94cf3a1 100644 --- a/simple_server.c +++ b/simple_server.c @@ -42,6 +42,7 @@ struct simple_server { struct sockaddr_storage local_addr; socklen_t local_addr_len; SSL_CTX *ssl_ctx; + struct quic_tls_config_t *tls_config; struct ev_loop *loop; }; @@ -121,15 +122,16 @@ int server_on_packets_send(void *psctx, struct quic_packet_out_spec_t *pkts, return sent_count; } -SSL_CTX *server_get_default_tls_config(void *ctx) { +struct quic_tls_config_t *server_get_default_tls_config(void *ctx) { struct simple_server *server = ctx; - return server->ssl_ctx; + return server->tls_config; } -SSL_CTX *server_select_tls_config(void *ctx, const uint8_t *server_name, - size_t server_name_len) { +struct quic_tls_config_t *server_select_tls_config(void *ctx, + const uint8_t *server_name, + size_t server_name_len) { struct simple_server *server = ctx; - return server->ssl_ctx; + return server->tls_config; } static char s_alpn[0x100]; @@ -179,6 +181,7 @@ int server_load_ssl_ctx(struct simple_server *server) { return -1; } SSL_CTX_set_alpn_select_cb(server->ssl_ctx, select_alpn, NULL); + server->tls_config = quic_tls_config_new_with_ssl_ctx(server->ssl_ctx); return 0; } @@ -370,6 +373,9 @@ int main(int argc, char *argv[]) { if (server.ssl_ctx != NULL) { SSL_CTX_free(server.ssl_ctx); } + if (server.tls_config != NULL) { + quic_tls_config_free(server.tls_config); + } if (server.sock > 0) { close(server.sock); }