Mercurial > hg > Blog
diff content/Java/commons-httpclient-vs-self-signed-certs.md @ 98:1d9382b0329b
Specify the syntax on markdown blocks to avoid broken output that has class=err
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Thu, 19 Dec 2019 10:04:33 +0100 |
parents | ba3f2e5c6950 |
children |
line wrap: on
line diff
--- a/content/Java/commons-httpclient-vs-self-signed-certs.md Thu Dec 19 09:31:57 2019 +0100 +++ b/content/Java/commons-httpclient-vs-self-signed-certs.md Thu Dec 19 10:04:33 2019 +0100 @@ -9,16 +9,19 @@ Let's assume you already have a HttpClient instance at hand: + :::java HttpClient client = new DefaultHttpClient(); Now let's configure all the socket factories and stuff that's required to make HTTPS traffic with self signed certificates work: + :::java TrustStrategy trustStrategy = new TrustSelfSignedStrategy(); X509HostnameVerifier hostnameVerifier = SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER; SchemeSocketFactory socketFactory = new SSLSocketFactory(trustStrategy, hostnameVerifier); And now let's put it all together: + :::java Scheme https = new Scheme("https", 443, socketFactory); SchemeRegistry registry = client.getConnectionManager().getSchemeRegistry(); registry.register(https);