Skip to content

Commit 658d741

Browse files
mourenZhuedsiper
authored andcommitted
tls: replace NPN with ALPN for client connections
Signed-off-by: Biao Zhu <[email protected]>
1 parent 76ab79b commit 658d741

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

src/tls/openssl.c

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -198,21 +198,6 @@ static int tls_context_server_alpn_select_callback(SSL *ssl,
198198
return result;
199199
}
200200

201-
static int tls_context_client_alpn_select_callback(SSL *ssl,
202-
unsigned char **out,
203-
unsigned char *outlen,
204-
const unsigned char *in,
205-
unsigned int inlen,
206-
void *arg)
207-
{
208-
return tls_context_server_alpn_select_callback(ssl,
209-
(const unsigned char **) out,
210-
outlen,
211-
in,
212-
inlen,
213-
arg);
214-
}
215-
216201
int tls_context_alpn_set(void *ctx_backend, const char *alpn)
217202
{
218203
size_t wire_format_alpn_index;
@@ -283,10 +268,15 @@ int tls_context_alpn_set(void *ctx_backend, const char *alpn)
283268
ctx);
284269
}
285270
else {
286-
SSL_CTX_set_next_proto_select_cb(
287-
ctx->ctx,
288-
tls_context_client_alpn_select_callback,
289-
ctx);
271+
if (ctx->alpn == NULL) {
272+
return -1;
273+
}
274+
if (SSL_CTX_set_alpn_protos(
275+
ctx->ctx,
276+
(const unsigned char *) &ctx->alpn[1],
277+
(unsigned int) ctx->alpn[0]) != 0) {
278+
return -1;
279+
}
290280
}
291281
}
292282

0 commit comments

Comments
 (0)