-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
We are building cryptography ourself on a system using system openssl 3.2.0 but we want to achieve minimum compatibility with openssl 3.0.8. The reason is that we want to use system openssl because it is patched faster in case of CVE and not using bundled openssl like it is on PYPI.
Based on the header for openssl it should be possible to set (via -DOPENSSL_API_COMPAT=30000 variable) the compatibility level.
However it is currently not possible to specify the compatibility level of openssl in cryptograpy.
For example how to use this in C:
https://github.com/openssl/openssl/blob/3d68b70b9e4f36509a8adf63221bf24b3cc18052/include/openssl/macros.h#L84-L87
While cryptography allows to specify CRYPTOGRAPHY_BUILD_OPENSSL_NO_LEGACY it does not allow you to change DEP_OPENSSL_VERSION_NUMBER that we want to target (because it is set from openssl rust project).
Would it be possible to override the openssl version to target lower openssl. Perhaps using additional OPENSSL_API_COMPAT before checking DEP_OPENSSL_VERSION_NUMBER.
The logic that depends and includes 3.2 symbols is:
cryptography/src/rust/src/lib.rs
Lines 245 to 256 in 1aae69a
if #[cfg(CRYPTOGRAPHY_OPENSSL_320_OR_GREATER)] { | |
use std::ptr; | |
use std::cmp::max; | |
let available = std::thread::available_parallelism().map_or(0, |v| v.get() as u64); | |
// SAFETY: This sets a libctx provider limit, but we always use the same libctx by passing NULL. | |
unsafe { | |
let current = openssl_sys::OSSL_get_max_threads(ptr::null_mut()); | |
// Set the thread limit to the max of available parallelism or current limit. | |
openssl_sys::OSSL_set_max_threads(ptr::null_mut(), max(available, current)); | |
} | |
} |