Skip to content

Commit b4d9195

Browse files
emuellentottoto
andauthored
feat(tls): Add support for rustls ignore_client_order (#2042)
* Add support for rustls ignore_client_order * Add support for rustls ignore_client_order * Remove line indiciating more specific use cases for client order disabling --------- Co-authored-by: tottoto <[email protected]>
1 parent 79a06cc commit b4d9195

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

tonic/src/transport/server/service/tls.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ impl TlsAcceptor {
2222
identity: Identity,
2323
client_ca_root: Option<Certificate>,
2424
client_auth_optional: bool,
25+
ignore_client_order: bool,
2526
) -> Result<Self, crate::BoxError> {
2627
let builder = ServerConfig::builder();
2728

@@ -42,6 +43,7 @@ impl TlsAcceptor {
4243

4344
let (cert, key) = convert_identity_to_pki_types(&identity)?;
4445
let mut config = builder.with_single_cert(cert, key)?;
46+
config.ignore_client_order = ignore_client_order;
4547

4648
config.alpn_protocols.push(ALPN_H2.into());
4749
Ok(Self {

tonic/src/transport/server/tls.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pub struct ServerTlsConfig {
99
identity: Option<Identity>,
1010
client_ca_root: Option<Certificate>,
1111
client_auth_optional: bool,
12+
ignore_client_order: bool,
1213
}
1314

1415
impl fmt::Debug for ServerTlsConfig {
@@ -24,6 +25,7 @@ impl ServerTlsConfig {
2425
identity: None,
2526
client_ca_root: None,
2627
client_auth_optional: false,
28+
ignore_client_order: false,
2729
}
2830
}
2931

@@ -56,11 +58,23 @@ impl ServerTlsConfig {
5658
}
5759
}
5860

61+
/// Sets whether the server's cipher preferences are followed instead of the client's.
62+
///
63+
/// # Default
64+
/// By default, this option is set to `false`.
65+
pub fn ignore_client_order(self, ignore_client_order: bool) -> Self {
66+
ServerTlsConfig {
67+
ignore_client_order,
68+
..self
69+
}
70+
}
71+
5972
pub(crate) fn tls_acceptor(&self) -> Result<TlsAcceptor, crate::BoxError> {
6073
TlsAcceptor::new(
6174
self.identity.clone().unwrap(),
6275
self.client_ca_root.clone(),
6376
self.client_auth_optional,
77+
self.ignore_client_order,
6478
)
6579
}
6680
}

0 commit comments

Comments
 (0)