title: trusted certificate entries are not password-protected java
body: <p>I have a .cer file provided from some other party. I need to create a saml credential with this .cer file.</p>
  
  <p>For this, I imported .cer file to jks file using following command. ( Password is same as password. It asked from prompt to accept certificate. I gave y then it said certificate is added to keystore )</p>
  
  <p><strong>keytool -importcert -file xyz.cer -keystore test.jks -alias "testsp"</strong></p>
  
  <p>Then I used this jks file to create credential as below.</p>
  
  <pre><code>    private Credential getCredential() {
            KeyStore keystore = readKeystoreFromFile("C:\\Users\\WTC\\Downloads\\icicistage\\test.jks", "password");
            Map&lt;String, String&gt; passwordMap = new HashMap&lt;String, String&gt;();
            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);
          }
      }
  </code></pre>
  
  <p>The below line gives me the following error in try block.</p>
  
  <p>credential = resolver.resolveSingle(criteriaSet);</p>
  
  <p><strong>java.lang.UnsupportedOperationException: trusted certificate entries are not password-protected</strong></p>
  
  <p>Can anyone please guide me to solve this issue ?</p>