nghttpx: Refactor handling of negotiated ALPN
This commit is contained in:
parent
2a59c832c1
commit
ffddefc177
|
@ -1425,9 +1425,18 @@ int Http2Session::connection_made() {
|
||||||
if (ssl_ctx_) {
|
if (ssl_ctx_) {
|
||||||
const unsigned char *next_proto = nullptr;
|
const unsigned char *next_proto = nullptr;
|
||||||
unsigned int next_proto_len = 0;
|
unsigned int next_proto_len = 0;
|
||||||
|
|
||||||
SSL_get0_next_proto_negotiated(conn_.tls.ssl, &next_proto, &next_proto_len);
|
SSL_get0_next_proto_negotiated(conn_.tls.ssl, &next_proto, &next_proto_len);
|
||||||
for (int i = 0; i < 2; ++i) {
|
#if OPENSSL_VERSION_NUMBER >= 0x10002000L
|
||||||
if (next_proto) {
|
if (!next_proto) {
|
||||||
|
SSL_get0_alpn_selected(conn_.tls.ssl, &next_proto, &next_proto_len);
|
||||||
|
}
|
||||||
|
#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L
|
||||||
|
|
||||||
|
if (!next_proto) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
auto proto = StringRef{next_proto, next_proto_len};
|
auto proto = StringRef{next_proto, next_proto_len};
|
||||||
if (LOG_ENABLED(INFO)) {
|
if (LOG_ENABLED(INFO)) {
|
||||||
SSLOG(INFO, this) << "Negotiated next protocol: " << proto;
|
SSLOG(INFO, this) << "Negotiated next protocol: " << proto;
|
||||||
|
@ -1435,17 +1444,6 @@ int Http2Session::connection_made() {
|
||||||
if (!util::check_h2_is_selected(proto)) {
|
if (!util::check_h2_is_selected(proto)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
#if OPENSSL_VERSION_NUMBER >= 0x10002000L
|
|
||||||
SSL_get0_alpn_selected(conn_.tls.ssl, &next_proto, &next_proto_len);
|
|
||||||
#else // OPENSSL_VERSION_NUMBER < 0x10002000L
|
|
||||||
break;
|
|
||||||
#endif // OPENSSL_VERSION_NUMBER < 0x10002000L
|
|
||||||
}
|
|
||||||
if (!next_proto) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto &http2conf = get_config()->http2;
|
auto &http2conf = get_config()->http2;
|
||||||
|
|
Loading…
Reference in New Issue