If I want to connect to a site which requires basic authentication and also uses a self signed cert I create a CredentialsProvider
which then lets me access the site.
If I want to access a site which uses a self signed cert I use the sslContextBuilder
and allow all certs to be used.
Each of the both work on their own but when I try to put them together to access a site that requires login and uses a self signed cert it wont let me.
I'm sure this is just simple syntax but how do I do this?
CloseableHttpClient hc = HttpClients.custom()
.setSslcontext(sslcb.build())
.setDefaultCredentialsProvider(credsProvider)
.build();
You may want to try setSSLSocketFactory
instead of setSslcontext
CloseableHttpClient httpclient = HttpClients.custom()
.setSSLSocketFactory(sslsf)
.setDefaultCredentialsProvider(credsProvider)
.build();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.