Skip to content

Commit f2f1b6b

Browse files
authored
fix(stackable-webhook): Explicitly set the TLS provider for the ServerConfig, and enable "safe" protocols (#778)
* fix(stackable-webhook): rustls now requires a global provider to be set, or explicity pass in via the server/client config. Normally this would be set by the application, and not in a library, however this library is to remove so much boiler plate from our applications. * docs(stackable-webhook): update changelog * chore(stackable-webhook): explicitly set accepted TLS protocol versions
1 parent 16ce3fa commit f2f1b6b

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

crates/stackable-webhook/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,16 @@ All notable changes to this project will be documented in this file.
2121
- Bump GitHub workflow actions ([#772]).
2222
- Revert `zeroize` version bump ([#772]).
2323

24+
### Fixed
25+
26+
- Explicitly set the TLS provider for the ServerConfig, and enable "safe" protocols ([#778]).
27+
2428
[#758]: https://github.com/stackabletech/operator-rs/pull/758
2529
[#762]: https://github.com/stackabletech/operator-rs/pull/762
2630
[#767]: https://github.com/stackabletech/operator-rs/pull/767
2731
[#769]: https://github.com/stackabletech/operator-rs/pull/769
2832
[#772]: https://github.com/stackabletech/operator-rs/pull/772
33+
[#778]: https://github.com/stackabletech/operator-rs/pull/778
2934
[#782]: https://github.com/stackabletech/operator-rs/pull/782
3035

3136
## [0.2.0] - 2024-03-26

crates/stackable-webhook/src/tls.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ use snafu::{ResultExt, Snafu};
1010
use stackable_certs::{ca::CertificateAuthority, keys::rsa, CertificatePairError};
1111
use stackable_operator::time::Duration;
1212
use tokio::net::TcpListener;
13-
use tokio_rustls::{rustls::ServerConfig, TlsAcceptor};
13+
use tokio_rustls::{
14+
rustls::{
15+
crypto::aws_lc_rs::default_provider,
16+
version::{TLS12, TLS13},
17+
ServerConfig,
18+
},
19+
TlsAcceptor,
20+
};
1421
use tower::Service;
1522
use tracing::{instrument, trace, warn};
1623

@@ -44,6 +51,9 @@ pub enum Error {
4451
EncodePrivateKeyDer {
4552
source: CertificatePairError<rsa::Error>,
4653
},
54+
55+
#[snafu(display("failed to set safe TLS protocol versions"))]
56+
SetSafeTlsProtocolVersions { source: tokio_rustls::rustls::Error },
4757
}
4858

4959
/// Custom implementation of [`std::cmp::PartialEq`] because some inner types
@@ -97,7 +107,10 @@ impl TlsServer {
97107
.private_key_der()
98108
.context(EncodePrivateKeyDerSnafu)?;
99109

100-
let mut config = ServerConfig::builder()
110+
let tls_provider = default_provider();
111+
let mut config = ServerConfig::builder_with_provider(tls_provider.into())
112+
.with_protocol_versions(&[&TLS12, &TLS13])
113+
.context(SetSafeTlsProtocolVersionsSnafu)?
101114
.with_no_client_auth()
102115
.with_single_cert(vec![certificate_der], private_key_der)
103116
.context(InvalidTlsPrivateKeySnafu)?;

0 commit comments

Comments
 (0)