summaryrefslogtreecommitdiff
path: root/src/lib/libtls/tls_server.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lib/libtls/tls_server.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/lib/libtls/tls_server.c b/src/lib/libtls/tls_server.c
index bba15aae7e..690af32eaf 100644
--- a/src/lib/libtls/tls_server.c
+++ b/src/lib/libtls/tls_server.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls_server.c,v 1.21 2016/08/02 07:47:11 jsing Exp $ */ 1/* $OpenBSD: tls_server.c,v 1.22 2016/08/12 15:10:59 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -48,6 +48,20 @@ tls_server_conn(struct tls *ctx)
48 return (conn_ctx); 48 return (conn_ctx);
49} 49}
50 50
51static int
52tls_server_alpn_cb(SSL *ssl, const unsigned char **out, unsigned char *outlen,
53 const unsigned char *in, unsigned int inlen, void *arg)
54{
55 struct tls *ctx = arg;
56
57 if (SSL_select_next_proto((unsigned char**)out, outlen,
58 ctx->config->alpn, ctx->config->alpn_len, in, inlen) ==
59 OPENSSL_NPN_NEGOTIATED)
60 return (SSL_TLSEXT_ERR_OK);
61
62 return (SSL_TLSEXT_ERR_NOACK);
63}
64
51int 65int
52tls_configure_server(struct tls *ctx) 66tls_configure_server(struct tls *ctx)
53{ 67{
@@ -71,6 +85,10 @@ tls_configure_server(struct tls *ctx)
71 goto err; 85 goto err;
72 } 86 }
73 87
88 if (ctx->config->alpn != NULL)
89 SSL_CTX_set_alpn_select_cb(ctx->ssl_ctx, tls_server_alpn_cb,
90 ctx);
91
74 if (ctx->config->dheparams == -1) 92 if (ctx->config->dheparams == -1)
75 SSL_CTX_set_dh_auto(ctx->ssl_ctx, 1); 93 SSL_CTX_set_dh_auto(ctx->ssl_ctx, 1);
76 else if (ctx->config->dheparams == 1024) 94 else if (ctx->config->dheparams == 1024)