improve HTTP/2 + TLS support#1229
Open
SSE4 wants to merge 3 commits intouserver-framework:developfrom
Open
Conversation
55b0272 to
63eefe9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've got userver working with plain HTTP/2 and HTTP/1.1 + TLS on their own, however, HTTP/2 + TLS didn't work quite well for me, I've used the following config:
that I get with curl - it doesn't use HTTP/2, only fallbacks to HTTP/1.1:
curl log
okay, this seems to be due to the fact userver never specifies ALPN, so I've added one via SSL_CTX_set_alpn_select_cb in 2d29453 (this is more or less same as nginx and envoy are doing)
it started to progress a little bit, curl now switches to HTTP/2, but results in an error in the middle:
curl log
there is also error message in userver log in that case:
userver log
okay, I've figured out it's due to the TODO in the existing code:
userver/core/src/server/http/http2_session.cpp
Line 242 in dd333c3
it only tries to work with
io::Socket, but in case of TLS, implementation is actuallyTlsWrapper, so I've changedHttp2Streamto use genericio::RwBaseinterface instead in 979c8daa small caveat was with
Http2SessionusingSendAllmethod acceptingstd::initializer_list, which doesn't match genericWriteAllsignature, so I've concluded, as userver already switched to C++20, it would be better to usestd::spanin the interface, this way it will compile and still may use iovec implementation for real socket saving system calls, this was done in f4451e5.finally, I've got working HTTP/2 over TLS via curl:
curl log
and it also worked in web-browser (Chromium).