Programmatically adding a trusted cert in Java

Posted by directedition on Stack Overflow See other posts from Stack Overflow or by directedition
Published on 2010-05-04T16:21:26Z Indexed on 2010/05/05 1:08 UTC
Read the original article Hit count: 272

Filed under:
|
|

I use SSL to communicate between two components written in Java. I can't use a CA, so I have to self-sign everything. Unfortunately, this means that when I try to handshake, I get a SunCertPathBuilderException. I can create my own X509TrustManager that just trusts everything, but that sort of defeats the purpose of having a signed cert.

I would like, when first making the connection, to prompt the user with "SSL handshake with invalid cert. Add cert to store?" or something so they could have it added for them to their certificate store, like web browsers do at sites with invalid certs. I can find plenty of examples online of adding a cert to the store through the commandline, but I can't figure out how to do it programmatically. Is there a way to do this?

© Stack Overflow or respective owner

Related posts about java

Related posts about ssl