@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/8024") public final class AdvancedTlsX509KeyManager extends X509ExtendedKeyManager
X509ExtendedKeyManager
that allows users to configure
advanced TLS features, such as private key and certificate chain reloading, etc.Modifier and Type | Class and Description |
---|---|
static interface |
AdvancedTlsX509KeyManager.Closeable
Mainly used to avoid throwing IO Exceptions in java.io.Closeable.
|
Constructor and Description |
---|
AdvancedTlsX509KeyManager()
Constructs an AdvancedTlsX509KeyManager.
|
Modifier and Type | Method and Description |
---|---|
String |
chooseClientAlias(String[] keyType,
Principal[] issuers,
Socket socket) |
String |
chooseEngineClientAlias(String[] keyType,
Principal[] issuers,
SSLEngine engine) |
String |
chooseEngineServerAlias(String keyType,
Principal[] issuers,
SSLEngine engine) |
String |
chooseServerAlias(String keyType,
Principal[] issuers,
Socket socket) |
X509Certificate[] |
getCertificateChain(String alias) |
String[] |
getClientAliases(String keyType,
Principal[] issuers) |
PrivateKey |
getPrivateKey(String alias) |
String[] |
getServerAliases(String keyType,
Principal[] issuers) |
void |
updateIdentityCredentials(PrivateKey key,
X509Certificate[] certs)
Updates the current cached private key and cert chains.
|
void |
updateIdentityCredentialsFromFile(File keyFile,
File certFile)
Updates the private key and certificate chains from the local file paths.
|
AdvancedTlsX509KeyManager.Closeable |
updateIdentityCredentialsFromFile(File keyFile,
File certFile,
long period,
TimeUnit unit,
ScheduledExecutorService executor)
Schedules a
ScheduledExecutorService to read private key and certificate chains from
the local file paths periodically, and update the cached identity credentials if they are both
updated. |
public AdvancedTlsX509KeyManager() throws CertificateException
CertificateException
public PrivateKey getPrivateKey(String alias)
public X509Certificate[] getCertificateChain(String alias)
public String chooseClientAlias(String[] keyType, Principal[] issuers, Socket socket)
public String chooseEngineClientAlias(String[] keyType, Principal[] issuers, SSLEngine engine)
chooseEngineClientAlias
in class X509ExtendedKeyManager
public String chooseServerAlias(String keyType, Principal[] issuers, Socket socket)
public String chooseEngineServerAlias(String keyType, Principal[] issuers, SSLEngine engine)
chooseEngineServerAlias
in class X509ExtendedKeyManager
public void updateIdentityCredentials(PrivateKey key, X509Certificate[] certs)
key
- the private key that is going to be usedcerts
- the certificate chain that is going to be usedpublic AdvancedTlsX509KeyManager.Closeable updateIdentityCredentialsFromFile(File keyFile, File certFile, long period, TimeUnit unit, ScheduledExecutorService executor) throws IOException, GeneralSecurityException
ScheduledExecutorService
to read private key and certificate chains from
the local file paths periodically, and update the cached identity credentials if they are both
updated.keyFile
- the file on disk holding the private keycertFile
- the file on disk holding the certificate chainperiod
- 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 credentialsIOException
GeneralSecurityException
public void updateIdentityCredentialsFromFile(File keyFile, File certFile) throws IOException, GeneralSecurityException
keyFile
- the file on disk holding the private keycertFile
- the file on disk holding the certificate chainIOException
GeneralSecurityException