git: 093b0eb52a7e - 2025Q1 - lang/rust: Make OpenSSL use the system default truststore in Cargo

From: Michael Osipov <michaelo_at_FreeBSD.org>
Date: Fri, 07 Mar 2025 18:02:11 UTC
The branch 2025Q1 has been updated by michaelo:

URL: https://cgit.FreeBSD.org/ports/commit/?id=093b0eb52a7edf34511ad4196375f111162c5dac

commit 093b0eb52a7edf34511ad4196375f111162c5dac
Author:     Michael Osipov <michaelo@FreeBSD.org>
AuthorDate: 2025-02-24 09:17:25 +0000
Commit:     Michael Osipov <michaelo@FreeBSD.org>
CommitDate: 2025-03-07 17:47:15 +0000

    lang/rust: Make OpenSSL use the system default truststore in Cargo
    
    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:
    * https://github.com/alexcrichton/openssl-probe/issues/37
    * https://github.com/rust-lang/git2-rs/pull/1130
    
    Reviewed by:    jrm (mentor), mikael (rust)
    MFH:            2025Q1
    Differential Revision:  https://reviews.freebsd.org/D49120
    
    (cherry picked from commit 078082660317490b1a2faf93ddce4b49c6b165dc)
---
 lang/rust/Makefile                                  |  2 +-
 lang/rust/files/patch-vendor_git2-0.19.0_src_lib.rs | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/lang/rust/Makefile b/lang/rust/Makefile
index 3da2334892f1..b29e5cb7a80b 100644
--- a/lang/rust/Makefile
+++ b/lang/rust/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	rust
 PORTVERSION?=	1.83.0
-PORTREVISION?=	0
+PORTREVISION?=	1
 CATEGORIES=	lang
 MASTER_SITES=	https://static.rust-lang.org/dist/:src \
 		https://dev-static.rust-lang.org/dist/:src \
diff --git a/lang/rust/files/patch-vendor_git2-0.19.0_src_lib.rs b/lang/rust/files/patch-vendor_git2-0.19.0_src_lib.rs
new file mode 100644
index 000000000000..612698c459f7
--- /dev/null
+++ b/lang/rust/files/patch-vendor_git2-0.19.0_src_lib.rs
@@ -0,0 +1,18 @@
+--- vendor/git2-0.19.0/src/lib.rs.orig	2025-02-21 20:02:44 UTC
++++ vendor/git2-0.19.0/src/lib.rs
+@@ -759,6 +759,7 @@ fn init() {
+     unix,
+     not(target_os = "macos"),
+     not(target_os = "ios"),
++    not(target_os = "freebsd"),
+     feature = "https"
+ ))]
+ fn openssl_env_init() {
+@@ -880,6 +881,7 @@ fn openssl_env_init() {
+     windows,
+     target_os = "macos",
+     target_os = "ios",
++    target_os = "freebsd",
+     not(feature = "https")
+ ))]
+ fn openssl_env_init() {}