Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TLS NPN support #1524

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions source/common/ssl/context_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ int ServerContextImpl::alpnSelectCallback(const unsigned char** out, unsigned ch
}
}

int ServerContextImpl::npnListCallback(const uint8_t** out, unsigned int* outlen) {
if (parsed_alpn_protocols_.empty()) {
return SSL_TLSEXT_ERR_NOACK;
} else {
*out = &parsed_alpn_protocols_[0];
*outlen = parsed_alpn_protocols_.size();
return SSL_TLSEXT_ERR_OK;
}
}

std::vector<uint8_t> ContextImpl::parseAlpnProtocols(const std::string& alpn_protocols) {
if (alpn_protocols.empty()) {
return {};
Expand Down Expand Up @@ -369,6 +379,12 @@ ServerContextImpl::ServerContextImpl(ContextManagerImpl& parent, Stats::Scope& s
out, outlen, in, inlen);
},
this);
SSL_CTX_set_next_protos_advertised_cb(
ctx_.get(),
[](SSL*, const uint8_t** out, unsigned int* outlen, void* arg) -> int {
return static_cast<ServerContextImpl*>(arg)->npnListCallback(out, outlen);
},
this);
}
}

Expand Down
2 changes: 2 additions & 0 deletions source/common/ssl/context_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ class ServerContextImpl : public ContextImpl, public ServerContext {
int alpnSelectCallback(const unsigned char** out, unsigned char* outlen, const unsigned char* in,
unsigned int inlen);

int npnListCallback(const uint8_t** out, unsigned int* outlen);

Runtime::Loader& runtime_;
std::vector<uint8_t> parsed_alt_alpn_protocols_;
};
Expand Down