Merge branch 'direct-connect-alpn_static'
This commit is contained in:
commit
2a57dc859d
|
@ -1,4 +1,5 @@
|
||||||
language: cpp
|
language: cpp
|
||||||
|
dist: xenial
|
||||||
compiler:
|
compiler:
|
||||||
- gcc
|
- gcc
|
||||||
- clang
|
- clang
|
||||||
|
|
|
@ -153,6 +153,32 @@ static const SSL_METHOD* get_ssl_method(const char* tls_version)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of supported protocols for ALPN.
|
||||||
|
* We only support "adc" protocol.
|
||||||
|
*/
|
||||||
|
unsigned char alpn_protocols[] = {
|
||||||
|
3, 'a', 'd', 'c',
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback for the server to select a protocol from the list
|
||||||
|
* sent by the client via ALPN.
|
||||||
|
*/
|
||||||
|
static int alpn_server_select_protocol(SSL *ssl, const unsigned char **out, unsigned char *outlen,
|
||||||
|
const unsigned char *in, unsigned int inlen, void *arg)
|
||||||
|
{
|
||||||
|
int res = SSL_select_next_proto((unsigned char **)out, outlen,
|
||||||
|
alpn_protocols, sizeof(alpn_protocols), in, inlen);
|
||||||
|
if (res == OPENSSL_NPN_NO_OVERLAP)
|
||||||
|
{
|
||||||
|
// set default protocol
|
||||||
|
*out = alpn_protocols;
|
||||||
|
*outlen = 1+alpn_protocols[0];
|
||||||
|
}
|
||||||
|
return SSL_TLSEXT_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new SSL context.
|
* Create a new SSL context.
|
||||||
*/
|
*/
|
||||||
|
@ -195,6 +221,8 @@ struct ssl_context_handle* net_ssl_context_create(const char* tls_version, const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SSL_CTX_set_alpn_select_cb(ctx->ssl, alpn_server_select_protocol, NULL);
|
||||||
|
|
||||||
return (struct ssl_context_handle*) ctx;
|
return (struct ssl_context_handle*) ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue