diff options
| author | Changqing Li <changqing.li@windriver.com> | 2025-04-28 13:53:07 +0800 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2025-05-02 08:20:12 -0700 |
| commit | 18206fc2dba1684bc96efecf95c65450f9577203 (patch) | |
| tree | cc7e48cb9fc750986ddb99e8aad5e0e513ad5551 | |
| parent | 397d432a62c265f481cf1ac4d9c760504d9eb9f5 (diff) | |
| download | poky-18206fc2dba1684bc96efecf95c65450f9577203.tar.gz | |
buildtools-tarball: Make buildtools respects host CA certificates
To adapt user network enviroment, buildtools should first try to use
the user configured envs like SSL_CERT_FILE/CURL_CA_BUNDLE/..., if these
envs is not set, then use the auto-detected ca file and ca path, and
finally use the CA certificates in buildtools.
nativesdk-openssl set OPENSSLDIR as "/not/builtin", need set SSL_CERT_FILE/SSL_CERT_DIR to work
nativesdk-curl don't set default ca file, need
SSL_CERT_FILE/SSL_CERT_DIR or CURL_CA_BUNDLE/CURL_CA_PATH to work
nativesdk-git actually use libcurl, and GIT_SSL_CAPATH/GIT_SSL_CAINFO
also works
nativesdk-python3-requests will use cacert.pem under python module certifi by
default, need to set REQUESTS_CA_BUNDLE
(From OE-Core rev: 0653b96bac6d0800dc5154557706a323418808be)
Signed-off-by: Changqing Li <changqing.li@windriver.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
5 files changed, 88 insertions, 15 deletions
diff --git a/meta/recipes-connectivity/openssl/files/environment.d-openssl.sh b/meta/recipes-connectivity/openssl/files/environment.d-openssl.sh index 6cb82d7386..c635be8aca 100644 --- a/meta/recipes-connectivity/openssl/files/environment.d-openssl.sh +++ b/meta/recipes-connectivity/openssl/files/environment.d-openssl.sh | |||
| @@ -1,8 +1,23 @@ | |||
| 1 | export OPENSSL_CONF="$OECORE_NATIVE_SYSROOT/usr/lib/ssl/openssl.cnf" | 1 | export OPENSSL_CONF="$OECORE_NATIVE_SYSROOT/usr/lib/ssl/openssl.cnf" |
| 2 | if [ -e "${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" ];then | ||
| 3 | export SSL_CERT_DIR="$OECORE_NATIVE_SYSROOT/usr/lib/ssl/certs" | ||
| 4 | export SSL_CERT_FILE="$OECORE_NATIVE_SYSROOT/usr/lib/ssl/certs/ca-certificates.crt" | ||
| 5 | export BB_ENV_PASSTHROUGH_ADDITIONS="${BB_ENV_PASSTHROUGH_ADDITIONS:-} SSL_CERT_DIR SSL_CERT_FILE" | ||
| 6 | fi | ||
| 7 | export OPENSSL_MODULES="$OECORE_NATIVE_SYSROOT/usr/lib/ossl-modules/" | 2 | export OPENSSL_MODULES="$OECORE_NATIVE_SYSROOT/usr/lib/ossl-modules/" |
| 8 | export OPENSSL_ENGINES="$OECORE_NATIVE_SYSROOT/usr/lib/engines-3" | 3 | export OPENSSL_ENGINES="$OECORE_NATIVE_SYSROOT/usr/lib/engines-3" |
| 4 | |||
| 5 | # Respect host env SSL_CERT_FILE/SSL_CERT_DIR first, then auto-detected host cert, then cert in buildtools | ||
| 6 | # CAFILE/CAPATH is auto-deteced when source buildtools | ||
| 7 | if [ -z "$SSL_CERT_FILE" ]; then | ||
| 8 | if [ -n "$CAFILE" ];then | ||
| 9 | export SSL_CERT_FILE="$CAFILE" | ||
| 10 | elif [ -e "${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" ];then | ||
| 11 | export SSL_CERT_FILE="$OECORE_NATIVE_SYSROOT/usr/lib/ssl/certs/ca-certificates.crt" | ||
| 12 | fi | ||
| 13 | fi | ||
| 14 | |||
| 15 | if [ -z "$SSL_CERT_DIR" ]; then | ||
| 16 | if [ -n "$CAPATH" ];then | ||
| 17 | export SSL_CERT_DIR="$CAPATH" | ||
| 18 | elif [ -e "${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" ];then | ||
| 19 | export SSL_CERT_DIR="$OECORE_NATIVE_SYSROOT/usr/lib/ssl/certs" | ||
| 20 | fi | ||
| 21 | fi | ||
| 22 | |||
| 23 | export BB_ENV_PASSTHROUGH_ADDITIONS="${BB_ENV_PASSTHROUGH_ADDITIONS:-} SSL_CERT_DIR SSL_CERT_FILE" | ||
diff --git a/meta/recipes-core/meta/buildtools-tarball.bb b/meta/recipes-core/meta/buildtools-tarball.bb index 414c266663..8e78169e23 100644 --- a/meta/recipes-core/meta/buildtools-tarball.bb +++ b/meta/recipes-core/meta/buildtools-tarball.bb | |||
| @@ -80,14 +80,35 @@ create_sdk_files:append () { | |||
| 80 | toolchain_create_sdk_version ${SDK_OUTPUT}/${SDKPATH}/version-${SDK_SYS} | 80 | toolchain_create_sdk_version ${SDK_OUTPUT}/${SDKPATH}/version-${SDK_SYS} |
| 81 | 81 | ||
| 82 | cat >> $script <<EOF | 82 | cat >> $script <<EOF |
| 83 | # Detect host ca file/path, export for envfile to use | ||
| 84 | # /etc/ssl/certs/ca-certificates.crt Debian systems | ||
| 85 | # /etc/pki/tls/certs/ca-bundle.crt Fedora systems | ||
| 86 | # /etc/ssl/ca-bundle.pem Suse systems | ||
| 87 | export CAFILE | ||
| 88 | export CAPATH | ||
| 89 | for a in /etc/ssl/certs/ca-certificates.crt \ | ||
| 90 | /etc/pki/tls/certs/ca-bundle.crt \ | ||
| 91 | /etc/ssl/ca-bundle.pem ; do | ||
| 92 | if test -f "\$a"; then | ||
| 93 | CAFILE="\$a" | ||
| 94 | break | ||
| 95 | fi | ||
| 96 | done | ||
| 97 | |||
| 98 | a="/etc/ssl/certs" | ||
| 99 | if test -d "\$a" && ls "\$a"/[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f].0 >/dev/null 2>/dev/null; then | ||
| 100 | CAPATH="\$a" | ||
| 101 | fi | ||
| 102 | |||
| 83 | if [ -d "\$OECORE_NATIVE_SYSROOT/environment-setup.d" ]; then | 103 | if [ -d "\$OECORE_NATIVE_SYSROOT/environment-setup.d" ]; then |
| 84 | for envfile in \$OECORE_NATIVE_SYSROOT/environment-setup.d/*.sh; do | 104 | for envfile in \$OECORE_NATIVE_SYSROOT/environment-setup.d/*.sh; do |
| 85 | . \$envfile | 105 | . \$envfile |
| 86 | done | 106 | done |
| 87 | fi | 107 | fi |
| 108 | |||
| 88 | # We have to unset this else it can confuse oe-selftest and other tools | 109 | # We have to unset this else it can confuse oe-selftest and other tools |
| 89 | # which may also use the overlapping namespace. | 110 | # which may also use the overlapping namespace. |
| 90 | unset OECORE_NATIVE_SYSROOT | 111 | unset OECORE_NATIVE_SYSROOT CAFILE CAPATH |
| 91 | EOF | 112 | EOF |
| 92 | 113 | ||
| 93 | if [ "${SDKMACHINE}" = "i686" ]; then | 114 | if [ "${SDKMACHINE}" = "i686" ]; then |
diff --git a/meta/recipes-devtools/git/git/environment.d-git.sh b/meta/recipes-devtools/git/git/environment.d-git.sh index f8e3221510..9c7b5a9251 100644 --- a/meta/recipes-devtools/git/git/environment.d-git.sh +++ b/meta/recipes-devtools/git/git/environment.d-git.sh | |||
| @@ -1,4 +1,19 @@ | |||
| 1 | if [ -e "${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" ];then | 1 | # Respect host env GIT_SSL_CAINFO/GIT_SSL_CAPATH first, then auto-detected host cert, then cert in buildtools |
| 2 | export GIT_SSL_CAINFO="${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" | 2 | # CAFILE/CAPATH is auto-deteced when source buildtools |
| 3 | export BB_ENV_PASSTHROUGH_ADDITIONS="${BB_ENV_PASSTHROUGH_ADDITIONS:-} GIT_SSL_CAINFO" | 3 | if [ -z "$GIT_SSL_CAINFO" ]; then |
| 4 | if [ -n "$CAFILE" ];then | ||
| 5 | export GIT_SSL_CAINFO="$CAFILE" | ||
| 6 | elif [ -e "${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" ];then | ||
| 7 | export GIT_SSL_CAINFO="${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" | ||
| 8 | fi | ||
| 4 | fi | 9 | fi |
| 10 | |||
| 11 | if [ -z "$GIT_SSL_CAPATH" ]; then | ||
| 12 | if [ -n "$CAPATH" ];then | ||
| 13 | export GIT_SSL_CAPATH="$CAPATH" | ||
| 14 | elif [ -e "${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" ];then | ||
| 15 | export GIT_SSL_CAPATH="${OECORE_NATIVE_SYSROOT}/etc/ssl/certs" | ||
| 16 | fi | ||
| 17 | fi | ||
| 18 | |||
| 19 | export BB_ENV_PASSTHROUGH_ADDITIONS="${BB_ENV_PASSTHROUGH_ADDITIONS:-} GIT_SSL_CAINFO GIT_SSL_CAPATH" | ||
diff --git a/meta/recipes-devtools/python/python3-requests/environment.d-python3-requests.sh b/meta/recipes-devtools/python/python3-requests/environment.d-python3-requests.sh index c7faec127d..492177a9c3 100644 --- a/meta/recipes-devtools/python/python3-requests/environment.d-python3-requests.sh +++ b/meta/recipes-devtools/python/python3-requests/environment.d-python3-requests.sh | |||
| @@ -1,4 +1,11 @@ | |||
| 1 | if [ -e "${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" ];then | 1 | # Respect host env REQUESTS_CA_BUNDLE first, then auto-detected host cert, then cert in buildtools |
| 2 | export REQUESTS_CA_BUNDLE="${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" | 2 | # CAFILE/CAPATH is auto-deteced when source buildtools |
| 3 | export BB_ENV_PASSTHROUGH_ADDITIONS="${BB_ENV_PASSTHROUGH_ADDITIONS:-} REQUESTS_CA_BUNDLE" | 3 | if [ -z "$REQUESTS_CA_BUNDLE" ]; then |
| 4 | if [ -n "$CAFILE" ];then | ||
| 5 | export REQUESTS_CA_BUNDLE="$CAFILE" | ||
| 6 | elif [ -e "${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" ];then | ||
| 7 | export REQUESTS_CA_BUNDLE="${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" | ||
| 8 | fi | ||
| 4 | fi | 9 | fi |
| 10 | |||
| 11 | export BB_ENV_PASSTHROUGH_ADDITIONS="${BB_ENV_PASSTHROUGH_ADDITIONS:-} REQUESTS_CA_BUNDLE" | ||
diff --git a/meta/recipes-support/curl/curl/environment.d-curl.sh b/meta/recipes-support/curl/curl/environment.d-curl.sh index 0ab83a267d..7c2971b3da 100644 --- a/meta/recipes-support/curl/curl/environment.d-curl.sh +++ b/meta/recipes-support/curl/curl/environment.d-curl.sh | |||
| @@ -1,4 +1,19 @@ | |||
| 1 | if [ -e "${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" ];then | 1 | # Respect host env CURL_CA_BUNDLE/CURL_CA_PATH first, then auto-detected host cert, then cert in buildtools |
| 2 | export CURL_CA_BUNDLE="${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" | 2 | # CAFILE/CAPATH is auto-deteced when source buildtools |
| 3 | export BB_ENV_PASSTHROUGH_ADDITIONS="${BB_ENV_PASSTHROUGH_ADDITIONS:-} CURL_CA_BUNDLE" | 3 | if [ -z "$CURL_CA_PATH" ]; then |
| 4 | if [ -n "$CAFILE" ];then | ||
| 5 | export CURL_CA_BUNDLE="$CAFILE" | ||
| 6 | elif [ -e "${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" ];then | ||
| 7 | export CURL_CA_BUNDLE="${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" | ||
| 8 | fi | ||
| 4 | fi | 9 | fi |
| 10 | |||
| 11 | if [ -z "$CURL_CA_PATH" ]; then | ||
| 12 | if [ -n "$CAPATH" ];then | ||
| 13 | export CURL_CA_PATH="$CAPATH" | ||
| 14 | elif [ -e "${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" ];then | ||
| 15 | export CURL_CA_PATH="${OECORE_NATIVE_SYSROOT}/etc/ssl/certs" | ||
| 16 | fi | ||
| 17 | fi | ||
| 18 | |||
| 19 | export BB_ENV_PASSTHROUGH_ADDITIONS="${BB_ENV_PASSTHROUGH_ADDITIONS:-} CURL_CA_BUNDLE CURL_CA_PATH" | ||
