-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prepare Rust for the next libcrypto bump
X509V3_EXT_add_alias() will go away and X509_PURPOSE_get0() will return a const pointer. This breaks the build of the vendored rust-openssl crate. Fix this by pulling in (parts of) the following upstream PRs: sfackler/rust-openssl#2121 sfackler/rust-openssl#2124 ok semarie (maintainer)
- Loading branch information
Showing
7 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
https://github.com/sfackler/rust-openssl/pull/2124 | ||
|
||
Index: vendor/openssl-sys/build/cfgs.rs | ||
--- vendor/openssl-sys/build/cfgs.rs.orig | ||
+++ vendor/openssl-sys/build/cfgs.rs | ||
@@ -53,6 +53,9 @@ pub fn get(openssl_version: Option<u64>, libressl_vers | ||
if libressl_version >= 0x3_07_00_00_0 { | ||
cfgs.push("libressl370"); | ||
} | ||
+ if libressl_version >= 0x3_09_00_00_0 { | ||
+ cfgs.push("libressl390"); | ||
+ } | ||
} else { | ||
let openssl_version = openssl_version.unwrap(); | ||
|
17 changes: 17 additions & 0 deletions
17
lang/rust/patches/patch-vendor_openssl-sys_src_handwritten_x509_rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
https://github.com/sfackler/rust-openssl/pull/2124 | ||
|
||
Index: vendor/openssl-sys/src/handwritten/x509.rs | ||
--- vendor/openssl-sys/src/handwritten/x509.rs.orig | ||
+++ vendor/openssl-sys/src/handwritten/x509.rs | ||
@@ -700,10 +700,8 @@ pub struct X509_PURPOSE { | ||
const_ptr_api! { | ||
extern "C" { | ||
pub fn X509_PURPOSE_get_by_sname(sname: #[const_ptr_if(any(ossl110, libressl280))] c_char) -> c_int; | ||
+ pub fn X509_PURPOSE_get0(idx: c_int) -> #[const_ptr_if(libressl390)] X509_PURPOSE; | ||
} | ||
-} | ||
-extern "C" { | ||
- pub fn X509_PURPOSE_get0(idx: c_int) -> *mut X509_PURPOSE; | ||
} | ||
|
||
extern "C" { |
13 changes: 13 additions & 0 deletions
13
lang/rust/patches/patch-vendor_openssl-sys_src_handwritten_x509v3_rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
https://github.com/sfackler/rust-openssl/pull/2124 | ||
|
||
Index: vendor/openssl-sys/src/handwritten/x509v3.rs | ||
--- vendor/openssl-sys/src/handwritten/x509v3.rs.orig | ||
+++ vendor/openssl-sys/src/handwritten/x509v3.rs | ||
@@ -84,6 +84,7 @@ const_ptr_api! { | ||
} | ||
|
||
extern "C" { | ||
+ #[cfg(not(libressl390))] | ||
pub fn X509V3_EXT_add_alias(nid_to: c_int, nid_from: c_int) -> c_int; | ||
pub fn X509V3_EXT_d2i(ext: *mut X509_EXTENSION) -> *mut c_void; | ||
pub fn X509V3_EXT_i2d(ext_nid: c_int, crit: c_int, ext: *mut c_void) -> *mut X509_EXTENSION; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
https://github.com/sfackler/rust-openssl/pull/2124 | ||
|
||
Index: vendor/openssl/build.rs | ||
--- vendor/openssl/build.rs.orig | ||
+++ vendor/openssl/build.rs | ||
@@ -73,6 +73,9 @@ fn main() { | ||
for var in vars.split(',') { | ||
println!("cargo:rustc-cfg=osslconf=\"{}\"", var); | ||
} | ||
+ if version >= 0x3_09_00_00_0 { | ||
+ println!("cargo:rustc-cfg=libressl390"); | ||
+ } | ||
} | ||
|
||
if let Ok(version) = env::var("DEP_OPENSSL_VERSION_NUMBER") { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Part of https://github.com/sfackler/rust-openssl/pull/2121 | ||
|
||
Index: vendor/openssl/src/lib.rs | ||
--- vendor/openssl/src/lib.rs.orig | ||
+++ vendor/openssl/src/lib.rs | ||
@@ -204,6 +204,15 @@ fn cvt_p<T>(r: *mut T) -> Result<*mut T, ErrorStack> { | ||
} | ||
|
||
#[inline] | ||
+fn cvt_p_const<T>(r: *const T) -> Result<*const T, ErrorStack> { | ||
+ if r.is_null() { | ||
+ Err(ErrorStack::get()) | ||
+ } else { | ||
+ Ok(r) | ||
+ } | ||
+} | ||
+ | ||
+#[inline] | ||
fn cvt(r: c_int) -> Result<c_int, ErrorStack> { | ||
if r <= 0 { | ||
Err(ErrorStack::get()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
From https://github.com/sfackler/rust-openssl/pull/2121 | ||
and https://github.com/sfackler/rust-openssl/pull/2124 | ||
|
||
Index: vendor/openssl/src/x509/mod.rs | ||
--- vendor/openssl/src/x509/mod.rs.orig | ||
+++ vendor/openssl/src/x509/mod.rs | ||
@@ -38,7 +38,7 @@ use crate::ssl::SslRef; | ||
use crate::stack::{Stack, StackRef, Stackable}; | ||
use crate::string::OpensslString; | ||
use crate::util::{ForeignTypeExt, ForeignTypeRefExt}; | ||
-use crate::{cvt, cvt_n, cvt_p}; | ||
+use crate::{cvt, cvt_n, cvt_p, cvt_p_const}; | ||
use openssl_macros::corresponds; | ||
|
||
#[cfg(any(ossl102, libressl261))] | ||
@@ -1022,6 +1022,7 @@ impl X509Extension { | ||
/// # Safety | ||
/// | ||
/// This method modifies global state without locking and therefore is not thread safe | ||
+ #[cfg(not(libressl390))] | ||
#[corresponds(X509V3_EXT_add_alias)] | ||
#[deprecated( | ||
note = "Use x509::extension types or new_from_der and then this is not necessary", | ||
@@ -2511,8 +2512,8 @@ impl X509PurposeRef { | ||
#[corresponds(X509_PURPOSE_get0)] | ||
pub fn from_idx(idx: c_int) -> Result<&'static X509PurposeRef, ErrorStack> { | ||
unsafe { | ||
- let ptr = cvt_p(ffi::X509_PURPOSE_get0(idx))?; | ||
- Ok(X509PurposeRef::from_ptr(ptr)) | ||
+ let ptr = cvt_p_const(ffi::X509_PURPOSE_get0(idx))?; | ||
+ Ok(X509PurposeRef::from_const_ptr(ptr)) | ||
} | ||
} | ||
|