@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/8024")
@IgnoreJRERequirement
public final class AdvancedTlsX509TrustManager
extends javax.net.ssl.X509ExtendedTrustManager
X509ExtendedTrustManager that allows users to configure
advanced TLS features, such as root certificate reloading, peer cert custom verification, etc.
For Android users: this class is only supported in API level 24 and above.| Modifier and Type | Class and Description |
|---|---|
static class |
AdvancedTlsX509TrustManager.Builder |
static interface |
AdvancedTlsX509TrustManager.Closeable |
static interface |
AdvancedTlsX509TrustManager.SslSocketAndEnginePeerVerifier |
static class |
AdvancedTlsX509TrustManager.Verification |
| Modifier and Type | Method and Description |
|---|---|
void |
checkClientTrusted(java.security.cert.X509Certificate[] chain,
java.lang.String authType) |
void |
checkClientTrusted(java.security.cert.X509Certificate[] chain,
java.lang.String authType,
java.net.Socket socket) |
void |
checkClientTrusted(java.security.cert.X509Certificate[] chain,
java.lang.String authType,
javax.net.ssl.SSLEngine engine) |
void |
checkServerTrusted(java.security.cert.X509Certificate[] chain,
java.lang.String authType) |
void |
checkServerTrusted(java.security.cert.X509Certificate[] chain,
java.lang.String authType,
java.net.Socket socket) |
void |
checkServerTrusted(java.security.cert.X509Certificate[] chain,
java.lang.String authType,
javax.net.ssl.SSLEngine engine) |
java.security.cert.X509Certificate[] |
getAcceptedIssuers() |
static AdvancedTlsX509TrustManager.Builder |
newBuilder() |
void |
updateTrustCredentials(java.security.cert.X509Certificate[] trustCerts)
Updates the current cached trust certificates as well as the key store.
|
AdvancedTlsX509TrustManager.Closeable |
updateTrustCredentialsFromFile(java.io.File trustCertFile,
long period,
java.util.concurrent.TimeUnit unit,
java.util.concurrent.ScheduledExecutorService executor)
Schedules a
ScheduledExecutorService to read trust certificates from a local file path
periodically, and update the cached trust certs if there is an update. |
void |
useSystemDefaultTrustCerts()
Uses the default trust certificates stored on user's local system.
|
public void checkClientTrusted(java.security.cert.X509Certificate[] chain,
java.lang.String authType)
throws java.security.cert.CertificateException
java.security.cert.CertificateExceptionpublic void checkClientTrusted(java.security.cert.X509Certificate[] chain,
java.lang.String authType,
java.net.Socket socket)
throws java.security.cert.CertificateException
checkClientTrusted in class javax.net.ssl.X509ExtendedTrustManagerjava.security.cert.CertificateExceptionpublic void checkClientTrusted(java.security.cert.X509Certificate[] chain,
java.lang.String authType,
javax.net.ssl.SSLEngine engine)
throws java.security.cert.CertificateException
checkClientTrusted in class javax.net.ssl.X509ExtendedTrustManagerjava.security.cert.CertificateExceptionpublic void checkServerTrusted(java.security.cert.X509Certificate[] chain,
java.lang.String authType,
javax.net.ssl.SSLEngine engine)
throws java.security.cert.CertificateException
checkServerTrusted in class javax.net.ssl.X509ExtendedTrustManagerjava.security.cert.CertificateExceptionpublic void checkServerTrusted(java.security.cert.X509Certificate[] chain,
java.lang.String authType)
throws java.security.cert.CertificateException
java.security.cert.CertificateExceptionpublic void checkServerTrusted(java.security.cert.X509Certificate[] chain,
java.lang.String authType,
java.net.Socket socket)
throws java.security.cert.CertificateException
checkServerTrusted in class javax.net.ssl.X509ExtendedTrustManagerjava.security.cert.CertificateExceptionpublic java.security.cert.X509Certificate[] getAcceptedIssuers()
public void useSystemDefaultTrustCerts()
throws java.security.cert.CertificateException,
java.security.KeyStoreException,
java.security.NoSuchAlgorithmException
java.security.cert.CertificateExceptionjava.security.KeyStoreExceptionjava.security.NoSuchAlgorithmExceptionpublic void updateTrustCredentials(java.security.cert.X509Certificate[] trustCerts)
throws java.security.cert.CertificateException,
java.security.KeyStoreException,
java.security.NoSuchAlgorithmException,
java.io.IOException
trustCerts - the trust certificates that are going to be usedjava.security.cert.CertificateExceptionjava.security.KeyStoreExceptionjava.security.NoSuchAlgorithmExceptionjava.io.IOExceptionpublic AdvancedTlsX509TrustManager.Closeable updateTrustCredentialsFromFile(java.io.File trustCertFile, long period, java.util.concurrent.TimeUnit unit, java.util.concurrent.ScheduledExecutorService executor)
ScheduledExecutorService to read trust certificates from a local file path
periodically, and update the cached trust certs if there is an update.trustCertFile - the file on disk holding the trust certificatesperiod - the period between successive read-and-update executionsunit - the time unit of the initialDelay and period parametersexecutor - the execute service we use to read and update the credentialspublic static AdvancedTlsX509TrustManager.Builder newBuilder()