Skip to content

Commit

Permalink
chore: update to newer mbedtls crate version
Browse files Browse the repository at this point in the history
  • Loading branch information
mcr committed Aug 10, 2023
1 parent 4d70369 commit f2d47b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/mbedtls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ edition = "2021"


[dependencies]
mbedtls = { version = "0.8.1" }
mbedtls = { version = "0.11.0" }
ureq = { path = "../.." }
11 changes: 6 additions & 5 deletions examples/mbedtls/src/mbedtls_connector.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// This requires mbedtls crate 0.11.0 or newer due to
// new Context<T> parameter
use std::fmt;
use std::io;
use ureq::{Error, ReadWrite, TlsConnector};
Expand All @@ -14,7 +16,7 @@ fn entropy_new() -> mbedtls::rng::OsEntropy {
}

pub struct MbedTlsConnector {
context: Arc<Mutex<Context>>,
context: Arc<Mutex<Context<Box<dyn ReadWrite>>>>,
}

#[derive(Debug)]
Expand Down Expand Up @@ -59,9 +61,8 @@ impl TlsConnector for MbedTlsConnector {
io: Box<dyn ReadWrite>,
) -> Result<Box<dyn ReadWrite>, Error> {
let mut ctx = self.context.lock().unwrap();
let sync = SyncIo(Mutex::new(io));
match ctx.establish(sync, None) {
Err(_) => {
match ctx.establish(io, None) {
Err(e) => {
let io_err = io::Error::new(io::ErrorKind::InvalidData, MbedTlsError);
return Err(io_err.into());
}
Expand Down Expand Up @@ -92,7 +93,7 @@ impl io::Write for SyncIo {
}

struct MbedTlsStream {
context: Arc<Mutex<Context>>, //tcp_stream: TcpStream,
context: Arc<Mutex<Context<Box<dyn ReadWrite>>>>, //tcp_stream: TcpStream,
}

impl fmt::Debug for MbedTlsStream {
Expand Down

0 comments on commit f2d47b8

Please sign in to comment.