lilinkevin / rest-assured

Automatically exported from code.google.com/p/rest-assured
0 stars 0 forks source link

SunCertPathBuilderException thrown because given().trustStore() seems to be ignored #347

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

given().trustStore() doesn't work as expected.

When I do

  System.setProperty("javax.net.ssl.trustStore", "jssecacerts.jks");
  System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
  given()
    .get("/oauth/authorize");

the test goes green. However, when I set truststore only per given request:

    KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
    trustStore.load(new FileInputStream(new File("jssecacerts.jks")), "changeit".toCharArray());
    given()
      .trustStore(trustStore)
      .get("/oauth/authorize");

I get exception

  javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)

Why is it returning this error?

What version of the product are you using? On what operating system?

RestAssured 2.3.2, JDK 1.8, OSX 10.9.4

Please provide any additional information below.

Original issue reported on code.google.com by mgawine...@gmail.com on 19 Aug 2014 at 6:15

GoogleCodeExporter commented 9 years ago
There's a test in SSLITest that looks like this:

@Test public void
allows_specifying_trust_store_in_dsl() throws Exception {
    InputStream keyStoreStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("truststore_cloudamqp.jks");
    KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
    keyStore.load(keyStoreStream, "cloud1234".toCharArray());

    given().trustStore(keyStore).then().get("https://bunny.cloudamqp.com/api/").then().statusCode(200);
}

And it works. So I'm not sure what is wrong on your part. You can use the 
SslConfig to configure additional details if required.

Original comment by johan.ha...@gmail.com on 29 Aug 2014 at 11:32

GoogleCodeExporter commented 9 years ago
Closing because no response

Original comment by johan.ha...@gmail.com on 23 Sep 2014 at 9:07

GoogleCodeExporter commented 9 years ago

Original comment by johan.ha...@gmail.com on 23 Sep 2014 at 9:08