title: Check whether certificate alias is already present
body: <p>I am implementing a shell script which will create a new self signed certificate using keytool command. Below is the command that I use to create the certificate </p>
  
  <pre><code>    echo "# Creating key and Self Signed Certificate"
      keytool -genkey -alias cert -keyalg RSA -storepass "${KEYSTORE_PASS}" -keypass         "${KEY_PASS}" -keystore cert/keystore.jks -validity 3650 -keysize 1024 -dname "C=${CNTRY}, ST=${ST}, L=${LOC}, O=${ORG}, OU=Certificates, CN=${ORG} SEURAT Certificate Authority"
  </code></pre>
  
  <p>exit_on_error $?</p>
  
  <p>For password and other subject information I am getting input from user. Now this command fails if alias name already exists. I can delete the alias using </p>
  
  <pre><code>    keytool -delete -alias 1 -keystore cert/keystore.jks
  </code></pre>
  
  <p>But the above command fails if alias name doesnt present. So how can I check in shell script if alias name present then delete the certificate and create new in its name , or just create it ?</p>