Skip to content

Commit

Permalink
certs: link host certs if present
Browse files Browse the repository at this point in the history
In certain cases, if host certificates are present at the path '/.bottlerocket/certs', we would link them to the
ca-trust and update-ca-trust process to pickup the new certificates.
  • Loading branch information
sumukhballal committed Jan 13, 2025
1 parent ac458da commit 2e1ceee
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions start_control_ssm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,21 @@ declare -r PERSISTENT_STORAGE_BASE_DIR="/.bottlerocket/host-containers/current"
declare -r USER_DATA="${PERSISTENT_STORAGE_BASE_DIR}/user-data"
declare -r SSM_AGENT_PERSISTENT_STATE_DIR="${PERSISTENT_STORAGE_BASE_DIR}/ssm"
declare -r SSM_AGENT_LOCAL_STATE_DIR="/var/lib/amazon/ssm"
declare -r HOST_CERTS="/.bottlerocket/certs"

log() {
echo "$*" >&2
}

# Link host certs if present into container & run update-ca-trust
link_host_certs() {
for cert in $(ls -1 "${HOST_CERTS}"); do
ln -s "${HOST_CERTS}/${cert}" "/etc/pki/ca-trust/source/anchors/${cert}"
done
# Update the CA trust to pickup the new certificates
update-ca-trust
}

enable_hybrid_env_ssm() {
# SSM parameters necessary to register with a hybrid activation
local activation_code
Expand Down Expand Up @@ -55,6 +65,8 @@ fetch_from_json() {
# then check to see if the user-data file contains ssm at the top-level. If so,
# attempt to manually register with SSM with a hybrid activation.

[[ -d "${HOST_CERTS}" ]] && link_host_certs

mkdir -p "${SSM_AGENT_PERSISTENT_STATE_DIR}"
chmod 750 "${SSM_AGENT_PERSISTENT_STATE_DIR}"

Expand Down

0 comments on commit 2e1ceee

Please sign in to comment.