Upgrade select alpn callback
nghttp2 has added a new callback[1] which solves the issue we were
seeing previously with const. This cleans up some NOLINT markers, but
should have no functional changes
[1] https://nghttp2.org/documentation/nghttp2_select_alpn.html#c.nghttp2_select_alpn
Tested:
Curl shows HTTP2 upgrade works properly.
* ALPN, offering h2
* ALPN, offering http/1.1
* ALPN, server accepted to use h2
* Using HTTP2, server supports multiplexing
* Connection state changed (HTTP/2 confirmed)
Change-Id: Ic41754c58e6166aac22ed5afca5371661db959da
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/src/ssl_key_handler.cpp b/src/ssl_key_handler.cpp
index 4423508..1d4039c 100644
--- a/src/ssl_key_handler.cpp
+++ b/src/ssl_key_handler.cpp
@@ -459,18 +459,15 @@
const unsigned char* in, unsigned int inlen,
void* /*unused*/)
{
- // There's a mismatch in constness for nghttp2_select_next_protocol. The
- // examples in nghttp2 don't show this problem. Unclear what the right fix
- // is here.
-
- // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
- unsigned char** outNew = const_cast<unsigned char**>(out);
- int rv = nghttp2_select_next_protocol(outNew, outlen, in, inlen);
- if (rv != 1)
+ int rv = nghttp2_select_alpn(out, outlen, in, inlen);
+ if (rv == -1)
{
return SSL_TLSEXT_ERR_NOACK;
}
-
+ if (rv == 1)
+ {
+ BMCWEB_LOG_DEBUG("Selected HTTP2");
+ }
return SSL_TLSEXT_ERR_OK;
}