Skip to content

Commit 8986c3c

Browse files
RyanMeulenkampamousset
authored andcommitted
Add TLS1.3 support
1 parent 7d04b8a commit 8986c3c

File tree

5 files changed

+24
-0
lines changed

5 files changed

+24
-0
lines changed

src/imp/openssl.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ fn supported_protocols(
3232
Protocol::Tlsv10 => SslVersion::TLS1,
3333
Protocol::Tlsv11 => SslVersion::TLS1_1,
3434
Protocol::Tlsv12 => SslVersion::TLS1_2,
35+
Protocol::Tlsv13 => SslVersion::TLS1_3,
3536
}
3637
}
3738

src/imp/schannel.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ static PROTOCOLS: &'static [Protocol] = &[
1919
Protocol::Tls10,
2020
Protocol::Tls11,
2121
Protocol::Tls12,
22+
Protocol::Tls13,
2223
];
2324

2425
fn convert_protocols(min: Option<::Protocol>, max: Option<::Protocol>) -> &'static [Protocol] {

src/imp/security_framework.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ fn convert_protocol(protocol: Protocol) -> SslProtocol {
4949
Protocol::Tlsv10 => SslProtocol::TLS1,
5050
Protocol::Tlsv11 => SslProtocol::TLS11,
5151
Protocol::Tlsv12 => SslProtocol::TLS12,
52+
Protocol::Tlsv13 => SslProtocol::TLS13,
5253
}
5354
}
5455

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,8 @@ pub enum Protocol {
322322
Tlsv11,
323323
/// The TLS 1.2 protocol.
324324
Tlsv12,
325+
/// The TLS 1.3 protocol.
326+
Tlsv13,
325327
}
326328

327329
/// A builder for `TlsConnector`s.

src/test.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,25 @@ macro_rules! p {
1616
};
1717
}
1818

19+
#[test]
20+
fn connect_google_tls13() {
21+
let builder = p!(
22+
TlsConnector::builder()
23+
.min_protocol_version(Some(Protocol::Tlsv13))
24+
.max_protocol_version(Some(Protocol::Tlsv13))
25+
.build());
26+
let s = p!(TcpStream::connect("google.com:443"));
27+
let mut socket = p!(builder.connect("google.com", s));
28+
29+
p!(socket.write_all(b"GET / HTTP/1.0\r\n\r\n"));
30+
let mut result = vec![];
31+
p!(socket.read_to_end(&mut result));
32+
33+
println!("{}", String::from_utf8_lossy(&result));
34+
assert!(result.starts_with(b"HTTP/1.0"));
35+
assert!(result.ends_with(b"</HTML>\r\n") || result.ends_with(b"</html>"));
36+
}
37+
1938
#[test]
2039
fn connect_google() {
2140
let builder = p!(TlsConnector::new());

0 commit comments

Comments
 (0)