I am trying to write an SSL client that sends mail using the javax.mail API. The problem I am having is that the server request that I use SSL, but the server is also configured with a non-standard SSL certificate. The web pages I have found say that I need to install the certificate into the trust store. I don't want to do that (I don't have the necessary permissions.)
- Is there a way to get Java to just ignore the certificate error and accept it?
- Failing that, is there a way to have the trust store be local for my program, and not installed for the whole JVM?
You need to create a fake TrustManager that accepts all certificates, and register it as a manager. Something like this:
Just add
-Dtrust_all_cert=true
to VM arguments. This argument tells java to ignore all certificate checks.Working code ( in jdk1.6.0_23) for #1.
Imports
The actual trust all TrustManager code.
Try this (answer to question 2):
You can also specify this as an additional command line parameter:
On Fedora this could be the system wide java trust store in
/etc/pki/java/cacerts
In Command Line you can add argument
-noCertificationCheck
to java to ignore the certificate checks.