forked from istio/istio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch_cacerts.sh
executable file
·47 lines (33 loc) · 1.1 KB
/
fetch_cacerts.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
WD=$(dirname "$0")
WD=$(cd "$WD"; pwd)
set -o errexit
set -o nounset
set -o pipefail
# based on the following
# https://github.com/GoogleCloudPlatform/distroless/blob/master/cacerts/extract.sh
# https://packages.debian.org/buster/ca-certificates
# Latest available ca certs as of 2017-12-14
DEB_CACAERTS=http://ftp.de.debian.org/debian/pool/main/c/ca-certificates/ca-certificates_20170717_all.deb
DEB=ca-certs.deb
DEB_DIR=$(mktemp -d)
# outputs
# These files are packaged
CA_CERTS=${WD}/ca-certificates.tgz
function cleanup {
rm -rf "${DEB_DIR}"
}
trap cleanup exit
cd "${DEB_DIR}"
curl -s ${DEB_CACAERTS} --output ${DEB}
ar -x $DEB data.tar.xz
tar -xf data.tar.xz ./usr/share/ca-certificates
tar -xf data.tar.xz ./usr/share/doc/ca-certificates/copyright
# Concat all the certs.
CERT_FILE=./etc/ssl/certs/ca-certificates.crt
mkdir -p "$(dirname $CERT_FILE)"
# concat all certs
for cert in $(find usr/share/ca-certificates -type f | sort); do
cat "$cert" >> ${CERT_FILE}
done
tar -czf "${CA_CERTS}" --owner=0 --group=0 etc/ssl/certs/ca-certificates.crt usr/share/doc/ca-certificates/copyright