feature: protect ca addition from duplicate
This commit is contained in:
parent
5ef6c848ad
commit
901abd15d0
13
action.yml
13
action.yml
@ -8,7 +8,7 @@ inputs:
|
|||||||
description: 'root certificate to add to the truststore'
|
description: 'root certificate to add to the truststore'
|
||||||
required: true
|
required: true
|
||||||
alias-name:
|
alias-name:
|
||||||
description: "alias name of the new added certificate"
|
description: "alias name of the new added certificate, if not provided a random name is generate, beware with random name generated certificate is always inserted even if it already exist"
|
||||||
required: false
|
required: false
|
||||||
default: ""
|
default: ""
|
||||||
store-path:
|
store-path:
|
||||||
@ -49,5 +49,14 @@ runs:
|
|||||||
|
|
||||||
- name: Add certificate ${{ steps.generate-alias-name.outputs.alias-name }} to truststore
|
- name: Add certificate ${{ steps.generate-alias-name.outputs.alias-name }} to truststore
|
||||||
shell: bash
|
shell: bash
|
||||||
|
env:
|
||||||
|
does_not_exist_message: "does not exist"
|
||||||
run: |
|
run: |
|
||||||
echo "${{ inputs.ca-cert }}" | keytool -import -noprompt -trustcacerts -alias ${{ steps.generate-alias-name.outputs.alias-name }} -keystore ${{ inputs.store-path }} -storepass ${{ inputs.store-password }}
|
already_exists=$(keytool -list -alias ${{ steps.generate-alias-name.outputs.alias-name }} -keystore ${{ inputs.store-path }} -storepass ${{ inputs.store-password }} 2>/dev/null | grep "${{ env.does_not_exist_message }}" || true)
|
||||||
|
|
||||||
|
if [ ! -z "$already_exists" ];
|
||||||
|
then
|
||||||
|
echo "${{ inputs.ca-cert }}" | keytool -import -noprompt -trustcacerts -alias ${{ steps.generate-alias-name.outputs.alias-name }} -keystore ${{ inputs.store-path }} -storepass ${{ inputs.store-password }};
|
||||||
|
else
|
||||||
|
echo "Certificate ${{ steps.generate-alias-name.outputs.alias-name }} already contained in the truststore";
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user