Trusted certificate entries are not protected by java password

I have a .cer file provided by the other party. I need to create a saml account with this .cer file.

To do this, I imported the .cer file into the jks file using the following command. (The password is the same as the password. He asked from the invitation to accept the certificate. I gave y, then he said that the certificate was added to the keystore)

keytool -importcert -file xyz.cer -keystore test.jks -alias "testsp"

Then I used this jks file to create the credentials as shown below.

private Credential getCredential() { KeyStore keystore = readKeystoreFromFile("C:\\Users\\WTC\\Downloads\\icicistage\\test.jks", "password"); Map<String, String> passwordMap = new HashMap<String, String>(); passwordMap.put("testsp", "password"); KeyStoreCredentialResolver resolver = new KeyStoreCredentialResolver(keystore, passwordMap); Criteria criteria = new EntityIDCriteria("testsp"); CriteriaSet criteriaSet = new CriteriaSet(criteria); Credential credential = null; try { credential = resolver.resolveSingle(criteriaSet); } catch (SecurityException e) { e.printStackTrace(); } return credential; } private static KeyStore readKeystoreFromFile(String pathToKeyStore, String keyStorePassword) { try { KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType()); InputStream inputStream = new FileInputStream(pathToKeyStore); keystore.load(inputStream, keyStorePassword.toCharArray()); inputStream.close(); return keystore; } catch (Exception e) { throw new RuntimeException("Something went wrong reading keystore", e); } } 

The following line gives me the following error in the try block.

credential = resolver.resolveSingle (set criteria);

java.lang.UnsupportedOperationException: trusted certificate entries are not password protected

Can anyone help me solve this problem?

0
java keystore
Oct 27 '15 at 13:56 on
source share
1 answer

Solved a problem.

We do not need to enter a password on the password card. Because the certificate contains only the public key. He will not take the password.

The line is removed from the code and it works great.

  passwordMap.put("testsp", "password"); 
0
Oct 29 '15 at 4:14
source share



All Articles