Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 1 addition & 0 deletions src/imp/openssl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(),
}
}
Expand Down
1 change: 1 addition & 0 deletions src/imp/schannel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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] {
Expand Down
1 change: 1 addition & 0 deletions src/imp/security_framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(),
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ pub enum Protocol {
Tlsv11,
/// The TLS 1.2 protocol.
Tlsv12,
/// The TLS 1.3 protocol.
Tlsv13,
#[doc(hidden)]
__NonExhaustive,
}
Expand Down
19 changes: 19 additions & 0 deletions src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"</HTML>\r\n") || result.ends_with(b"</html>"));
}

#[test]
fn connect_google() {
let builder = p!(TlsConnector::new());
Expand Down