Re: Changing the SSL socket factory for https:// URLs

Florian Weimer <[email protected]> Thu, 09 Jul 2009 07:26:53 +0000
Newsgroups gmane.comp.web.httpunit.devel
Message-ID <[email protected]>
* Wolfgang Fahl:

> Excellent. I've been looking for a solution for this for 
> a long time. Please bare with me if it will take a few 
> days before the changes show up in subversion.

Thanks.  For completeness, here's how to create a socket factory which
uses an anything-goes trust manager:

    public SSLSocketFactory getSocketFactory() throws Exception {
	final SSLContext context = SSLContext.getInstance("TLS");
	context.init(null, new X509TrustManager[] {
		new X509TrustManager() {
		    @Override
		    public void checkClientTrusted(X509Certificate[] arg0,
			    String arg1) throws CertificateException {
		    }

		    @Override
		    public void checkServerTrusted(X509Certificate[] arg0,
			    String arg1) throws CertificateException {
		    }

		    @Override
		    public X509Certificate[] getAcceptedIssuers() {
			return null;
		    }

		}}, null);
	return context.getSocketFactory();
    }

This could be added as a convenience method.

-- 
Florian Weimer                <[email protected]>
BFK edv-consulting GmbH       http://www.bfk.de/
Kriegsstraße 100              tel: +49-721-96201-1
D-76133 Karlsruhe             fax: +49-721-96201-99

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge