Skip to content

Commit cbf51a5

Browse files
refactor: enhance CA certificate splitting logic in entrypoint script
Updated the entrypoint script to improve the processing of CA certificates. The new implementation splits both bundled and individual .crt files into separate certificates, ensuring better organization and handling of custom CA certificates. This change enhances the robustness of the certificate setup process.
1 parent addd941 commit cbf51a5

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

deploy/docker/fs/opt/appsmith/entrypoint.sh

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -381,17 +381,18 @@ setup-custom-ca-certificates() (
381381
-srcstorepass changeit \
382382
-deststorepass changeit
383383

384-
# Process each certificate file
385-
find -L "$stacks_ca_certs_path" -maxdepth 1 -type f -o -type l -name '*.crt' | while read -r cert_file; do
386-
# For ca_bundle.crt, split into individual certificates
387-
if [[ "$(basename "$cert_file")" == "ca_bundle.crt" ]]; then
388-
# Split the bundle into individual certificates
389-
awk 'split_after==1{n++;split_after=0} /-----END CERTIFICATE-----/ {split_after=1} {print > ("'"$temp_cert_dir"'/cert" n ".crt")}' "$cert_file"
390-
else
391-
# For individual .crt files, just copy them
392-
cp "$cert_file" "$temp_cert_dir/cert$(basename "$cert_file")"
393-
fi
394-
done
384+
# Split every .crt file (bundle or single) into individual certs
385+
cert_index=0
386+
while read -r cert_file; do
387+
awk -v prefix="$temp_cert_dir/cert" -v ext=".crt" -v idx="$cert_index" '
388+
BEGIN {n=0}
389+
/-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/ {
390+
print > (prefix idx "_" n ext)
391+
if (/-----END CERTIFICATE-----/) n++
392+
}
393+
' "$cert_file"
394+
cert_index=$((cert_index + 1))
395+
done < <(find -L "$stacks_ca_certs_path" -maxdepth 1 -type f -o -type l -name '*.crt')
395396

396397
# Import all certificates from the temp directory
397398
find "$temp_cert_dir" -type f -name '*.crt' | while read -r cert_file; do

0 commit comments

Comments
 (0)