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

Do not call openssl_probe::init_ssl_cert_env_vars() on FreeBSD (#1129) #1130

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

michael-o
Copy link

The heuristics in openssl-probe leave the process environment with an invalid value breaking the certificate validation on FreeBSD. FreeBSD has a system truststore managed by certctl(8). Leave it to OpenSSL to do the right thing.

Upstream issue: alexcrichton/openssl-probe#37

This fixes #1129

…lang#1129)

The heuristics in openssl-probe leave the process environment with an invalid
value breaking the certificate validation on FreeBSD. FreeBSD has a system
truststore managed by certctl(8). Leave it to OpenSSL to do the right thing.

Upstream issue: alexcrichton/openssl-probe#37

This fixes rust-lang#1129
@rustbot rustbot added the S-waiting-on-review Status: Waiting on review label Feb 24, 2025
michael-o added a commit to michael-o/freebsd-ports that referenced this pull request Feb 24, 2025
Cargo uses curl-rust and git2-rs (which uses curl-rest as well).
Unfortunately, git2-rs calls openssl_probe::init_ssl_cert_env_vars()
unconditionally which breaks the process environment by setting an invalid
value for SSL_CERT_DIR and then the system default truststore is circumvented,
resulting in certificate validation errors even if certlctl(8) manages
everything nicely.

Upstream issues:
* alexcrichton/openssl-probe#37
* rust-lang/git2-rs#1130

Reviewed by:	jrm (mentor), otis (mentor), ...
MFH:		2025Q1
@michael-o
Copy link
Author

@emaste FYI

freebsd-git pushed a commit to freebsd/freebsd-ports that referenced this pull request Mar 7, 2025
Cargo uses curl-rust and git2-rs (which uses curl-rest as well).
Unfortunately, git2-rs calls openssl_probe::init_ssl_cert_env_vars()
unconditionally which breaks the process environment by setting an invalid
value for SSL_CERT_DIR and then the system default truststore is circumvented,
resulting in certificate validation errors even if certctl(8) manages
everything nicely.

Upstream issues:
* alexcrichton/openssl-probe#37
* rust-lang/git2-rs#1130

Reviewed by:	jrm (mentor), mikael (rust)
MFH:		2025Q1
Differential Revision:	https://reviews.freebsd.org/D49120
freebsd-git pushed a commit to freebsd/freebsd-ports that referenced this pull request Mar 7, 2025
Cargo uses curl-rust and git2-rs (which uses curl-rest as well).
Unfortunately, git2-rs calls openssl_probe::init_ssl_cert_env_vars()
unconditionally which breaks the process environment by setting an invalid
value for SSL_CERT_DIR and then the system default truststore is circumvented,
resulting in certificate validation errors even if certctl(8) manages
everything nicely.

Upstream issues:
* alexcrichton/openssl-probe#37
* rust-lang/git2-rs#1130

Reviewed by:	jrm (mentor), mikael (rust)
MFH:		2025Q1
Differential Revision:	https://reviews.freebsd.org/D49120

(cherry picked from commit 0780826)
@ehuss
Copy link
Contributor

ehuss commented Mar 17, 2025

Sorry, I don't know much about FreeBSD in this regard. @asomers do you perhaps have any knowledge here?

Can you say why this wouldn't be a fix in openssl-probe instead?

@michael-o
Copy link
Author

michael-o commented Mar 17, 2025

Sorry, I don't know much about FreeBSD in this regard. @asomers do you perhaps have any knowledge here?

Can you say why this wouldn't be a fix in openssl-probe instead?

Fro two reasons:

  • OpenSSL knows best which store to use by its default verify paths
  • You will never be able to have a complete list of possible locations of truststores without any false positives across 10+ OSes.

Don't set anything explicit if it works works flawless implicit: SSL_CTX_set_default_verify_paths

I have already committed the patch downstream in FreeBSD's Rust port to fix Cargo, but this doesn't fix standalone use of this library: freebsd/freebsd-ports@0780826

@kevans

@asomers
Copy link

asomers commented Mar 18, 2025

Sorry @ehuss ; I'm not knowledgeable about this issue.

@michael-o
Copy link
Author

@ehuss Do you have any objections/pain to merge this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Waiting on review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Calling openssl_env_init() on FreeBSD breaks certificate validation with the system default trutstore
4 participants