summaryrefslogtreecommitdiffstats
path: root/src/bin/client/tls.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/bin/client/tls.rs17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/bin/client/tls.rs b/src/bin/client/tls.rs
index b46f52b..e14ed98 100644
--- a/src/bin/client/tls.rs
+++ b/src/bin/client/tls.rs
@@ -17,10 +17,10 @@ use std::net::TcpStream;
17use std::sync::Arc; 17use std::sync::Arc;
18 18
19use parking_lot::Mutex; 19use parking_lot::Mutex;
20use rustls::client::{HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier};
21use rustls::DigitallySignedStruct; 20use rustls::DigitallySignedStruct;
21use rustls::client::{HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier};
22use zagan_bet::protocol::LineBuffer; 22use zagan_bet::protocol::LineBuffer;
23use zagan_bet::tofu::{decide, spki_fingerprint, TrustDecision}; 23use zagan_bet::tofu::{TrustDecision, decide, spki_fingerprint};
24 24
25pub struct TlsConnector { 25pub struct TlsConnector {
26 config: Arc<rustls::ClientConfig>, 26 config: Arc<rustls::ClientConfig>,
@@ -53,7 +53,10 @@ impl TlsConnector {
53 }) 53 })
54 } 54 }
55 55
56 pub fn connect(&self, stream: TcpStream) -> Result<TlsStream, Box<dyn std::error::Error + Send + Sync>> { 56 pub fn connect(
57 &self,
58 stream: TcpStream,
59 ) -> Result<TlsStream, Box<dyn std::error::Error + Send + Sync>> {
57 let mut conn = 60 let mut conn =
58 rustls::ClientConnection::new(Arc::clone(&self.config), self.server_name.clone())?; 61 rustls::ClientConnection::new(Arc::clone(&self.config), self.server_name.clone())?;
59 let mut sock = stream; 62 let mut sock = stream;
@@ -200,10 +203,7 @@ impl TlsStream {
200 } 203 }
201 204
202 /// Apply a read timeout to the underlying TCP socket. 205 /// Apply a read timeout to the underlying TCP socket.
203 pub fn set_read_timeout( 206 pub fn set_read_timeout(&self, duration: Option<std::time::Duration>) -> std::io::Result<()> {
204 &self,
205 duration: Option<std::time::Duration>,
206 ) -> std::io::Result<()> {
207 let mut s = self.session.lock(); 207 let mut s = self.session.lock();
208 s.read_timeout = duration; 208 s.read_timeout = duration;
209 s.sock.set_read_timeout(duration) 209 s.sock.set_read_timeout(duration)
@@ -235,8 +235,7 @@ impl TlsStream {
235 Err(error) 235 Err(error)
236 if matches!( 236 if matches!(
237 error.kind(), 237 error.kind(),
238 std::io::ErrorKind::WouldBlock 238 std::io::ErrorKind::WouldBlock | std::io::ErrorKind::TimedOut
239 | std::io::ErrorKind::TimedOut
240 ) => 239 ) =>
241 { 240 {
242 return Ok(()); 241 return Ok(());