Skip to content

Commit 7f1d694

Browse files
bors[bot]weibin159Taowyoo
authored
Merge #218
218: Fix wrong cert used in examples/client.rs r=Taowyoo a=weibin159 I got this error when trying to run the `examples/client.rs` ``` thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: X509CertVerifyFailed', mbedtls/examples/client.rs:54:6 stack backtrace: 0: rust_begin_unwind at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panicking.rs:575:5 1: core::panicking::panic_fmt at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/panicking.rs:64:14 2: core::result::unwrap_failed at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/result.rs:1791:5 3: core::result::Result<T,E>::unwrap at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/result.rs:1113:23 4: client::main at ./mbedtls/examples/client.rs:49:5 5: core::ops::function::FnOnce::call_once at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/ops/function.rs:507:5 note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. ``` I found that it's because of using the wrong cert in `examples/client.rs` Fix with: ```diff - let cert = Arc::new(Certificate::from_pem_multiple(keys::PEM_CERT.as_bytes())?); + let cert = Arc::new(Certificate::from_pem_multiple(keys::ROOT_CA_CERT.as_bytes())?); ``` Same as #123 Co-authored-by: Weibin <[email protected]> Co-authored-by: YX Cao <[email protected]>
2 parents 2879a2a + 0929b81 commit 7f1d694

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mbedtls/examples/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use support::keys;
2727
fn result_main(addr: &str) -> TlsResult<()> {
2828
let entropy = Arc::new(entropy_new());
2929
let rng = Arc::new(CtrDrbg::new(entropy, None)?);
30-
let cert = Arc::new(Certificate::from_pem_multiple(keys::PEM_CERT.as_bytes())?);
30+
let cert = Arc::new(Certificate::from_pem_multiple(keys::ROOT_CA_CERT.as_bytes())?);
3131
let mut config = Config::new(Endpoint::Client, Transport::Stream, Preset::Default);
3232
config.set_rng(rng);
3333
config.set_ca_list(cert, None);

0 commit comments

Comments
 (0)