{"action":"created","issue":{"url":"https://api.github.com/repos/jayway/rest-assured/issues/359","labels_url":"https://api.github.com/repos/jayway/rest-assured/issues/359/labels{/name}","comments_url":"https://api.github.com/repos/jayway/rest-assured/issues/359/comments","events_url":"https://api.github.com/repos/jayway/rest-assured/issues/359/events","html_url":"https://github.com/jayway/rest-assured/issues/359","id":96242361,"number":359,"title":"Certificate authentication with own truststore doesn't work","user":{"login":"johanhaleby","id":187029,"avatar_url":"https://avatars.githubusercontent.com/u/187029?v=3","gravatar_id":"","url":"https://api.github.com/users/johanhaleby","html_url":"https://github.com/johanhaleby","followers_url":"https://api.github.com/users/johanhaleby/followers","following_url":"https://api.github.com/users/johanhaleby/following{/other_user}","gists_url":"https://api.github.com/users/johanhaleby/gists{/gist_id}","starred_url":"https://api.github.com/users/johanhaleby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johanhaleby/subscriptions","organizations_url":"https://api.github.com/users/johanhaleby/orgs","repos_url":"https://api.github.com/users/johanhaleby/repos","events_url":"https://api.github.com/users/johanhaleby/events{/privacy}","received_events_url":"https://api.github.com/users/johanhaleby/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jayway/rest-assured/labels/bug","name":"bug","color":"FFFFFF"},{"url":"https://api.github.com/repos/jayway/rest-assured/labels/imported","name":"imported","color":"FFFFFF"},{"url":"https://api.github.com/repos/jayway/rest-assured/labels/Priority-Medium","name":"Priority-Medium","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-21T06:45:53Z","updated_at":"2015-07-21T06:46:00Z","closed_at":null,"body":"_From [henrik.k...@gmail.com](https://code.google.com/u/101552491294560837468/) on November 12, 2012 11:49:19_\n\nWhat steps will reproduce the problem? 1. Do an request over https to a service with a certificate sign by a CA that's not in default cacerts 2. 3. What is the expected output? What do you see instead? What version of the product are you using? On what operating system? 1.7, Windows 7 Please provide any additional information below. Running this test class generates:\r\njavax.net.ssl.SSLPeerUnverifiedException: peer not authenticated\r\n\tat com.sun.net.ssl.internal.ssl.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:352)\r\n\tat org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:128)\r\n\tat org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:572)\r\n\tat org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:692)\r\n\tat org.apache.http.conn.scheme.SchemeSocketFactoryAdaptor.connectSocket(SchemeSocketFactoryAdaptor.java:65)\r\n\tat org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)\r\n\tat org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)\r\n\tat org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:640)\r\n\tat org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:479)\r\n\tat org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)\r\n\tat org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)\r\n\tat org.apache.http.client.HttpClient$execute.call(Unknown Source)\r\n\tat org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)\r\n\tat com.jayway.restassured.internal.RequestSpecificationImpl$RestAssuredHttpBuilder.doRequest(RequestSpecificationImpl.groovy:1341)\r\n\tat com.jayway.restassured.internal.http.HTTPBuilder.doRequest(HTTPBuilder.java:489)\r\n\tat com.jayway.restassured.internal.http.HTTPBuilder.request(HTTPBuilder.java:438)\r\n\tat com.jayway.restassured.internal.http.HTTPBuilder$request.call(Unknown Source)\r\n\tat org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)\r\n\tat com.jayway.restassured.internal.RequestSpecificationImpl.sendHttpRequest(RequestSpecificationImpl.groovy:917)\r\n\tat com.jayway.restassured.internal.RequestSpecificationImpl.this$2$sendHttpRequest(RequestSpecificationImpl.groovy)\r\n\tat com.jayway.restassured.internal.RequestSpecificationImpl$this$2$sendHttpRequest.callCurrent(Unknown Source)\r\n\tat org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)\r\n\tat com.jayway.restassured.internal.RequestSpecificationImpl.sendRequest(RequestSpecificationImpl.groovy:784)\r\n\tat com.jayway.restassured.internal.RequestSpecificationImpl.this$2$sendRequest(RequestSpecificationImpl.groovy)\r\n\tat com.jayway.restassured.internal.RequestSpecificationImpl$this$2$sendRequest.call(Unknown Source)\r\n\tat org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)\r\n\tat com.jayway.restassured.internal.filter.RootFilter.filter(RootFilter.groovy:28)\r\n\tat com.jayway.restassured.filter.Filter$filter.call(Unknown Source)\r\n\tat org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)\r\n\tat com.jayway.restassured.internal.filter.FilterContextImpl.next(FilterContextImpl.groovy:47)\r\n\tat com.jayway.restassured.filter.FilterContext$next.call(Unknown Source)\r\n\tat org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)\r\n\tat com.jayway.restassured.internal.RequestSpecificationImpl.invokeFilterChain(RequestSpecificationImpl.groovy:717)\r\n\tat com.jayway.restassured.internal.RequestSpecificationImpl$invokeFilterChain.callCurrent(Unknown Source)\r\n\tat org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)\r\n\tat com.jayway.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1106)\r\n\tat com.jayway.restassured.internal.RequestSpecificationImpl.this$2$applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy)\r\n\tat com.jayway.restassured.internal.RequestSpecificationImpl$this$2$applyPathParamsAndSendRequest.callCurrent(Unknown Source)\r\n\tat org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)\r\n\tat com.jayway.restassured.internal.RequestSpecificationImpl.get(RequestSpecificationImpl.groovy:127)\r\n\tat com.jayway.restassured.specification.RequestSender$get.call(Unknown Source)\r\n\tat org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)\r\n\tat com.jayway.restassured.internal.ResponseSpecificationImpl.get(ResponseSpecificationImpl.groovy:218)\r\n\tat se.pulsencombine.integration.externalservices.RestTestCase.testGetRoot(RestTestCase.java:59)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)\r\n\tat java.lang.reflect.Method.invoke(Method.java:597)\r\n\tat org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)\r\n\tat org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)\r\n\tat org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)\r\n\tat org.junit.internal.runners.statements.InvokeMethod.evaluate(Invoke...\n\n_Original issue: http://code.google.com/p/rest-assured/issues/detail?id=205_"},"comment":{"url":"https://api.github.com/repos/jayway/rest-assured/issues/comments/123188158","html_url":"https://github.com/jayway/rest-assured/issues/359#issuecomment-123188158","issue_url":"https://api.github.com/repos/jayway/rest-assured/issues/359","id":123188158,"user":{"login":"johanhaleby","id":187029,"avatar_url":"https://avatars.githubusercontent.com/u/187029?v=3","gravatar_id":"","url":"https://api.github.com/users/johanhaleby","html_url":"https://github.com/johanhaleby","followers_url":"https://api.github.com/users/johanhaleby/followers","following_url":"https://api.github.com/users/johanhaleby/following{/other_user}","gists_url":"https://api.github.com/users/johanhaleby/gists{/gist_id}","starred_url":"https://api.github.com/users/johanhaleby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johanhaleby/subscriptions","organizations_url":"https://api.github.com/users/johanhaleby/orgs","repos_url":"https://api.github.com/users/johanhaleby/repos","events_url":"https://api.github.com/users/johanhaleby/events{/privacy}","received_events_url":"https://api.github.com/users/johanhaleby/received_events","type":"User","site_admin":false},"created_at":"2015-07-21T06:46:00Z","updated_at":"2015-07-21T06:46:00Z","body":"_From [henrik.k...@gmail.com](https://code.google.com/u/101552491294560837468/) on November 21, 2012 09:33:11_\n\nI've managed to get this to work. You have to create a SSLSocketFactory with both a keystore and a truststore. I added this method to AuthConfig:\r\n\r\n\tpublic void certificate( String certURL, String password, String trustURL, String trustPassword ) \r\n\t\t\tthrows GeneralSecurityException, IOException {\r\n\t\t\r\n\t\tKeyStore keyStore = KeyStore.getInstance( KeyStore.getDefaultType() );\r\n        InputStream jksStream = new URL(certURL).openStream();\r\n        try {\r\n        \tkeyStore.load( jksStream, password.toCharArray() );\r\n        } finally { jksStream.close(); }\r\n\r\n\t\tKeyStore trustStore = KeyStore.getInstance( KeyStore.getDefaultType() );\r\n        jksStream = new URL(trustURL).openStream();\r\n        try {\r\n        \ttrustStore.load( jksStream, trustPassword.toCharArray() );\r\n        } finally { jksStream.close(); }\r\n                \r\n        SSLSocketFactory ssl = new SSLSocketFactory(keyStore, password, trustStore);\r\n        ssl.setHostnameVerifier( SSLSocketFactory.STRICT_HOSTNAME_VERIFIER );\r\n        \r\n        builder.getClient().getConnectionManager().getSchemeRegistry()\r\n        \t.register( new Scheme(\"https\", ssl, 443) );\r\n\t}\r\n\r\nI now changed the beforeClass() method like this:\r\n\t@BeforeClass\r\n\tpublic static void beforeClass() throws Exception {\r\n\t\tfinal CertAuthWithTrustStoreScheme scheme = new CertAuthWithTrustStoreScheme();\r\n        scheme.setCertURL(AbstractExternalServicesFunctionalTestCase.class.getClassLoader().getResource(\"client.jks\").toString());\r\n        scheme.setPassword(\"xdr537\");\r\n        scheme.setTrustURL(AbstractExternalServicesFunctionalTestCase.class.getClassLoader().getResource(\"trust.jks\").toString());\r\n        scheme.setTrustPassword(\"changeit\");\r\n        RestAssured.authentication = scheme;\r\n\t\tRestAssured.baseURI = \"https://localhost/\";\r\n\t\tRestAssured.port = 443;\r\n\t}\r\n\r\nThe best would be if you could use the keystore set by RestAssured.keystore(), but I didn't found a way to do that...\n\n**Attachment:** [CertAuthWithTrustStoreScheme.groovy AuthConfig.java](http://code.google.com/p/rest-assured/issues/detail?id=205#hc2)"}}