Package io.grpc.util
Class AdvancedTlsX509TrustManager
- java.lang.Object
-
- javax.net.ssl.X509ExtendedTrustManager
-
- io.grpc.util.AdvancedTlsX509TrustManager
-
- All Implemented Interfaces:
javax.net.ssl.TrustManager,javax.net.ssl.X509TrustManager
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/8024") @IgnoreJRERequirement public final class AdvancedTlsX509TrustManager extends javax.net.ssl.X509ExtendedTrustManagerAdvancedTlsX509TrustManager is anX509ExtendedTrustManagerthat 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAdvancedTlsX509TrustManager.Builderstatic interfaceAdvancedTlsX509TrustManager.Closeablestatic interfaceAdvancedTlsX509TrustManager.SslSocketAndEnginePeerVerifierstatic classAdvancedTlsX509TrustManager.Verification
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckClientTrusted(java.security.cert.X509Certificate[] chain, java.lang.String authType)voidcheckClientTrusted(java.security.cert.X509Certificate[] chain, java.lang.String authType, java.net.Socket socket)voidcheckClientTrusted(java.security.cert.X509Certificate[] chain, java.lang.String authType, javax.net.ssl.SSLEngine engine)voidcheckServerTrusted(java.security.cert.X509Certificate[] chain, java.lang.String authType)voidcheckServerTrusted(java.security.cert.X509Certificate[] chain, java.lang.String authType, java.net.Socket socket)voidcheckServerTrusted(java.security.cert.X509Certificate[] chain, java.lang.String authType, javax.net.ssl.SSLEngine engine)java.security.cert.X509Certificate[]getAcceptedIssuers()static AdvancedTlsX509TrustManager.BuildernewBuilder()voidupdateTrustCredentials(java.security.cert.X509Certificate[] trustCerts)Updates the current cached trust certificates as well as the key store.voidupdateTrustCredentialsFromFile(java.io.File trustCertFile)Updates the trust certificates from a local file path.AdvancedTlsX509TrustManager.CloseableupdateTrustCredentialsFromFile(java.io.File trustCertFile, long period, java.util.concurrent.TimeUnit unit, java.util.concurrent.ScheduledExecutorService executor)Schedules aScheduledExecutorServiceto read trust certificates from a local file path periodically, and update the cached trust certs if there is an update.voiduseSystemDefaultTrustCerts()Uses the default trust certificates stored on user's local system.
-
-
-
Method Detail
-
checkClientTrusted
public void checkClientTrusted(java.security.cert.X509Certificate[] chain, java.lang.String authType) throws java.security.cert.CertificateException- Throws:
java.security.cert.CertificateException
-
checkClientTrusted
public void checkClientTrusted(java.security.cert.X509Certificate[] chain, java.lang.String authType, java.net.Socket socket) throws java.security.cert.CertificateException- Specified by:
checkClientTrustedin classjavax.net.ssl.X509ExtendedTrustManager- Throws:
java.security.cert.CertificateException
-
checkClientTrusted
public void checkClientTrusted(java.security.cert.X509Certificate[] chain, java.lang.String authType, javax.net.ssl.SSLEngine engine) throws java.security.cert.CertificateException- Specified by:
checkClientTrustedin classjavax.net.ssl.X509ExtendedTrustManager- Throws:
java.security.cert.CertificateException
-
checkServerTrusted
public void checkServerTrusted(java.security.cert.X509Certificate[] chain, java.lang.String authType, javax.net.ssl.SSLEngine engine) throws java.security.cert.CertificateException- Specified by:
checkServerTrustedin classjavax.net.ssl.X509ExtendedTrustManager- Throws:
java.security.cert.CertificateException
-
checkServerTrusted
public void checkServerTrusted(java.security.cert.X509Certificate[] chain, java.lang.String authType) throws java.security.cert.CertificateException- Throws:
java.security.cert.CertificateException
-
checkServerTrusted
public void checkServerTrusted(java.security.cert.X509Certificate[] chain, java.lang.String authType, java.net.Socket socket) throws java.security.cert.CertificateException- Specified by:
checkServerTrustedin classjavax.net.ssl.X509ExtendedTrustManager- Throws:
java.security.cert.CertificateException
-
getAcceptedIssuers
public java.security.cert.X509Certificate[] getAcceptedIssuers()
-
useSystemDefaultTrustCerts
public void useSystemDefaultTrustCerts() throws java.security.cert.CertificateException, java.security.KeyStoreException, java.security.NoSuchAlgorithmExceptionUses the default trust certificates stored on user's local system. After this is used, functions that will provide new credential data(e.g. updateTrustCredentials(), updateTrustCredentialsFromFile()) should not be called.- Throws:
java.security.cert.CertificateExceptionjava.security.KeyStoreExceptionjava.security.NoSuchAlgorithmException
-
updateTrustCredentials
public void updateTrustCredentials(java.security.cert.X509Certificate[] trustCerts) throws java.io.IOException, java.security.GeneralSecurityExceptionUpdates the current cached trust certificates as well as the key store.- Parameters:
trustCerts- the trust certificates that are going to be used- Throws:
java.io.IOExceptionjava.security.GeneralSecurityException
-
updateTrustCredentialsFromFile
public AdvancedTlsX509TrustManager.Closeable updateTrustCredentialsFromFile(java.io.File trustCertFile, long period, java.util.concurrent.TimeUnit unit, java.util.concurrent.ScheduledExecutorService executor) throws java.io.IOException, java.security.GeneralSecurityException
Schedules aScheduledExecutorServiceto read trust certificates from a local file path periodically, and update the cached trust certs if there is an update.- Parameters:
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 credentials- Returns:
- an object that caller should close when the file refreshes are not needed
- Throws:
java.io.IOExceptionjava.security.GeneralSecurityException
-
updateTrustCredentialsFromFile
public void updateTrustCredentialsFromFile(java.io.File trustCertFile) throws java.io.IOException, java.security.GeneralSecurityExceptionUpdates the trust certificates from a local file path.- Parameters:
trustCertFile- the file on disk holding the trust certificates- Throws:
java.io.IOExceptionjava.security.GeneralSecurityException
-
newBuilder
public static AdvancedTlsX509TrustManager.Builder newBuilder()
-
-