try {
/*
* Open the trust store, prompting the user if needed for a valid
* password to use.
*/
AsadminTruststore truststore = AsadminTruststore.newInstance();
// if the certificate already exists in the truststore,
// it is implicitly trusted
if (!truststore.certificateExists(chain[0])) {
// if the certificate does not exist in the truststore,
// then we prompt the user. Upon confirmation from the user,
// the certificate is added to the truststore.
if (isItOKToAddCertToTrustStore(chain[0])) {
truststore.addCertificate(getAliasName(), chain[0]);
} else {
throw new CertificateException(strmgr.get(
"serverCertificateNotTrusted"));
}
}