Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

May I ask if there is a switch that can turn off some OpenSSL functions that I cannot use #2213

Closed
androiddisk opened this issue Mar 31, 2024 · 3 comments

Comments

@androiddisk
Copy link

openssl = { version = "0.10.64", features = ["vendored"] }
[profile.release]
strip = true
opt-level = "z"
lto = true

After adding OpenSSL, the compiled binary is 3M larger

openssl = { path = "./src/rust-openssl/openssl", features = ["vendored"] }

Now I will integrate the source code of OpenSSL into the project for use. I hope to find a way to streamline OpenSSL functionality.
There are too many features in OpenSSL, and I hope to disable some of them, such as RSA.
Thank you

@androiddisk
Copy link
Author

I tried compiling from Linux to Android. I don't want dynamic linking, I just want static compilation. May I ask if there is a suitable method? Thank you

@Skepfyr
Copy link
Collaborator

Skepfyr commented May 7, 2024

If you want a heavily customized OpenSSL, then your best bet is to compile it yourself and configure rust-openssl to statically link against that:

Manual

A set of environment variables can be used to point openssl-sys towards an OpenSSL installation. They will override the automatic detection logic.

  • OPENSSL_DIR - If specified, the directory of an OpenSSL installation. The directory should contain lib and include subdirectories containing the libraries and headers respectively.
  • OPENSSL_LIB_DIR and OPENSSL_INCLUDE_DIR - If specified, the directories containing the OpenSSL libraries and headers respectively. This can be used if the OpenSSL installation is split in a nonstandard directory layout.
  • OPENSSL_STATIC - If set, the crate will statically link to OpenSSL rather than dynamically link.
  • OPENSSL_LIBS - If set, a :-separated list of library names to link to (e.g. ssl:crypto). This can be used if nonstandard library names were used for whatever reason.
  • OPENSSL_NO_VENDOR - If set, always find OpenSSL in the system, even if the vendored feature is enabled.

Additionally, these variables can be prefixed with the upper-cased target architecture (e.g. X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR), which can be useful when cross compiling.

@androiddisk
Copy link
Author

Okay, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants