Skip to content

Commit e3bb181

Browse files
aafeijoo-susejohannbg
authored andcommitted
fix(url-lib): improve ca-bundle detection
The current detection routine for openssl-based libcurl assumes that libcurl has its own hardcoded path to the ca-bundle. Fix the cases where curl is compiled with: --with-ca-fallback --without-ca-path --without-ca-bundle In this case, we must also grep in OpenSSLs libcrypto. Other changes: - Filter reported but non-existant paths. - Strip nul bytes returned by grep. - Consider that ca-bundles might use '.pem' instead of '.crt'. Original-patch-by: Daniel Molkentin <[email protected]>
1 parent d9c3c77 commit e3bb181

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

modules.d/45url-lib/module-setup.sh

+13-6
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ depends() {
1515

1616
# called by dracut
1717
install() {
18-
local _dir _crt _found _lib _nssckbi _p11roots _p11root
18+
local _dir _crt _crts _found _lib _nssckbi _p11roots _p11root
1919
inst_simple "$moddir/url-lib.sh" "/lib/url-lib.sh"
2020
inst_multiple -o ctorrent
21-
inst_multiple curl
21+
inst_multiple curl sed
2222
if curl --version | grep -qi '\bNSS\b'; then
2323
# also install libs for curl https
2424
inst_libdir_file "libnsspem.so*"
@@ -29,21 +29,28 @@ install() {
2929

3030
for _dir in $libdirs; do
3131
[[ -d $dracutsysrootdir$_dir ]] || continue
32-
for _lib in "$dracutsysrootdir$_dir"/libcurl.so.*; do
32+
for _lib in "$dracutsysrootdir$_dir"/libcurl.so.* "$dracutsysrootdir$_dir"/libcrypto.so.*; do
3333
[[ -e $_lib ]] || continue
3434
if ! [[ $_nssckbi ]]; then
3535
read -r -d '' _nssckbi < <(grep -F --binary-files=text -z libnssckbi "$_lib")
3636
fi
37-
read -r -d '' _crt < <(grep -F --binary-files=text -z .crt "$_lib")
37+
read -r -d '' _crt < <(grep -E --binary-files=text -z "\.(pem|crt)" "$_lib" | sed 's/\x0//g')
3838
[[ $_crt ]] || continue
3939
[[ $_crt == /*/* ]] || continue
40+
if [[ -e $_crt ]]; then
41+
_crts="$_crts $_crt"
42+
_found=1
43+
fi
44+
done
45+
done
46+
if [[ $_found ]] && [[ -n $_crts ]]; then
47+
for _crt in $_crts; do
4048
if ! inst "${_crt#$dracutsysrootdir}"; then
4149
dwarn "Couldn't install '$_crt' SSL CA cert bundle; HTTPS might not work."
4250
continue
4351
fi
44-
_found=1
4552
done
46-
done
53+
fi
4754
# If we found no cert bundle files referenced in libcurl but we
4855
# *did* find a mention of libnssckbi (checked above), install it.
4956
# If its truly NSS libnssckbi, it includes its own trust bundle,

0 commit comments

Comments
 (0)