public class SslCertificateTruster
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
JAVAX_NET_SSL_TRUST_STORE |
static java.lang.String |
JAVAX_NET_SSL_TRUST_STORE_PASSWORD |
| Modifier and Type | Method and Description |
|---|---|
static void |
appendToTruststore(java.security.cert.X509Certificate[] chain)
Append the certificate to the JVM's currently used truststore.
|
static java.security.cert.X509Certificate[] |
getUntrustedCertificate(java.lang.String host,
int port,
int timeout)
Performs an SSL handshake with the given host and port, and if the JVM
does not trust the certificate presented during SSL handshake, return the
certificate chain, otherwise return null.
|
static void |
trustCertificate(java.lang.String host,
int port,
int timeout)
If the certificate at the specified host and port is untrusted, append
the untrusted certificate to the JVM's currently used truststore.
|
public static final java.lang.String JAVAX_NET_SSL_TRUST_STORE_PASSWORD
public static final java.lang.String JAVAX_NET_SSL_TRUST_STORE
public static java.security.cert.X509Certificate[] getUntrustedCertificate(java.lang.String host,
int port,
int timeout)
throws java.lang.Exception
host - port - timeout - socket timeout in millisecondsjava.lang.Exception - if the certificate chain could not be obtained during SSL
handshakepublic static void trustCertificate(java.lang.String host,
int port,
int timeout)
throws java.lang.Exception
host - port - timeout - java.lang.Exceptionpublic static void appendToTruststore(java.security.cert.X509Certificate[] chain)
throws java.security.NoSuchAlgorithmException,
java.security.KeyStoreException,
java.io.IOException,
java.security.cert.CertificateException,
java.io.FileNotFoundException
chain - java.security.NoSuchAlgorithmExceptionjava.security.KeyStoreExceptionjava.io.IOExceptionjava.security.cert.CertificateExceptionjava.io.FileNotFoundException