java - Establishing connection to HTTPS using client certificates -


i want upload file https-server using java. server not open url hence need client certificates establish connection. having .pem , .jks , .pkcs12 client certificate files.

can 1 suggest me how use certificate files in application establish communication ? need use 3 certificate files ?

the .jks file java keystore. should contain correct client certificates (and maybe intermediate certificates certificate chain).

i assume going write client uploads file https server? should use .jks file client certificate (let's apache) httpclient.

you need create sslcontext , load keystore

sslcontext sslcontext = sslcontexts.custom().loadtrustmaterial(new file("keystore", "yourpassword".tochararray(), new trustselfsignedstrategy()).build(); 

then have put sslcontextin sslconnectionsocketfactory

sslconnectionsocketfactory sslsf = new sslconnectionsocketfactory(sslcontext, new string[] { "tlsv1" }, null, sslconnectionsocketfactory.getdefaulthostnameverifier()); 

and build httpclient

httpclient httpclient = httpclients.custom().setsslsocketfactory(sslsf).build(); 

after these steps httpclient should use client certificate keystore desired request.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -