Package org.postgresql.ssl
Class BaseX509KeyManager
- java.lang.Object
-
- org.postgresql.ssl.BaseX509KeyManager
-
- All Implemented Interfaces:
javax.net.ssl.KeyManager,javax.net.ssl.X509KeyManager
- Direct Known Subclasses:
PEMKeyManager,PKCS12KeyManager
public abstract class BaseX509KeyManager extends java.lang.Object implements javax.net.ssl.X509KeyManager
-
-
Field Summary
Fields Modifier and Type Field Description protected PSQLExceptionerror
-
Constructor Summary
Constructors Constructor Description BaseX509KeyManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringchooseClientAlias(java.lang.String[] keyType, java.security.Principal[] principals, java.net.Socket socket)java.lang.StringchooseServerAlias(java.lang.String s, java.security.Principal[] principals, java.net.Socket socket)java.lang.String[]getClientAliases(java.lang.String keyType, java.security.Principal[] principals)java.lang.String[]getServerAliases(java.lang.String s, java.security.Principal[] principals)voidthrowKeyManagerException()getCertificateChain and getPrivateKey cannot throw exceptions, therefore any exception is stored inerrorand can be raised by this method.static voidvalidateKeyFilePermissions(java.nio.file.Path keyPath)Validates that the private key file has secure permissions, matching libpq behavior.
-
-
-
Field Detail
-
error
protected PSQLException error
-
-
Method Detail
-
throwKeyManagerException
public void throwKeyManagerException() throws PSQLExceptiongetCertificateChain and getPrivateKey cannot throw exceptions, therefore any exception is stored inerrorand can be raised by this method.- Throws:
PSQLException- if any exception is stored inerrorand can be raised
-
getClientAliases
public java.lang.String[] getClientAliases(java.lang.String keyType, java.security.Principal[] principals)- Specified by:
getClientAliasesin interfacejavax.net.ssl.X509KeyManager
-
chooseClientAlias
public java.lang.String chooseClientAlias(java.lang.String[] keyType, java.security.Principal[] principals, java.net.Socket socket)- Specified by:
chooseClientAliasin interfacejavax.net.ssl.X509KeyManager
-
getServerAliases
public java.lang.String[] getServerAliases(java.lang.String s, java.security.Principal[] principals)- Specified by:
getServerAliasesin interfacejavax.net.ssl.X509KeyManager
-
chooseServerAlias
public java.lang.String chooseServerAlias(java.lang.String s, java.security.Principal[] principals, java.net.Socket socket)- Specified by:
chooseServerAliasin interfacejavax.net.ssl.X509KeyManager
-
validateKeyFilePermissions
public static void validateKeyFilePermissions(java.nio.file.Path keyPath) throws PSQLExceptionValidates that the private key file has secure permissions, matching libpq behavior. On POSIX systems, root-owned files are allowed group-read access (up to 0640), since it's common for root to own certs and grant read access via group membership. Files owned by anyone else must be 0600 or stricter. On Windows, ACLs are checked to ensure only the owner and trusted system accounts have access.- Parameters:
keyPath- the path to the private key file- Throws:
PSQLException- if the file has insecure permissions
-
-