summaryrefslogtreecommitdiffstats
path: root/abs/core/ca-certificates/update-ca-trust
blob: 53441b36707096d71527a46dd3eb0cf5a2b72af2 (plain)
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
#!/bin/bash

# At this time, while this script is trivial, we ignore any parameters given.
# However, for backwards compatibility reasons, future versions of this script must
# support the syntax "update-ca-trust extract" trigger the generation of output
# files in $DEST.

DEST=/etc/ca-certificates/extracted

# Prevent p11-kit from reading user configuration files.
export P11_KIT_NO_USER_CONFIG=1

extract() {
  trust extract --overwrite "$@"
}

## Simple PEM bundles
extract --comment --format=pem-bundle --filter=ca-anchors --purpose=server-auth  $DEST/tls-ca-bundle.pem
extract --comment --format=pem-bundle --filter=ca-anchors --purpose=email        $DEST/email-ca-bundle.pem
extract --comment --format=pem-bundle --filter=ca-anchors --purpose=code-signing $DEST/objsign-ca-bundle.pem

## OpenSSL PEM bundle that includes trust flags
extract --comment --format=openssl-bundle --filter=certificates $DEST/ca-bundle.trust.crt

## TianoCore EDK II bundle
extract --format=edk2-cacerts --filter=ca-anchors --purpose=server-auth $DEST/edk2-cacerts.bin

## Java bundle
extract --format=java-cacerts --filter=ca-anchors --purpose=server-auth /etc/ssl/certs/java/cacerts

## OpenSSL-style directory with individual PEM files and hash links
# The directory-format extractors remove all files in the target directory, but not directories or files therein
extract --format=pem-directory-hash --filter=ca-anchors --purpose=server-auth $DEST/cadir

# We don't want to have to remove everything from the certs directory but neither
# do we want to leave stale certs around, so only place symlinks in the real cadir
for f in $DEST/cadir/*; do
  ln -fsr -t /etc/ssl/certs "$f"
done

# Now find and remove all broken symlinks
find -L /etc/ssl/certs -maxdepth 1 -type l -delete