Java mail by SSL


如果没有设置证书,会出现以下Exception:
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

要解决这个问题,方法有两个:
1. java的启动参数添加 -Djavax.net.ssl.trustStore=/path/to/jssecacerts
2. Properties systemProps = System.getProperties();
   systemProps.put( "javax.net.ssl.trustStore", "/path/to/jssecerts");
   System.setProperties(systemProps);
 


参考:
http://www.rap.ucar.edu/staff/paddy/cacerts/index.html
http://code.google.com/p/java-use-examples/source/browse/trunk/src/com/aw/ad/util/InstallCert.java

你可能感兴趣的:(Java mail by SSL)