Estou tentando executar o arquivo .sh para colocar o certificado por meio do comando keytool em todos os arquivos jre / lib / security / cacert descritos no arquivo ~ / .java / deployment / deployment.properties.
#!/bin/bash
PATTERN=deployment\.javaws\.jre\.[0-9]*\.path
FILE=~/.java/deployment/deployment.properties
sep='='
trail=lib/security/cacerts
#Traverse file line by line
while read line ; do
#If line matches pattern
if printf %s\n "${line}" | grep -q "${PATTERN}"; then
case $line in
(*"$sep"*)
#Process line to get path for ../jre/lib/security/cacert file
after=${line#*"$sep"};
resultPath=${after%????????}${trail};
#This fails : no password asked and IOException showed
sudo bash -c keytool -import -v -trustcacerts -alias test-cert -file ./test.cer -keystore ${resultPath};
;;
(*)
;;
esac
fi
done < "$FILE"
Na linha
sudo bash -c keytool -import -v -trustcacerts -alias test-cert -file ./test.cer -keystore ${resultPath};
Deve estar pedindo senhas: 1º - senha do administrador por causa de sudo
e 2º - keystore
senha. Mas quando eu executo este script através de bash ./script.sh
, o shell pede apenas a senha de administrador e não é necessário keystore
. Como um resultado. Eu tenho esse erro:
Enter keystore password: keytool error: java.io.IOException: Keystore was tampered with, or password was incorrect
java.io.IOException: Keystore was tampered with, or password was incorrect
at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:772)
at sun.security.provider.JavaKeyStore$JKS.engineLoad(JavaKeyStore.java:55)
at java.security.KeyStore.load(KeyStore.java:1214)
at sun.security.tools.KeyTool.doCommands(KeyTool.java:885)
at sun.security.tools.KeyTool.run(KeyTool.java:340)
at sun.security.tools.KeyTool.main(KeyTool.java:333)
Caused by: java.security.UnrecoverableKeyException: Password verification failed
at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:770)
... 5 more
O que devo fazer pedindo keystore
senha?