diff --git a/Cargo.toml b/Cargo.toml index 2fb3a748..caffc6c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -135,7 +135,7 @@ darling = { version = "0.23" } regex = { version = "1" } embedded-io-async = { version = "0.7", features = ["alloc"] } embedded-io = { version = "0.7", features = ["alloc"] } -embedded-tls = { version = "0.17", default-features = false, features = [ +embedded-tls = { version = "0.18", default-features = false, features = [ "alloc", ] } diff --git a/drivers/shared/Cargo.toml b/drivers/shared/Cargo.toml index fa80717e..7fa91533 100644 --- a/drivers/shared/Cargo.toml +++ b/drivers/shared/Cargo.toml @@ -12,9 +12,9 @@ network = { workspace = true } task = { workspace = true } synchronization = { workspace = true } embassy-futures = { workspace = true } -embedded-io-async = "0.6.1" +embedded-io-async = { workspace = true } embedded-tls = { workspace = true } -embedded-io = "0.6.1" +embedded-io = { workspace = true } rand_core = "0.6" getrandom = { version = "0.4.2" } diff --git a/drivers/shared/src/devices/https_client.rs b/drivers/shared/src/devices/https_client.rs index 20e8b9da..1df3f8da 100644 --- a/drivers/shared/src/devices/https_client.rs +++ b/drivers/shared/src/devices/https_client.rs @@ -2,9 +2,9 @@ use alloc::boxed::Box; use alloc::vec::Vec; use core::time::Duration; use embassy_futures::select::{Either, select}; -use embedded_io as embedded_io_v06; -use embedded_io_async as embedded_io_async_v06; -use embedded_tls::{Aes128GcmSha256, NoVerify, TlsConfig, TlsConnection, TlsContext}; +use embedded_io; +use embedded_io_async; +use embedded_tls::{Aes128GcmSha256, TlsConfig, TlsConnection, TlsContext, UnsecureProvider}; use file_system::{BaseOperations, CharacterDevice, Context, Error, MountOperations, Result, Size}; use network::{DnsQueryKind, Duration as NetworkDuration, Port, TcpSocket}; use rand_core::{CryptoRng, RngCore}; @@ -53,27 +53,37 @@ enum IoError { FileSystem(Error), } -impl embedded_io_v06::Error for IoError { - fn kind(&self) -> embedded_io_v06::ErrorKind { +impl embedded_io::Error for IoError { + fn kind(&self) -> embedded_io::ErrorKind { match self { - IoError::FileSystem(Error::NotFound) => embedded_io_v06::ErrorKind::NotFound, + IoError::FileSystem(Error::NotFound) => embedded_io::ErrorKind::NotFound, IoError::FileSystem(Error::PermissionDenied) => { - embedded_io_v06::ErrorKind::PermissionDenied + embedded_io::ErrorKind::PermissionDenied } - _ => embedded_io_v06::ErrorKind::Other, + _ => embedded_io::ErrorKind::Other, } } } +impl core::fmt::Display for IoError { + fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + IoError::FileSystem(error) => write!(formatter, "filesystem error: {:?}", error), + } + } +} + +impl core::error::Error for IoError {} + struct TcpSocketAdapter { socket: TcpSocket, } -impl embedded_io_v06::ErrorType for TcpSocketAdapter { +impl embedded_io::ErrorType for TcpSocketAdapter { type Error = IoError; } -impl embedded_io_async_v06::Read for TcpSocketAdapter { +impl embedded_io_async::Read for TcpSocketAdapter { async fn read(&mut self, buffer: &mut [u8]) -> core::result::Result { self.socket .read(buffer) @@ -83,7 +93,7 @@ impl embedded_io_async_v06::Read for TcpSocketAdapter { } } -impl embedded_io_async_v06::Write for TcpSocketAdapter { +impl embedded_io_async::Write for TcpSocketAdapter { async fn write(&mut self, buffer: &[u8]) -> core::result::Result { self.socket .write(buffer) @@ -168,7 +178,7 @@ fn map_tls_error(error: embedded_tls::TlsError) -> Error { match error { embedded_tls::TlsError::ConnectionClosed => Error::InputOutput, - embedded_tls::TlsError::Io(embedded_io_v06::ErrorKind::TimedOut) => Error::InputOutput, + embedded_tls::TlsError::Io(embedded_io::ErrorKind::TimedOut) => Error::InputOutput, _ => Error::InputOutput, } } @@ -309,13 +319,11 @@ async fn create_tls_connection<'a>( let mut tls = TlsConnection::new(TcpSocketAdapter { socket }, read_record, write_record); let configuration = TlsConfig::new().with_server_name(host); - let mut random = SystemRng; - let context = TlsContext::new(&configuration, &mut random); + let provider = UnsecureProvider::new::(SystemRng); + let context = TlsContext::new(&configuration, provider); log::information!("https_client: starting tls handshake"); - tls.open::(context) - .await - .map_err(map_tls_error)?; + tls.open(context).await.map_err(map_tls_error)?; log::information!("https_client: tls handshake done"); Ok(tls)