0

When i run the below shell script it is throwing the below error. I tried to troubleshoot it but i am unable to find where is the unexpected token. Any help would be appreciated.

ERROR:

ssl-certs.sh: command substitution: line 13: syntax error near unexpected token `('
ssl-certs.sh: command substitution: line 13: `openssl pkcs12 -in <(base64 -d <<<"${application_tls_p12}") -passin "pass:${application_tls_password}" -passout "pass:${application_tls_password}")'

Shell script:

#!/bin/bash


chmod +x /home/ssm-user/client/ssl.sh
cmcs_resp=$(/home/ssm-user/client/ssl.sh request-cert)
sudo /home/ssm-user/client/ssl.sh install-trusted-certs
application_tls_p12=$(jq --raw-output ".pkcs12" <<<"${cmcs_resp}")
application_tls_password=$(jq --raw-output ".password" <<<"${cmcs_resp}")
if ! openssl_response=$(openssl pkcs12 -in <(base64 -d <<<"${application_tls_p12}") \
    -passin "pass:${application_tls_password}" \
    -passout "pass:${application_tls_password}"); then
echo "ERROR: Failed to extract private key and certificate from CMCS credential"
echo "${openssl_response}"
fi
application_tls_private_key=$(sed -n \
    -- '/^-----BEGIN ENCRYPTED PRIVATE KEY-----$/,/^-----END ENCRYPTED PRIVATE KEY-----$/p' \
    <<<"${openssl_response}")
application_tls_cert=$(sed -n \
    -- '/^-----BEGIN CERTIFICATE-----$/,/^-----END CERTIFICATE-----$/p' \
    <<<"${openssl_response}")
echo "${application_tls_private_key}" >/application-cert.key
echo "${application_tls_password}" >/application-cert.pass
echo "${application_tls_cert}" >/application-cert.pem
learning fun
  • 97
  • 1
  • 1
  • 5
  • 2
    This doesn't seem to be the actual script generating the error, because line 13 is just an `echo`. How are you running this? With `sh ssl-certs.sh` perhaps? It looks like you're using process substitution (`<(...)`), but not Bash. – Benjamin W. Sep 03 '21 at 20:08

1 Answers1

1

issue resolved after running the script with ./script-name instead of sh script-name

learning fun
  • 97
  • 1
  • 1
  • 5