java - HTTP Request with Certificate -
how can hit url using certificate, can not throw exception. must have include certificate. suggest me demo example. able read certificate how can hit url using certificate..
import java.io.fileinputstream; import java.io.filenotfoundexception; import java.net.httpurlconnection; import java.security.cert.certificateexception; import java.security.cert.certificatefactory; import java.security.cert.x509certificate; public class httpcert { public static void main(string[] args) { fileinputstream is; try { = new fileinputstream("/home/devel-p/android/pki/ca.crt"); certificatefactory x509certfact = certificatefactory.getinstance("x.509"); x509certificate cert = (x509certificate)x509certfact.generatecertificate(is); system.out.println(cert); } catch (filenotfoundexception e) { e.printstacktrace(); } catch (certificateexception e) { e.printstacktrace(); } }
the ssl connection sends client certificate if server asks it, , certificate mandatory if server decides. can't control of client end.
Comments
Post a Comment