diff --git a/build.rs b/build.rs index b7a41f4..f0b6f7d 100644 --- a/build.rs +++ b/build.rs @@ -8,6 +8,11 @@ fn main() { if version >= 0x1_01_00_00_0 { println!("cargo:rustc-cfg=have_min_max_version"); } + + // TLS 1.3 requires openssl 1.1.1 + if version >= 0x1_01_01_00_0 { + println!("cargo:rustc-cfg=have_tls13_version"); + } } if let Ok(version) = env::var("DEP_OPENSSL_LIBRESSL_VERSION_NUMBER") { @@ -16,5 +21,10 @@ fn main() { if version >= 0x2_06_01_00_0 { println!("cargo:rustc-cfg=have_min_max_version"); } + + // TLS 1.3 requires libressl 3.2 + if version >= 0x3_02_01_00_0 { + println!("cargo:rustc-cfg=have_tls13_version"); + } } } diff --git a/src/imp/openssl.rs b/src/imp/openssl.rs index 2d1df1a..f0ad7fb 100644 --- a/src/imp/openssl.rs +++ b/src/imp/openssl.rs @@ -32,6 +32,7 @@ fn supported_protocols( Protocol::Tlsv10 => SslVersion::TLS1, Protocol::Tlsv11 => SslVersion::TLS1_1, Protocol::Tlsv12 => SslVersion::TLS1_2, + #[cfg(have_tls13_version)] Protocol::Tlsv13 => SslVersion::TLS1_3, } } diff --git a/src/lib.rs b/src/lib.rs index 614007d..3fb5f2b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -323,6 +323,7 @@ pub enum Protocol { /// The TLS 1.2 protocol. Tlsv12, /// The TLS 1.3 protocol. + #[cfg(any(target_os = "macos", target_os = "windows", target_os = "ios", have_tls13_version))] Tlsv13, }