git: 078082660317 - main - lang/rust: Make OpenSSL use the system default truststore in Cargo

From: Michael Osipov <michaelo_at_FreeBSD.org>
Date: Fri, 07 Mar 2025 17:45:03 UTC
The branch main has been updated by michaelo:

URL: https://cgit.FreeBSD.org/ports/commit/?id=078082660317490b1a2faf93ddce4b49c6b165dc

commit 078082660317490b1a2faf93ddce4b49c6b165dc
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:44:16 +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
---
 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 e6521112bd61..7d5f8cf09f04 100644
--- a/lang/rust/Makefile
+++ b/lang/rust/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	rust
 PORTVERSION?=	1.85.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() {}