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 server support #2614

Merged
merged 12 commits into from
Feb 22, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add HTTP/2 support
Geal committed Feb 15, 2023
commit c13f822edc31b73b35b7c9246efa3bb8f7fac465
5 changes: 5 additions & 0 deletions apollo-router/src/axum_factory/listeners.rs
Original file line number Diff line number Diff line change
@@ -277,9 +277,14 @@ pub(super) fn serve_router_on_listen_addr(
.expect(
"this should not fail unless the socket is invalid",
);

let protocol = stream.get_ref().1.alpn_protocol();
let http2 = protocol == Some(&b"h2"[..]);

let connection = Http::new()
.http1_keep_alive(true)
.http1_header_read_timeout(Duration::from_secs(10))
.http2_only(http2)
.serve_connection(stream, app);

tokio::pin!(connection);
16 changes: 9 additions & 7 deletions apollo-router/src/configuration/mod.rs
Original file line number Diff line number Diff line change
@@ -661,13 +661,15 @@ impl TlsSupergraph {
pub(crate) fn tls_config(&self) -> Result<Arc<rustls::ServerConfig>, ApolloRouterError> {
let mut certificates = vec![self.certificate.clone()];
certificates.extend(self.certificate_chain.iter().cloned());
Ok(Arc::new(
ServerConfig::builder()
.with_safe_defaults()
.with_no_client_auth()
.with_single_cert(certificates, self.key.clone())
.map_err(ApolloRouterError::Rustls)?,
))

let mut config = ServerConfig::builder()
.with_safe_defaults()
.with_no_client_auth()
.with_single_cert(certificates, self.key.clone())
.map_err(ApolloRouterError::Rustls)?;
config.alpn_protocols = vec![b"h2".to_vec(), b"http/1.1".to_vec()];

Ok(Arc::new(config))
}
}