diff --git a/src/sender/mod.rs b/src/sender/mod.rs index fa3a762..6aab624 100644 --- a/src/sender/mod.rs +++ b/src/sender/mod.rs @@ -70,7 +70,8 @@ where let cfg = match client_cert { None => cfg.with_no_client_auth(), Some(c) => { - let rustls_cert = rustls::Certificate::read_bytes(&c.der)?; + //let rustls_cert = rustls::Certificate::read_bytes(&c.der)?; + let rustls_cert = rustls::Certificate(c.der); let cert_chain = vec![rustls_cert]; let key_der = rustls::PrivateKey(c.key); cfg.with_single_cert(cert_chain, key_der)? @@ -79,8 +80,8 @@ where let client = ClientConnection::new(Arc::new(cfg), dnsname)?; let mut stream = StreamOwned::new(client, tcp_stream); stream.write_all(self.request.to_string().as_bytes())?; - let mut buf = vec![]; - stream.read_to_end(&mut buf)?; + let mut buf = Vec::with_capacity(1024); + let _res = stream.read_to_end(&mut buf); stream.conn.send_close_notify(); drop(stream); let res = buf.try_into()?; diff --git a/src/status/mod.rs b/src/status/mod.rs index ca88b1d..1ddb6f7 100644 --- a/src/status/mod.rs +++ b/src/status/mod.rs @@ -1,4 +1,6 @@ mod error; +use std::fmt; + pub use error::Error; #[cfg(feature = "serde")] @@ -32,7 +34,8 @@ pub enum Status { impl From for u8 { fn from(value: Status) -> Self { match value { - Status::Input | Status::Success => value.into(), + Status::Input => 10, + Status::Success => 20, Status::Redirect(n) => 30 + n as u8, Status::TemporaryFailure(n) => 40 + n as u8, Status::PermanentFailure(n) => 50 + n as u8, @@ -200,6 +203,18 @@ impl TryFrom for AuthenticationFailure { mod tests { use super::*; + #[test] + fn to_number_success() { + let num: u8 = Status::Success.into(); + assert_eq!(num, 20); + } + + #[test] + fn to_number_redirect() { + let num: u8 = Status::Redirect(Redirect::Temporary).into(); + assert_eq!(num, 30); + } + #[test] fn parse_status_success() { let status = Status::try_from(21).unwrap();