update-ca-trust 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. # At this time, while this script is trivial, we ignore any parameters given.
  3. # However, for backwards compatibility reasons, future versions of this script must
  4. # support the syntax "update-ca-trust extract" trigger the generation of output
  5. # files in $DEST.
  6. mkdir -p /etc/ssl/certs/java
  7. mkdir -p /etc/ssl/certs/edk2
  8. DEST=/etc/ca-certificates/update.d
  9. # Prevent p11-kit from reading user configuration files.
  10. export P11_KIT_NO_USER_CONFIG=1
  11. extract() {
  12. trust extract --overwrite "$@"
  13. }
  14. ## Simple PEM bundles
  15. extract --comment --format=pem-bundle --filter=ca-anchors --purpose=server-auth $DEST/tls-ca-bundle.pem
  16. extract --comment --format=pem-bundle --filter=ca-anchors --purpose=email $DEST/email-ca-bundle.pem
  17. extract --comment --format=pem-bundle --filter=ca-anchors --purpose=code-signing $DEST/objsign-ca-bundle.pem
  18. ## OpenSSL PEM bundle that includes trust flags
  19. extract --comment --format=openssl-bundle --filter=certificates $DEST/ca-bundle.trust.crt
  20. ## TianoCore EDK II bundle
  21. extract --format=edk2-cacerts --filter=ca-anchors --purpose=server-auth $DEST/edk2-cacerts.bin
  22. ## Java bundle
  23. extract --format=java-cacerts --filter=ca-anchors --purpose=server-auth /etc/ssl/certs/java/cacerts
  24. ## OpenSSL-style directory with individual PEM files and hash links
  25. # The directory-format extractors remove all files in the target directory, but not directories or files therein
  26. extract --format=pem-directory-hash --filter=ca-anchors --purpose=server-auth $DEST/cadir
  27. # We don't want to have to remove everything from the certs directory but neither
  28. # do we want to leave stale certs around, so only place symlinks in the real cadir
  29. for f in $DEST/cadir/*; do
  30. ln -fsr -t /etc/ssl/certs "$f"
  31. done
  32. # Now find and remove all broken symlinks
  33. find -L /etc/ssl/certs -maxdepth 1 -type l -delete