damu11782 / rest-assured

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

Setting keystore doesn't work #398

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I supply the keystore file but it doesn't work.. I also made a liitle java 
program to see if the keystore works at all.

openssl s_client -connect https://unity-unl-acc.powerhouse.local -starttls ssl 
> essent.cer

System.setProperty("javax.net.ssl.trustStore","/path/to/myKeystore");
System.setProperty("javax.net.ssl.trustStorePassword","password");

URL url = new URL("https://url.local");
URLConnection con = url.openConnection();
Reader reader = new InputStreamReader(con.getInputStream());
while (true) {
    int ch = reader.read();
    if (ch == -1) {
        break;
    }
    System.out.print((char) ch);
}

Gives expected output. (without keystore it does NOT)

My rest assured test look like this:

RestAssured.baseURI = getData().getUrl();
RestAssured.requestSpecification = new 
RequestSpecBuilder().log(LogDetail.ALL).setContentType(ContentType.JSON).build()
;
RestAssured.defaultParser = Parser.JSON;

/* Object creation */
Session session = new Session();
session.setGebruikersnaam("test1");
session.setWachtwoord("test1");

char[] password = "changeit".toCharArray();

FileInputStream fIn = new FileInputStream("path/to/myKeystore");
KeyStore keystore = KeyStore.getInstance("JKS");
keystore.load(fIn, password);

/* Rest call */
Response res = 
given().trustStore(keystore).body(session).post("/rest/session").then().extract(
).response();

and gives the following output:
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)
    at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1917)

What can be the cause of this? How to debug/fix this?

Any help is much appreciated! 

Original issue reported on code.google.com by dekleijn...@gmail.com on 28 Apr 2015 at 9:57

GoogleCodeExporter commented 9 years ago
..

Original comment by dekleijn...@gmail.com on 29 Apr 2015 at 12:51