Skip to content

Commit a74530b

Browse files
committed
feat: RHTAP-4382 Add support for custom root CA for secure connections
This commit introduces the ability to use a custom root CA certificate for secure connections in various scripts. This is achieved by: - Adding a `CUSTOM_ROOT_CA` variable to the GitHub Actions workflow and `ghub-set-vars` script. - Implementing an `addRootCert` function in `acs-deploy-check.sh`, `buildah-rhtap.sh`, and `cosign-sign-attest.sh` to install the custom CA certificate if provided. - Adding support for `CUSTOM_ROOT_CA` in `download-sbom-from-url-in-attestation.sh` - Updating the templates to include the new variable.
1 parent 419ab84 commit a74530b

File tree

7 files changed

+35
-1
lines changed

7 files changed

+35
-1
lines changed

generated/source-repo/githubactions/.github/workflows/build-and-update-gitops.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ env:
2626
# NEXUS_IO_CREDS_USR: ${{ vars.NEXUS_IO_CREDS_USR }}
2727
# Used to verify the image signature and attestation
2828
COSIGN_PUBLIC_KEY: ${{ vars.COSIGN_PUBLIC_KEY }}
29+
# Custom Root CA to be used in scripts as trusted
30+
CUSTOM_ROOT_CA: ${{ vars.CUSTOM_ROOT_CA }}
2931
# Secrets
3032
ROX_API_TOKEN: ${{ secrets.ROX_API_TOKEN }}
3133
GITOPS_AUTH_PASSWORD: ${{ secrets.GITOPS_AUTH_PASSWORD }}

hack/ghub-set-vars

100644100755
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,7 @@ set_variable TRUSTIFICATION_OIDC_CLIENT_ID "$TRUSTIFICATION_OIDC_CLIENT_ID"
6363
set_variable TRUSTIFICATION_SUPPORTED_CYCLONEDX_VERSION "$TRUSTIFICATION_SUPPORTED_CYCLONEDX_VERSION"
6464
set_secret TRUSTIFICATION_OIDC_CLIENT_SECRET "$TRUSTIFICATION_OIDC_CLIENT_SECRET"
6565

66+
set_variable CUSTOM_ROOT_CA $CUSTOM_ROOT_CA
67+
6668
echo
6769
echo "All variables and secrets are set."

rhtap/common.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ prepare-registry-user-pass() {
4848
fi
4949
}
5050

51+
function addRootCert() {
52+
if [ ! -z "$CUSTOM_ROOT_CA" ]; then
53+
echo "Using provided CA bundle"
54+
echo "$CUSTOM_ROOT_CA" > /etc/pki/ca-trust/source/anchors/ca-bundle.crt
55+
update-ca-trust
56+
fi
57+
}
58+
5159
# Performs an image registry login. It takes a single parameter which could be either an image
5260
# registry, e.g. quay.io, or a full image reference, e.g. quay.io/spam/bacon:crispy.
5361
function registry-login() {
@@ -81,3 +89,5 @@ export PATH=$PATH:/usr/local/bin
8189

8290
# env.sh comes from the users repo in rhtap/env.sh
8391
source $DIR/rhtap/env.sh
92+
93+
addRootCert

rhtap/download-sbom-from-url-in-attestation.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ source "$SCRIPTDIR"/common.sh
4040
: "${IGNORE_REKOR=false}"
4141
: "${TUF_MIRROR=}"
4242

43+
# Import custom certificate if set.
44+
if [ ! -z "$CUSTOM_ROOT_CA" ]; then
45+
echo "Using provided CA bundle"
46+
echo "$CUSTOM_ROOT_CA" > /etc/pki/ca-trust/source/anchors/ca-bundle.crt
47+
update-ca-trust
48+
fi
49+
4350
# Set script-local variables
4451
WORKDIR=$(mktemp -d --tmpdir "download-sbom-workdir.XXXXXX")
4552

rhtap/env.template.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export IMAGE=${IMAGE-$IMAGE_URL}
1111

1212
export DOCKERFILE=${DOCKERFILE-${{ values.dockerfile }}}
1313
export CONTEXT=${CONTEXT-${{ values.buildContext }}}
14-
export TLSVERIFY=${TLSVERIFY-false}
14+
export TLSVERIFY=${TLSVERIFY-true}
1515
export BUILD_ARGS=${BUILD_ARGS-""}
1616
export BUILD_ARGS_FILE=${BUILD_ARGS_FILE-""}
1717

@@ -49,6 +49,8 @@ export EFFECTIVE_TIME=${EFFECTIVE_TIME-now}
4949
export HOMEDIR=${HOMEDIR-$(pwd)}
5050
export TUF_MIRROR=${TUF_MIRROR-http://tuf.tssc-tas.svc}
5151

52+
export CUSTOM_ROOT_CA=${CUSTOM_ROOT_CA-""}
53+
5254
# Allow PR to succeed even if TAS vars not configured
5355
export FAIL_IF_TRUSTIFICATION_NOT_CONFIGURED=false
5456

rhtap/upload-sbom-to-trustification.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ source "$SCRIPTDIR"/common.sh
3939
: "${TRUSTIFICATION_OIDC_CLIENT_SECRET=}"
4040
: "${TRUSTIFICATION_SUPPORTED_CYCLONEDX_VERSION=}"
4141

42+
# Import custom certificate if set.
43+
if [ ! -z "$CUSTOM_ROOT_CA" ]; then
44+
echo "Using provided CA bundle"
45+
echo "$CUSTOM_ROOT_CA" > /etc/pki/ca-trust/source/anchors/ca-bundle.crt
46+
update-ca-trust
47+
fi
48+
4249
# Set script-local variables
4350
WORKDIR=$(mktemp -d --tmpdir "upload-sbom-workdir.XXXXXX")
4451
trap 'rm -r "$WORKDIR"' EXIT

templates/data.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ build_variables:
7171
commented_out: true
7272
comment: Used to verify the image signature and attestation
7373

74+
- name: CUSTOM_ROOT_CA
75+
comment: Custom Root CA to be used in scripts as trusted
76+
optional: true
77+
7478
build_secrets:
7579
- name: ROX_API_TOKEN
7680

0 commit comments

Comments
 (0)