Class SniX509ExtendedKeyManager
- All Implemented Interfaces:
KeyManager
,X509KeyManager
A X509ExtendedKeyManager
that selects a key with an alias
retrieved from SNI information, delegating other processing to a nested X509ExtendedKeyManager.
Can only be used on server side.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Selects a certificate based on SNI information. -
Constructor Summary
ConstructorDescriptionSniX509ExtendedKeyManager
(X509ExtendedKeyManager keyManager, SslContextFactory.Server sslContextFactory) -
Method Summary
Modifier and TypeMethodDescriptionchooseClientAlias
(String[] keyType, Principal[] issuers, Socket socket) chooseEngineClientAlias
(String[] keyType, Principal[] issuers, SSLEngine engine) chooseEngineServerAlias
(String keyType, Principal[] issuers, SSLEngine engine) chooseServerAlias
(String keyType, Principal[] issuers, Socket socket) protected String
chooseServerAlias
(String keyType, Principal[] issuers, Collection<SNIMatcher> matchers, SSLSession session) getCertificateChain
(String alias) String[]
getClientAliases
(String keyType, Principal[] issuers) getPrivateKey
(String alias) String[]
getServerAliases
(String keyType, Principal[] issuers) void
setAliasMapper
(UnaryOperator<String> aliasMapper) Sets a function that transforms the alias into a possibly different alias, invoked when the SNI logic must choose the alias to pick the right certificate.
-
Constructor Details
-
SniX509ExtendedKeyManager
public SniX509ExtendedKeyManager(X509ExtendedKeyManager keyManager, SslContextFactory.Server sslContextFactory)
-
-
Method Details
-
getAliasMapper
- Returns:
- the function that transforms the alias
- See Also:
-
setAliasMapper
Sets a function that transforms the alias into a possibly different alias, invoked when the SNI logic must choose the alias to pick the right certificate.
This function is required when using the
PKIX KeyManagerFactory algorithm
which suffers from bug https://bugs.openjdk.java.net/browse/JDK-8246262, where aliases are returned by the OpenJDK implementation to the application in the formN.0.alias
whereN
is an always increasing number. Such mangled aliases won't match the aliases in the keystore, so that for example SNI matching will always fail.Other implementations such as BouncyCastle have been reported to mangle the alias in a different way, namely
0.alias.N
.This function allows to "unmangle" the alias from the implementation specific mangling back to just
alias
so that SNI matching will work again.- Parameters:
aliasMapper
- the function that transforms the alias
-
chooseClientAlias
-
chooseEngineClientAlias
- Overrides:
chooseEngineClientAlias
in classX509ExtendedKeyManager
-
chooseServerAlias
protected String chooseServerAlias(String keyType, Principal[] issuers, Collection<SNIMatcher> matchers, SSLSession session) -
chooseServerAlias
-
chooseEngineServerAlias
- Overrides:
chooseEngineServerAlias
in classX509ExtendedKeyManager
-
getCertificateChain
-
getClientAliases
-
getPrivateKey
-
getServerAliases
-