Java ignore certificate validation -



Java ignore certificate validation -

i'm trying create sample java projects connect self-signed https server. can't seem java stop trying validate certificate. don't want have trust certificate, want ignore certificate validation altogether; server within network , want able run test apps without worrying whether certificate valid.

java -dcom.sun.net.ssl.checkrevocation=false helloworld org.apache.axis2.axisfault: connection has been shutdown: javax.net.ssl.sslhandshakeexception: sun.security.validator.validatorexception: pkix path building failed: sun.security.provider.certpath.suncertpathbuilderexception: unable find valid certification path requested target

the -dcom.sun.net.ssl.checkrevocation=false didn't help. tried adding next code:

public static void disablecertificatevalidation() { trustmanager[] trustallcerts = new trustmanager[]{ new x509trustmanager() { public x509certificate[] getacceptedissuers() { homecoming null; } public void checkclienttrusted(x509certificate[] certs, string authtype) { } public void checkservertrusted(x509certificate[] certs, string authtype) { } } }; seek { sslcontext sc = sslcontext.getinstance("ssl"); sc.init(null, trustallcerts, new java.security.securerandom()); httpsurlconnection.setdefaultsslsocketfactory(sc.getsocketfactory()); } grab (exception e) { } }

but still have same issue. what's going on here?

org.apache.axis2.axisfault indicates you're using axis 2, , axis 2 doesn't utilize httpsurlconnection create http(s) connections, apache httpclient (3.x far know), httpsurlconnection.setdefaultsslsocketfactory(...) have no effect there.

you can have @ this answer setting sslcontext axis 2, more specifically, document: http://axis.apache.org/axis2/java/core/docs/http-transport.html#httpsupport

(alternatively, may able away setting default sslcontext sslcontext.setdefault(...), introduced in java 6. disabling certificate verification default ssl context not thought in real application.)

java ssl-certificate

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -