Skip to content

Commit d830de1

Browse files
committed
readd client credentials support
1 parent 695331b commit d830de1

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/client.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,12 @@ pub struct TlsConfig<'a, const RX_SIZE: usize = 4096, const TX_SIZE: usize = 409
4343
/// Minimum TLS version for the connection
4444
version: crate::TlsVersion,
4545

46-
/// Client certificates. See [mbedtls_rs::Certificates]
46+
/// Root certificates to trust. See [mbedtls_rs::Certificates]
4747
certificates: crate::Certificate<'a>,
4848

49+
/// Client certificate and private key for mutual TLS. See [mbedtls_rs::Certificates]
50+
client_credentials: Option<crate::Credentials<'a>>,
51+
4952
/// A reference to instance of the MbedTLS library.
5053
tls_reference: mbedtls_rs::TlsReference<'a>,
5154
}
@@ -122,11 +125,13 @@ impl<'a, const RX_SIZE: usize, const TX_SIZE: usize> TlsConfig<'a, RX_SIZE, TX_S
122125
pub fn new(
123126
version: crate::TlsVersion,
124127
certificates: crate::Certificate<'a>,
128+
client_credentials: Option<crate::Credentials<'a>>,
125129
tls_reference: crate::TlsReference<'a>,
126130
) -> Self {
127131
Self {
128132
version,
129133
certificates,
134+
client_credentials,
130135
tls_reference,
131136
}
132137
}
@@ -186,7 +191,7 @@ where
186191
conn,
187192
&mbedtls_rs::SessionConfig::Client(mbedtls_rs::ClientSessionConfig {
188193
ca_chain: Some(tls.certificates.clone()),
189-
creds: None,
194+
creds: tls.client_credentials.clone(),
190195
server_name: None, // don't set it here because it would reference a local variable
191196
auth_mode: mbedtls_rs::AuthMode::Required,
192197
min_version: tls.version,

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl From<embedded_tls::TlsError> for Error {
8484

8585
/// Re-export those members since they're used for [client::TlsConfig].
8686
#[cfg(feature = "mbedtls-rs")]
87-
pub use mbedtls_rs::{Certificate, TlsReference, TlsVersion, X509};
87+
pub use mbedtls_rs::{Certificate, Credentials, TlsReference, TlsVersion, X509};
8888

8989
#[cfg(feature = "mbedtls-rs")]
9090
impl From<mbedtls_rs::SessionError> for Error {

0 commit comments

Comments
 (0)