Package org.postgresql.ssl
Class Pk8OrPemKeyManager
java.lang.Object
org.postgresql.ssl.Pk8OrPemKeyManager
- All Implemented Interfaces:
KeyManager,X509KeyManager
A key manager that selects PEM when its header is found within the first 64 KiB
of the key file, and PK8/DER otherwise. This preserves libpq's preference for PEM
before DER, while using a bounded marker scan rather than parsing the key during
format detection.
The delegate is resolved lazily on the first call to any X509KeyManager
method, so this works regardless of which method the TLS engine calls first.
-
Constructor Summary
ConstructorsConstructorDescriptionPk8OrPemKeyManager(String keyFilePath, PEMKeyManager pem, LazyKeyManager pk8) -
Method Summary
Modifier and TypeMethodDescription@Nullable StringchooseClientAlias(String[] keyType, Principal @Nullable [] issuers, @Nullable Socket socket) @Nullable StringchooseServerAlias(String keyType, Principal @Nullable [] issuers, @Nullable Socket socket) X509Certificate @Nullable []getCertificateChain(String alias) String @Nullable []getClientAliases(String keyType, Principal @Nullable [] issuers) @Nullable PrivateKeygetPrivateKey(String alias) String @Nullable []getServerAliases(String keyType, Principal @Nullable [] issuers) voidPropagates any exception from the resolved delegate key manager, including an insecure-permission error detected while probing the key file.
-
Constructor Details
-
Pk8OrPemKeyManager
-
-
Method Details
-
getClientAliases
- Specified by:
getClientAliasesin interfaceX509KeyManager
-
chooseClientAlias
public @Nullable String chooseClientAlias(String[] keyType, Principal @Nullable [] issuers, @Nullable Socket socket) - Specified by:
chooseClientAliasin interfaceX509KeyManager
-
getServerAliases
- Specified by:
getServerAliasesin interfaceX509KeyManager
-
chooseServerAlias
public @Nullable String chooseServerAlias(String keyType, Principal @Nullable [] issuers, @Nullable Socket socket) - Specified by:
chooseServerAliasin interfaceX509KeyManager
-
getCertificateChain
- Specified by:
getCertificateChainin interfaceX509KeyManager
-
getPrivateKey
- Specified by:
getPrivateKeyin interfaceX509KeyManager
-
throwKeyManagerException
Propagates any exception from the resolved delegate key manager, including an insecure-permission error detected while probing the key file.- Throws:
PSQLException- if the delegate key manager has a stored exception
-