Wednesday, September 17, 2008

How to WebTest a site using an invalid SSL certificate

UPDATE: there is a option you can pass to the config step which should achieve the same thing: useInsecureSSL


A very short post regarding an issue I recently came across while testing an application I'm working on.

My application needs to interface with and existing PHP application that uses SSL. To acceptance test this functionality I am writing a WebTest that drives both applications to assert information is flowing correctly between them.

Unfortunately the test instance of the PHP application I have been given to use has a self-signed SSL certificate which causes WebTest to fail with a SSLHandshakeException.

To ignore the self signed certificate, add the following line to your test:

groovy('step.context.currentWebClientContext.webClient.useInsecureSSL = true')