0
votes

I am getting error: "javax.net.ssl.SSLPeerUnverifiedException: SSL peer failed hostname validation for name: null" while running the java application on my local machine.

I have created the key stores like following and added the jks file in classpath. Still the error is not resolved.

@Bean
public KeyManager keyManager() {
    DefaultResourceLoader loader = new DefaultResourceLoader();
    Resource storeFile = loader.getResource("classpath:samlKeystore.jks");
    String storePass = "password";
    Map<String, String> passwords = new HashMap<String, String>();
    passwords.put("username", "password");
    String defaultKey = "username";
    return new JKSKeyManager(storeFile, storePass, passwords, defaultKey);
}

Can anyone please help me with it ?

I am using Spring SAML as service provider and Salesforce as IdP.

1

1 Answers

0
votes

This is probably because the certificate is self-signed. For test purposes you can add your local CA to the trusted authorities:

keytool -list -keystore [...]/jre/lib/security/cacerts

For production the certificate should be signed by a recognised authority.