select the system certificates more reliably

The rust build requires cargo to connect to its servers, it needs system
certificates to connect through MITM proxies or other various issues in
corporate systems.  This searches for more common locations to find
those certificates and the name used by RHEL in addition to the usual
debian convention.  Fixes rust build on TOSS4.
This commit is contained in:
Tom Scogland 2023-11-06 11:46:00 -08:00
parent 367abcb801
commit f80df0ca47

View File

@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import re
import os
from spack.package import *
@ -92,8 +93,16 @@ def setup_build_environment(self, env):
env.set("AR", ar.path)
# Manually inject the path of openssl's certs for build.
certs = join_path(self.spec["openssl"].prefix, "etc/openssl/cert.pem")
env.set("CARGO_HTTP_CAINFO", certs)
certs = None
for p in ("etc/openssl/cert.pem", "../etc/openssl/cert.pem",
"etc/ssl/certs/ca-bundle.crt", "../etc/ssl/certs/ca-bundle.crt"):
certs = join_path(self.spec["openssl"].prefix, p)
if os.path.exists(certs):
break
else:
certs = None
if certs is not None:
env.set("CARGO_HTTP_CAINFO", certs)
def configure(self, spec, prefix):
opts = []