Quantcast
Viewing all articles
Browse latest Browse all 1535

javax.net.ssl.SSLException: Certificate for doesn't match any of the subject alternative names: []

When I try to Hit the URL using Postman it works fine,by using my personal cert.But when I tried the same using Rest Assured test case it is throwing the above exception.

Configuration Class

public class Configuration {    protected SSLConfig config = null;    private static final Logger LOG = LoggerFactory.getLogger(Configuration.class);    @SuppressWarnings("deprecation")    @BeforeClass    public void setKeystore()    {        KeyStore keyStore = null;        KeyStore trustStore = null;        try {            String certPassword = System.getProperty("certPassword");            String certPath = System.getProperty("certPath");            String trustStorePassword = System.getProperty("trustStorePassword");            String trustStorePath = System.getProperty("trustStorePath");            Validate.notNull(certPath, "Path to Certificate on the file system cannot be null");            Validate.notEmpty(certPassword, "Password cannot be empty");            Validate.notNull(trustStorePath, "Path to trustStore on the file system cannot be null");            Validate.notEmpty(trustStorePassword, "TrustStore Password cannot be empty");            keyStore = KeyStore.getInstance("JKS");            keyStore.load(new FileInputStream(certPath), certPassword.toCharArray());            trustStore = KeyStore.getInstance("JKS");            trustStore.load(new FileInputStream(trustStorePath), trustStorePassword.toCharArray());            if (keyStore != null) {                org.apache.http.conn.ssl.SSLSocketFactory clientAuthFactory = new org.apache.http.conn.ssl.SSLSocketFactory(                        keyStore, certPassword, trustStore);                config = new SSLConfig().with().sslSocketFactory(clientAuthFactory).and().allowAllHostnames();            }            EnvironmentConstants.getEnvironment();        } catch (Exception e) {            LOG.error("Error while loading keystore");            e.printStackTrace();        }    }    @BeforeTest    public Properties loadproperties() {        InputStream input = getClass().getClassLoader().getResourceAsStream("errorMessages.properties");        Properties properties = new Properties();        try {            properties.load(input);        } catch (IOException e) {            e.printStackTrace();        }        return properties;    }}

Viewing all articles
Browse latest Browse all 1535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>