From bd7ba7d0edda287db0c871ae47fa2c480b5685ef Mon Sep 17 00:00:00 2001 From: Edwin Svensson Date: Wed, 25 Mar 2020 23:16:53 +0100 Subject: [PATCH 1/3] update deps --- Cargo.toml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a39b7138..88f812d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,18 +13,18 @@ vendored = ["openssl/vendored"] [target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies] security-framework = "0.4.1" security-framework-sys = "0.4.1" -lazy_static = "1.0" +lazy_static = "1.4" libc = "0.2" -tempfile = "3.0" +tempfile = "3.1" [target.'cfg(target_os = "windows")'.dependencies] -schannel = "0.1.16" +schannel = "0.1.18" [target.'cfg(not(any(target_os = "windows", target_os = "macos", target_os = "ios")))'.dependencies] -log = "0.4.5" -openssl = "0.10.25" -openssl-sys = "0.9.30" +log = "0.4" +openssl = "0.10.28" +openssl-sys = "0.9.54" openssl-probe = "0.1" [dev-dependencies] -hex = "0.3" +hex = "0.4" From e75866bbbf9fe8c52cc3dc486708a4cf4d554f45 Mon Sep 17 00:00:00 2001 From: Edwin Svensson Date: Wed, 25 Mar 2020 23:25:41 +0100 Subject: [PATCH 2/3] implement TLS 1.3 --- src/imp/openssl.rs | 1 + src/imp/schannel.rs | 1 + src/imp/security_framework.rs | 1 + src/lib.rs | 2 ++ 4 files changed, 5 insertions(+) diff --git a/src/imp/openssl.rs b/src/imp/openssl.rs index 421eda29..63ee74c9 100644 --- a/src/imp/openssl.rs +++ b/src/imp/openssl.rs @@ -33,6 +33,7 @@ fn supported_protocols( Protocol::Tlsv10 => SslVersion::TLS1, Protocol::Tlsv11 => SslVersion::TLS1_1, Protocol::Tlsv12 => SslVersion::TLS1_2, + Protocol::Tlsv13 => SslVersion::TLS1_3, Protocol::__NonExhaustive => unreachable!(), } } diff --git a/src/imp/schannel.rs b/src/imp/schannel.rs index 5b0a3961..66190f0b 100644 --- a/src/imp/schannel.rs +++ b/src/imp/schannel.rs @@ -18,6 +18,7 @@ static PROTOCOLS: &'static [Protocol] = &[ Protocol::Tls10, Protocol::Tls11, Protocol::Tls12, + Protocol::Tls13, ]; fn convert_protocols(min: Option<::Protocol>, max: Option<::Protocol>) -> &'static [Protocol] { diff --git a/src/imp/security_framework.rs b/src/imp/security_framework.rs index 5060f410..a5724c49 100644 --- a/src/imp/security_framework.rs +++ b/src/imp/security_framework.rs @@ -44,6 +44,7 @@ fn convert_protocol(protocol: Protocol) -> SslProtocol { Protocol::Tlsv10 => SslProtocol::TLS1, Protocol::Tlsv11 => SslProtocol::TLS11, Protocol::Tlsv12 => SslProtocol::TLS12, + Protocol::Tlsv13 => SslProtocol::TLS13, Protocol::__NonExhaustive => unreachable!(), } } diff --git a/src/lib.rs b/src/lib.rs index 3edcb86f..ea4ca923 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -314,6 +314,8 @@ pub enum Protocol { Tlsv11, /// The TLS 1.2 protocol. Tlsv12, + /// The TLS 1.3 protocol. + Tlsv13, #[doc(hidden)] __NonExhaustive, } From 90cd06fb9b7bf505f9cbf97f80f71c192388ef52 Mon Sep 17 00:00:00 2001 From: Edwin Svensson Date: Wed, 25 Mar 2020 23:25:55 +0100 Subject: [PATCH 3/3] added TLS 1.3 test --- src/test.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/test.rs b/src/test.rs index f52d7fa7..853710e0 100644 --- a/src/test.rs +++ b/src/test.rs @@ -19,6 +19,25 @@ macro_rules! p { mod tests { use super::*; + #[test] + fn connect_google_tls13() { + let builder = p!( + TlsConnector::builder() + .min_protocol_version(Some(Protocol::Tlsv13)) + .max_protocol_version(Some(Protocol::Tlsv13)) + .build()); + let s = p!(TcpStream::connect("google.com:443")); + let mut socket = p!(builder.connect("google.com", s)); + + p!(socket.write_all(b"GET / HTTP/1.0\r\n\r\n")); + let mut result = vec![]; + p!(socket.read_to_end(&mut result)); + + println!("{}", String::from_utf8_lossy(&result)); + assert!(result.starts_with(b"HTTP/1.0")); + assert!(result.ends_with(b"\r\n") || result.ends_with(b"")); + } + #[test] fn connect_google() { let builder = p!(TlsConnector::new());