From e0efd1d438fbf426a7e1006e4983b0f352c630f6 Mon Sep 17 00:00:00 2001 From: Christopher Vittal Date: Tue, 3 Oct 2017 23:53:50 -0400 Subject: [PATCH 1/3] Add support for LibreSSL 2.6.2 --- openssl-sys/build.rs | 11 ++++++++++- openssl/src/ssl/tests/mod.rs | 2 +- systest/build.rs | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/openssl-sys/build.rs b/openssl-sys/build.rs index 4848f236..34b74f82 100644 --- a/openssl-sys/build.rs +++ b/openssl-sys/build.rs @@ -316,8 +316,10 @@ fn validate_headers(include_dirs: &[PathBuf]) -> Version { #include #include -#if LIBRESSL_VERSION_NUMBER >= 0x20602000 +#if LIBRESSL_VERSION_NUMBER >= 0x20603000 RUST_LIBRESSL_NEW +#elif LIBRESSL_VERSION_NUMBER >= 0x20602000 +RUST_LIBRESSL_262 #elif LIBRESSL_VERSION_NUMBER >= 0x20601000 RUST_LIBRESSL_261 #elif LIBRESSL_VERSION_NUMBER >= 0x20600000 @@ -466,6 +468,13 @@ See rust-openssl README for more information: println!("cargo:libressl_version=261"); println!("cargo:version=101"); Version::Libressl + } else if expanded.contains("RUST_LIBRESSL_262") { + println!("cargo:rustc-cfg=libressl"); + println!("cargo:rustc-cfg=libressl262"); + println!("cargo:libressl=true"); + println!("cargo:libressl_version=262"); + println!("cargo:version=101"); + Version::Libressl } else if expanded.contains("RUST_OPENSSL_110F") { println!("cargo:rustc-cfg=ossl110"); println!("cargo:rustc-cfg=ossl110f"); diff --git a/openssl/src/ssl/tests/mod.rs b/openssl/src/ssl/tests/mod.rs index a3ac6832..38c553e7 100644 --- a/openssl/src/ssl/tests/mod.rs +++ b/openssl/src/ssl/tests/mod.rs @@ -616,7 +616,7 @@ fn test_connect_with_npn_successful_single_match() { /// Tests that when the `SslStream` is created as a server stream, the protocols /// are correctly advertised to the client. #[test] -#[cfg(not(libressl261))] +#[cfg(all(not(libressl261),not(libressl262)))] fn test_npn_server_advertise_multiple() { let listener = TcpListener::bind("127.0.0.1:0").unwrap(); let localhost = listener.local_addr().unwrap(); diff --git a/systest/build.rs b/systest/build.rs index 45e335c0..7418cca0 100644 --- a/systest/build.rs +++ b/systest/build.rs @@ -42,7 +42,7 @@ fn main() { } let has_cms_h = if let Ok(version) = env::var("DEP_OPENSSL_LIBRESSL_VERSION") { - version != "261" + version != "261" && version != "262" } else { true }; From 701d3781dd8febcc582c801ba63527fcb5c328fb Mon Sep 17 00:00:00 2001 From: Christopher Vittal Date: Wed, 4 Oct 2017 00:05:24 -0400 Subject: [PATCH 2/3] Update CI to use LibreSSL 2.6.2 --- .circleci/config.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2c2fb0d5..39ef6c53 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -78,9 +78,9 @@ openssl_101: &OPENSSL_101 libressl_250: &LIBRESSL_250 LIBRARY: libressl VERSION: 2.5.0 -libressl_261: &LIBRESSL_261 +libressl_261: &LIBRESSL_262 LIBRARY: libressl - VERSION: 2.6.1 + VERSION: 2.6.2 x86_64: &X86_64 TARGET: x86_64-unknown-linux-gnu @@ -139,10 +139,10 @@ jobs: <<: *JOB environment: <<: [*LIBRESSL_250, *X86_64, *BASE] - x86_64-libressl-2.6.1: + x86_64-libressl-2.6.2: <<: *JOB environment: - <<: [*LIBRESSL_261, *X86_64, *BASE] + <<: [*LIBRESSL_262, *X86_64, *BASE] workflows: version: 2 tests: @@ -157,4 +157,4 @@ workflows: - armhf-openssl-1.0.2 - armhf-openssl-1.0.1 - x86_64-libressl-2.5.0 - - x86_64-libressl-2.6.1 + - x86_64-libressl-2.6.2 From 1308cb2b526355c66854ee22ea03de93bae326c1 Mon Sep 17 00:00:00 2001 From: Christopher Vittal Date: Wed, 4 Oct 2017 00:36:32 -0400 Subject: [PATCH 3/3] Fix cfgs for libressl262 --- openssl-sys/src/lib.rs | 8 ++++---- openssl-sys/src/libressl/mod.rs | 8 ++++---- openssl/src/ssl/mod.rs | 4 ++-- openssl/src/ssl/tests/mod.rs | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/openssl-sys/src/lib.rs b/openssl-sys/src/lib.rs index b7951f0a..5c8bef7f 100644 --- a/openssl-sys/src/lib.rs +++ b/openssl-sys/src/lib.rs @@ -1250,14 +1250,14 @@ pub const SSL_VERIFY_NONE: c_int = 0; pub const SSL_VERIFY_PEER: c_int = 1; pub const SSL_VERIFY_FAIL_IF_NO_PEER_CERT: c_int = 2; -#[cfg(not(any(libressl261, ossl101)))] +#[cfg(not(any(libressl261, libressl262, ossl101)))] pub const SSL_OP_TLSEXT_PADDING: c_ulong = 0x00000010; -#[cfg(libressl261)] +#[cfg(any(libressl261, libressl262))] pub const SSL_OP_TLSEXT_PADDING: c_ulong = 0x0; pub const SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: c_ulong = 0x00000800; -#[cfg(not(libressl261))] +#[cfg(not(any(libressl261, libressl262)))] pub const SSL_OP_CRYPTOPRO_TLSEXT_BUG: c_ulong = 0x80000000; -#[cfg(libressl261)] +#[cfg(any(libressl261, libressl262))] pub const SSL_OP_CRYPTOPRO_TLSEXT_BUG: c_ulong = 0x0; pub const SSL_OP_LEGACY_SERVER_CONNECT: c_ulong = 0x00000004; #[cfg(not(libressl))] diff --git a/openssl-sys/src/libressl/mod.rs b/openssl-sys/src/libressl/mod.rs index f4806e8a..52a76f9e 100644 --- a/openssl-sys/src/libressl/mod.rs +++ b/openssl-sys/src/libressl/mod.rs @@ -345,9 +345,9 @@ pub const SSL_CTRL_OPTIONS: c_int = 32; pub const SSL_CTRL_CLEAR_OPTIONS: c_int = 77; pub const SSL_CTRL_SET_ECDH_AUTO: c_int = 94; -#[cfg(libressl261)] +#[cfg(any(libressl261, libressl262))] pub const SSL_OP_ALL: c_ulong = 0x4; -#[cfg(not(libressl261))] +#[cfg(not(any(libressl261, libressl262)))] pub const SSL_OP_ALL: c_ulong = 0x80000014; pub const SSL_OP_CISCO_ANYCONNECT: c_ulong = 0x0; pub const SSL_OP_NO_COMPRESSION: c_ulong = 0x0; @@ -360,9 +360,9 @@ pub const SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: c_ulong = 0x0; pub const SSL_OP_SSLEAY_080_CLIENT_DH_BUG: c_ulong = 0x0; pub const SSL_OP_TLS_D5_BUG: c_ulong = 0x0; pub const SSL_OP_TLS_BLOCK_PADDING_BUG: c_ulong = 0x0; -#[cfg(libressl261)] +#[cfg(any(libressl261, libressl262))] pub const SSL_OP_SINGLE_ECDH_USE: c_ulong = 0x0; -#[cfg(not(libressl261))] +#[cfg(not(any(libressl261, libressl262)))] pub const SSL_OP_SINGLE_ECDH_USE: c_ulong = 0x00080000; pub const SSL_OP_SINGLE_DH_USE: c_ulong = 0x00100000; pub const SSL_OP_NO_SSLv2: c_ulong = 0x0; diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs index 762118a5..0506668c 100644 --- a/openssl/src/ssl/mod.rs +++ b/openssl/src/ssl/mod.rs @@ -652,7 +652,7 @@ impl SslContextBuilder { /// Set the protocols to be used during Next Protocol Negotiation (the protocols /// supported by the application). - #[cfg(not(libressl261))] + #[cfg(not(any(libressl261, libressl262)))] pub fn set_npn_protocols(&mut self, protocols: &[&[u8]]) -> Result<(), ErrorStack> { // Firstly, convert the list of protocols to a byte-array that can be passed to OpenSSL // APIs -- a list of length-prefixed strings. @@ -1311,7 +1311,7 @@ impl SslRef { /// /// The protocol's name is returned is an opaque sequence of bytes. It is up to the client /// to interpret it. - #[cfg(not(libressl261))] + #[cfg(not(any(libressl261, libressl262)))] pub fn selected_npn_protocol(&self) -> Option<&[u8]> { unsafe { let mut data: *const c_uchar = ptr::null(); diff --git a/openssl/src/ssl/tests/mod.rs b/openssl/src/ssl/tests/mod.rs index 38c553e7..168248de 100644 --- a/openssl/src/ssl/tests/mod.rs +++ b/openssl/src/ssl/tests/mod.rs @@ -503,7 +503,7 @@ fn test_connect_with_unilateral_alpn() { /// Tests that connecting with the client using NPN, but the server not does not /// break the existing connection behavior. #[test] -#[cfg(not(libressl261))] +#[cfg(not(any(libressl261, libressl262)))] fn test_connect_with_unilateral_npn() { let (_s, stream) = Server::new(); let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); @@ -616,7 +616,7 @@ fn test_connect_with_npn_successful_single_match() { /// Tests that when the `SslStream` is created as a server stream, the protocols /// are correctly advertised to the client. #[test] -#[cfg(all(not(libressl261),not(libressl262)))] +#[cfg(not(any(libressl261, libressl262)))] fn test_npn_server_advertise_multiple() { let listener = TcpListener::bind("127.0.0.1:0").unwrap(); let localhost = listener.local_addr().unwrap(); @@ -1241,7 +1241,7 @@ fn tmp_dh_callback() { } #[test] -#[cfg(any(all(feature = "v101", ossl101, not(libressl261)), all(feature = "v102", ossl102)))] +#[cfg(any(all(feature = "v101", ossl101, not(any(libressl261, libressl262))), all(feature = "v102", ossl102)))] fn tmp_ecdh_callback() { use ec::EcKey; use nid; @@ -1308,7 +1308,7 @@ fn tmp_dh_callback_ssl() { } #[test] -#[cfg(any(all(feature = "v101", ossl101, not(libressl261)), all(feature = "v102", ossl102)))] +#[cfg(any(all(feature = "v101", ossl101, not(any(libressl261, libressl262))), all(feature = "v102", ossl102)))] fn tmp_ecdh_callback_ssl() { use ec::EcKey; use nid;