windows - java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty -
i have added certificate in keystore, , trying connect email exchange server using java code. when connect throws exception.
the same thing works fine when execute same java code in eclipse fails when execute same service fails.
here code:
public static void getemailconnection(string folder){ try{ store store = null; properties properties = system.getproperties(); folder emailfolder = null; final string ssl_factory = "javax.net.ssl.sslsocketfactory"; string host = "host name"; string username = "username";// change accordingly string password = "password";// change accordingly string mailstoretype = "pop3"; string port = "1234"; //set manual properties properties.setproperty("mail.pop3.socketfactory.class", ssl_factory); properties.setproperty("mail.pop3.socketfactory.fallback", "false"); properties.setproperty("mail.pop3.socketfactory.port", port); properties.setproperty("mail.store.protocol", mailstoretype); properties.setproperty("mail.pop3.host", host); properties.setproperty("mail.pop3.port", port); session emailsession = session.getdefaultinstance(properties); //create pop3 store object , connect pop server store = emailsession.getstore("pop3"); store.connect(host,1234,username, password); emailfolder = store.getfolder(folder); emailfolder.open(folder.read_only); }catch(exception e){ throw new bsfconstraintviolationexception("unable connect exchange server",e); } }
please find below stack trace.
caused by: java.lang.runtimeexception: unexpected error: java.security.invalidalgorithmparameterexception: trustanchors parameter must non-empty @ sun.security.validator.pkixvalidator.(pkixvalidator.java:90) @ sun.security.validator.validator.getinstance(validator.java:179) @ sun.security.ssl.x509trustmanagerimpl.getvalidator(x509trustmanagerimpl.java:314) @ sun.security.ssl.x509trustmanagerimpl.checktrustedinit(x509trustmanagerimpl.java:173) @ sun.security.ssl.x509trustmanagerimpl.checktrusted(x509trustmanagerimpl.java:186) @ sun.security.ssl.x509trustmanagerimpl.checkservertrusted(x509trustmanagerimpl.java:126) @ sun.security.ssl.clienthandshaker.servercertificate(clienthandshaker.java:1320) @ sun.security.ssl.clienthandshaker.processmessage(clienthandshaker.java:154) @ sun.security.ssl.handshaker.processloop(handshaker.java:868) @ sun.security.ssl.handshaker.process_record(handshaker.java:804) @ sun.security.ssl.sslsocketimpl.readrecord(sslsocketimpl.java:1032) @ sun.security.ssl.sslsocketimpl.performinitialhandshake(sslsocketimpl.java:1328) @ sun.security.ssl.sslsocketimpl.readdatarecord(sslsocketimpl.java:882) @ sun.security.ssl.appinputstream.read(appinputstream.java:102) ... 24 more
can 1 please me how resolve issue.
Comments
Post a Comment