One usually thinks of SSL in the context of HTTPS, but there are also other protocols which rely on it to provide security. See this link for a short overview of SSL – it only mentions HTTPS, but the same applies for IMAPS, FTPS, etc – SSL is independent of the wrapped protocol. You can have issues with your Java programs in where the party you are communicating with provider changes their certificate and the program rejects it as invalid. The exception is something like:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException:
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException:
unable to find valid certification path to requested target
One cause of the problem can be that the server uses an SSL provider which is based on a root certificate that wasn’t included with the particular version of Java you are using (this is especially true for really old versions like Java 1.5). The issue can be solved by updating to the latest version, but it might be that this isn’t an option. Fortunately I found the following article: No more ‘unable to find valid certification path to requested target’
How to use it:
- Compile the program
javac InstallCert.java
- Run it with the target host/port. For example in our case it would be:
java InstallCert imap.mailprovider.com:993
(993 is the port for IMAPS) - navigate trough the menus and select which certificate to import
- now you have a file called
jssecacerts
. You need to copy this to$JAVA_HOME/jre/lib/security/cacerts
(back up the existing file first!) - Now the root certificate is imported (you can confirm this by rerunning InstallCert)
HTH