Skip to content

Specify minimum compatibly when building with openssl #13393

@mspiller

Description

@mspiller

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:

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));
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions