NishantKashyap
asked on
SSL + rest assured
I have to make a GET request in my rest assured framework to a path using SSL certificate, I am following this wiki https://github.com/jayway/rest-assured/wiki/Usage#ssl-config
generated my keystore jks file and used in my code like
I got this below error:-
groovy.lang.MissingMethodE xception: No signature of method: com.jayway.restassured.int ernal.http .AuthConfi g.certific ate() is applicable for argument types: (java.io.File, java.lang.String, java.lang.String, java.lang.Integer, null, org.apache.http.conn.ssl.A llowAllHos tnameVerif ier, null) values: [<my jks file path>,<password> jks, -1, ...]
Possible solutions: certificate(java.lang.Stri ng, java.lang.String, java.lang.String, int, java.security.KeyStore, org.apache.http.conn.ssl.X 509Hostnam eVerifier, org.apache.http.conn.ssl.S SLSocketFa ctory)
at org.codehaus.groovy.runtim e.ScriptBy tecodeAdap ter.unwrap (ScriptByt ecodeAdapt er.java:58 )
at org.codehaus.groovy.runtim e.callsite .PojoMetaC lassSite.c all(PojoMe taClassSit e.java:49)
at org.codehaus.groovy.runtim e.callsite .CallSiteA rray.defau ltCall(Cal lSiteArray .java:48)
at org.codehaus.groovy.runtim e.callsite .AbstractC allSite.ca ll(Abstrac tCallSite. java:113)
at com.jayway.restassured.aut henticatio n.CertAuth Scheme.aut henticate( CertAuthSc heme.groov y:35)
at com.jayway.restassured.aut henticatio n.Authenti cationSche me$authent icate.call (Unknown Source)
at org.codehaus.groovy.runtim e.callsite .CallSiteA rray.defau ltCall(Cal lSiteArray .java:48)
at org.codehaus.groovy.runtim e.callsite .AbstractC allSite.ca ll(Abstrac tCallSite. java:113)
at org.codehaus.groovy.runtim e.callsite .AbstractC allSite.ca ll(Abstrac tCallSite. java:125)
at com.jayway.restassured.int ernal.Requ estSpecifi cationImpl .sendReque st(Request Specificat ionImpl.gr oovy:1091)
at sun.reflect.NativeMethodAc cessorImpl .invoke0(N ative Method)
at sun.reflect.NativeMethodAc cessorImpl .invoke(Na tiveMethod Accesso
generated my keystore jks file and used in my code like
given().keystore(jksfilePath, password).spec(requestSpec.getRequestSpec()).when().get(urlPath);
I got this below error:-
groovy.lang.MissingMethodE
Possible solutions: certificate(java.lang.Stri
at org.codehaus.groovy.runtim
at org.codehaus.groovy.runtim
at org.codehaus.groovy.runtim
at org.codehaus.groovy.runtim
at com.jayway.restassured.aut
at com.jayway.restassured.aut
at org.codehaus.groovy.runtim
at org.codehaus.groovy.runtim
at org.codehaus.groovy.runtim
at com.jayway.restassured.int
at sun.reflect.NativeMethodAc
at sun.reflect.NativeMethodAc
Why don't you just import the cert into your existing cacerts? In theory, you shouldn't have to do anything after doing that
ASKER
I imported that cert in existing cacerts , and then made a GET call using rest assured , but there was a handshake failure. Moreover , I cant use this approach while running tests on a remote agent.
Well if there was a handshake failure, that would probably be for different reasons. Try running the app with the following JVM param set and post the trace here
-Djava.net.debug=ssl
ASKER
I used this command to run my test
gradle test --tests *SampleTest -Djava.net.debug=ssl
Log trace :- file attached
Please let me know if I am missing something.
logtrace
gradle test --tests *SampleTest -Djava.net.debug=ssl
Log trace :- file attached
Please let me know if I am missing something.
logtrace
ASKER
I am able to make a request to https://google.com/ by using this :
, which has a similar certificate as my website except that "No certificate transparency information was supplied by the server" message in my certificate.
given().config(RestAssured.config().sslConfig(sslConfig().relaxedHTTPSValidation("TLS"))).when().get(urlPath);
, which has a similar certificate as my website except that "No certificate transparency information was supplied by the server" message in my certificate.
ASKER
when I am trying to access that website through POSTMAN , a simple GET would return me the result without any other settings
and the same thing with java code throws - javax.net.ssl.SSLHandshake Exception: Received fatal alert: handshake_failure
and the same thing with java code throws - javax.net.ssl.SSLHandshake
given().when().get(urlPath);
ASKER
I did add the certificate under existing cacerts
didn't work. Trygradle test --tests *SampleTest -Djava.net.debug=ssl
gradle -Djava.net.debug=ssl test --tests *SampleTest
ASKER
same log trace with above command as well
Snippet:-
javax.net.ssl.SSLHandshake Exception: Received fatal alert: handshake_failure
at sun.security.ssl.Alerts.ge tSSLExcept ion(Alerts .java:192)
at sun.security.ssl.Alerts.ge tSSLExcept ion(Alerts .java:154)
at sun.security.ssl.SSLSocket Impl.recvA lert(SSLSo cketImpl.j ava:1979)
at sun.security.ssl.SSLSocket Impl.readR ecord(SSLS ocketImpl. java:1086)
at sun.security.ssl.SSLSocket Impl.perfo rmInitialH andshake(S SLSocketIm pl.java:13 32)
at sun.security.ssl.SSLSocket Impl.start Handshake( SSLSocketI mpl.java:1 359)
at sun.security.ssl.SSLSocket Impl.start Handshake( SSLSocketI mpl.java:1 343)
at org.apache.http.conn.ssl.S SLSocketFa ctory.conn ectSocket( SSLSocketF actory.jav a:535)
at org.apache.http.conn.ssl.S SLSocketFa ctory.conn ectSocket( SSLSocketF actory.jav a:403)
at org.apache.http.impl.conn. DefaultCli entConnect ionOperato r.openConn ection(Def aultClient Connection Operator.j ava:177)
at org.apache.http.impl.conn. ManagedCli entConnect ionImpl.op en(Managed ClientConn ectionImpl .java:304)
at org.apache.http.impl.clien t.DefaultR equestDire ctor.tryCo nnect(Defa ultRequest Director.j ava:611)
at org.apache.http.impl.clien t.DefaultR equestDire ctor.execu te(Default RequestDir ector.java :446)
at org.apache.http.impl.clien t.Abstract HttpClient .doExecute (AbstractH ttpClient. java:863)
at org.apache.http.impl.clien t.Closeabl eHttpClien t.execute( CloseableH ttpClient. java:82)
at org.apache.http.impl.clien t.Closeabl eHttpClien t.execute( CloseableH ttpClient. java:57)
at org.apache.http.client.Htt pClient$ex ecute$0.ca ll(Unknown Source)
at org.codehaus.groovy.runtim e.callsite .CallSiteA rray.defau ltCall(Cal lSiteArray .java:48)
at org.codehaus.groovy.runtim e.callsite .AbstractC allSite.ca ll(Abstrac tCallSite. java:113)
at org.codehaus.groovy.runtim e.callsite .AbstractC allSite.ca ll(Abstrac tCallSite. java:133)
Snippet:-
javax.net.ssl.SSLHandshake
at sun.security.ssl.Alerts.ge
at sun.security.ssl.Alerts.ge
at sun.security.ssl.SSLSocket
at sun.security.ssl.SSLSocket
at sun.security.ssl.SSLSocket
at sun.security.ssl.SSLSocket
at sun.security.ssl.SSLSocket
at org.apache.http.conn.ssl.S
at org.apache.http.conn.ssl.S
at org.apache.http.impl.conn.
at org.apache.http.impl.conn.
at org.apache.http.impl.clien
at org.apache.http.impl.clien
at org.apache.http.impl.clien
at org.apache.http.impl.clien
at org.apache.http.impl.clien
at org.apache.http.client.Htt
at org.codehaus.groovy.runtim
at org.codehaus.groovy.runtim
at org.codehaus.groovy.runtim
No. That's not it. This is the sort of thing you should be getting (in addition to your stack trace)
Incidentally, you will note that i have a similar exception so you should be able to produce an almost identical log
ssl-me.log
Incidentally, you will note that i have a similar exception so you should be able to produce an almost identical log
ssl-me.log
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
messaged you the log file
ASKER
Issue got fixed ... I updated to java 1.8 from 1.7 , thanks for pointing the debug option
ASKER
debug helped me to find the root cause and resolve the issue
:)