Hi Senthil,

Self-signed SSL certificates are not very fun in Java at all. I haven't
done any SSL testing in JWebUnit myself.

Do you need to check the SSL certificate at all, or could you just force
Java to accept all SSL certificates?

Normally I'd suggest importing your self-signed certificate as a trusted
certificate, but if you are failing at hostnames, that might not work. How
are you connecting to the site in JWebUnit?

You could check out the following SO answer:
http://stackoverflow.com/questions/7256955/java-sslexception-hostname-in-certificate-didnt-match

Alternatively, can you add "unknown" as a host for your self-signed
certificate?

Cheers
Jevon



On Wed, Jun 26, 2013 at 7:43 PM, Senthil <senthilprab...@gmail.com> wrote:

> Hi All
> I've been trying to use jWebUnit with a webpage with a self-signed
> certificate. I initially got the following exception for which I searched
> the web and found a solution in creating a TrustProvider (
> https://devcentral.f5.com/blogs/us/ssl-trust-provider-for-java#.Ucnl85zcOnI) 
> to
> bypass the certificate check
>
> Exception in thread "main" java.lang.RuntimeException:
> javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
>
> at
> net.sourceforge.jwebunit.htmlunit.HtmlUnitTestingEngineImpl.gotoPage(HtmlUnitTestingEngineImpl.java:260)
>
> at
> net.sourceforge.jwebunit.htmlunit.HtmlUnitTestingEngineImpl.beginAt(HtmlUnitTestingEngineImpl.java:212)
>
> at net.sourceforge.jwebunit.junit.WebTester.beginAt(WebTester.java:234)
>
> Then I bypassed the above exception and hit the following exception
>
> Exception in thread "main" java.lang.RuntimeException:
> javax.net.ssl.SSLException: hostname in certificate didn't match:
> <10.64.91.117> != <unknown>
>
> at
> net.sourceforge.jwebunit.htmlunit.HtmlUnitTestingEngineImpl.gotoPage(HtmlUnitTestingEngineImpl.java:260)
>
> at
> net.sourceforge.jwebunit.htmlunit.HtmlUnitTestingEngineImpl.beginAt(HtmlUnitTestingEngineImpl.java:212)
>
> at net.sourceforge.jwebunit.junit.WebTester.beginAt(WebTester.java:234)
> Caused by: javax.net.ssl.SSLException: hostname in certificate didn't
> match: <10.64.91.117> != <unknown>
>  at
> org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:228)
> at
> org.apache.http.conn.ssl.BrowserCompatHostnameVerifier.verify(BrowserCompatHostnameVerifier.java:54)
>  at
> org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:149)
> at
> org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:130)
> * at
> org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:572)
> *
> * at
> com.gargoylesoftware.htmlunit.HtmlUnitSSLSocketFactory.connectSocket(HtmlUnitSSLSocketFactory.java:171)
> *
>  at
> org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)
> at
> org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)
>  at
> org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:640)
> at
> org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:479)
>  at
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
> at
> com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:171)
>  at
> com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1484)
> at
> com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1402)
>  at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:304)
> at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:373)
>  at
> net.sourceforge.jwebunit.htmlunit.HtmlUnitTestingEngineImpl.gotoPage(HtmlUnitTestingEngineImpl.java:253)
>
> I followed the steps specified in the link
> http://life.neophi.com/danielr/2005/10/https_testing_with_jwebunit.html which
> suggested creating a "NullHostnameVerifier" to bypass the hostname
> verification and use it in combination with the above mentioned trust
> provider. It  DIDN'T work.
>
> Any suggestions on how to bypass the hostname verification is welcome.
>
> Thanks
> Senthil.
>
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Windows:
>
> Build for Windows Store.
>
> http://p.sf.net/sfu/windows-dev2dev
> _______________________________________________
> JWebUnit-users mailing list
> JWebUnit-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jwebunit-users
>
>
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
JWebUnit-users mailing list
JWebUnit-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jwebunit-users

Reply via email to