From 4d7036984fcfcda5206490ef0383e3b225cc0834 Mon Sep 17 00:00:00 2001 From: Michael Richardson Date: Thu, 10 Aug 2023 17:56:06 -0400 Subject: [PATCH 1/2] chore: point ureq path at root directory --- examples/mbedtls/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/mbedtls/Cargo.toml b/examples/mbedtls/Cargo.toml index 51abba1..5223c57 100644 --- a/examples/mbedtls/Cargo.toml +++ b/examples/mbedtls/Cargo.toml @@ -6,3 +6,4 @@ edition = "2021" [dependencies] mbedtls = { version = "0.8.1" } +ureq = { path = "../.." } \ No newline at end of file From f2d47b8b2a163541a8ee90ac63d496189df9f9a9 Mon Sep 17 00:00:00 2001 From: Michael Richardson Date: Thu, 10 Aug 2023 17:31:27 -0400 Subject: [PATCH 2/2] chore: update to newer mbedtls crate version --- examples/mbedtls/Cargo.toml | 2 +- examples/mbedtls/src/mbedtls_connector.rs | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/mbedtls/Cargo.toml b/examples/mbedtls/Cargo.toml index 5223c57..5db13d5 100644 --- a/examples/mbedtls/Cargo.toml +++ b/examples/mbedtls/Cargo.toml @@ -5,5 +5,5 @@ edition = "2021" [dependencies] -mbedtls = { version = "0.8.1" } +mbedtls = { version = "0.11.0" } ureq = { path = "../.." } \ No newline at end of file diff --git a/examples/mbedtls/src/mbedtls_connector.rs b/examples/mbedtls/src/mbedtls_connector.rs index 856db7a..bf62a8a 100644 --- a/examples/mbedtls/src/mbedtls_connector.rs +++ b/examples/mbedtls/src/mbedtls_connector.rs @@ -1,3 +1,5 @@ +// This requires mbedtls crate 0.11.0 or newer due to +// new Context parameter use std::fmt; use std::io; use ureq::{Error, ReadWrite, TlsConnector}; @@ -14,7 +16,7 @@ fn entropy_new() -> mbedtls::rng::OsEntropy { } pub struct MbedTlsConnector { - context: Arc>, + context: Arc>>>, } #[derive(Debug)] @@ -59,9 +61,8 @@ impl TlsConnector for MbedTlsConnector { io: Box, ) -> Result, 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()); } @@ -92,7 +93,7 @@ impl io::Write for SyncIo { } struct MbedTlsStream { - context: Arc>, //tcp_stream: TcpStream, + context: Arc>>>, //tcp_stream: TcpStream, } impl fmt::Debug for MbedTlsStream {