Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom CA certificate support #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions elements/ca-certificate/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
==============
ca-certificate
==============
Add custom CA certifacte to the trusted CA bundle and update it.

`DIB_CUSTOM_CA_CERTIFICATE_URL`: URL to the custom CA certifacte
`DIB_CUSTOM_CA_CERTIFICATE_NAME`: The file name to use when saving the certifacte locally (optional)

If `DIB_CUSTOM_CA_CERTIFICATE_NAME` is not defined, the certifacte will be saved as `custom-ca`

For example:

.. code-block::

export DIB_CUSTOM_CA_CERTIFICATE_URL="https://www.example.org/custom.pem"
export DIB_CUSTOM_CA_CERTIFICATE_NAME="my-cert.pem"
4 changes: 4 additions & 0 deletions elements/ca-certificate/environment.d/ca-certificate
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

export CUSTOM_CA_CERTIFICATE_URL=${DIB_CUSTOM_CA_CERTIFICATE_URL:?"You must define DIB_CUSTOM_CA_CERTIFICATE_URL"}
export CUSTOM_CA_CERTIFICATE_NAME=${DIB_CUSTOM_CA_CERTIFICATE_NAME:-"custom-ca"}
15 changes: 15 additions & 0 deletions elements/ca-certificate/pre-install.d/00-03-copy-ca-certificate
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

if [ ${DIB_DEBUG_TRACE:-1} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail

if type dnf; then
curl -x "" -o /etc/pki/ca-trust/source/anchors/$CUSTOM_CA_CERTIFICATE_NAME $CUSTOM_CA_CERTIFICATE_URL
sudo update-ca-trust
else
curl -x "" -o /usr/local/share/ca-certificates/$CUSTOM_CA_CERTIFICATE_NAME $CUSTOM_CA_CERTIFICATE_URL
sudo update-ca-certificates
fi