commons-http-clientでSSLの証明書を無視する設定

開発時のサンプル用に

	static final TrustManager IGNORE_ALL = new X509TrustManager() {
		@Override
		public X509Certificate[] getAcceptedIssuers() {
			return null;
		}
		
		@Override
		public void checkServerTrusted(X509Certificate[] chain, String authType)
				throws CertificateException {
			
		}
		
		@Override
		public void checkClientTrusted(X509Certificate[] chain, String authType)
				throws CertificateException {
			
		}
	};
	
	public static HttpClient createHttpClient() throws Exception{
		SSLContext tls = SSLContext.getInstance("TLS");
		tls.init(null,new TrustManager[]{IGNORE_ALL} , null);
		
		SSLSocketFactory sf = new SSLSocketFactory(
				tls,
			    SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
		
		HttpClient httpClient = new DefaultHttpClient();
		httpClient.getConnectionManager().getSchemeRegistry().unregister("https");
		httpClient.getConnectionManager().getSchemeRegistry().register(new Scheme("https",443,sf));
		
		return httpClient;
	}