Skip to content

Commit 2c5517a

Browse files
pip25pip25sonrisa
andauthored
docs: touch up SSL keyfile documentation (#1836)
document differences between how PKCS-8 and PKCS-12 keyfiles are handled, and when the sslcert setting has an effect Co-authored-by: Papp István Péter <[email protected]>
1 parent 80d4ed3 commit 2c5517a

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

docs/documentation/head/connect.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,20 +120,22 @@ Connection conn = DriverManager.getConnection(url);
120120

121121
* **sslcert** = String
122122

123-
Provide the full path for the certificate file. Defaults to /defaultdir/postgresql.crt
123+
Provide the full path for the certificate file. Defaults to /defaultdir/postgresql.crt, where defaultdir is ${user.home}/.postgresql/ in *nix systems and %appdata%/postgresql/ on windows.
124124

125125
It can be a PEM encoded X509v3 certificate
126126

127-
*Note:* defaultdir is ${user.home}/.postgresql/ in *nix systems and %appdata%/postgresql/ on windows
127+
*Note:* This parameter is ignored when using PKCS-12 keys, since in that case the certificate is also retrieved from the same keyfile.
128128

129129
* **sslkey** = String
130130

131131
Provide the full path for the key file. Defaults to /defaultdir/postgresql.pk8.
132132

133-
*Note:* The key file **must** be in [PKCS-8](https://en.wikipedia.org/wiki/PKCS_8) [DER format](https://wiki.openssl.org/index.php/DER). A PEM key can be converted to DER format using the openssl command:
133+
*Note:* The key file **must** be in [PKCS-12](https://en.wikipedia.org/wiki/PKCS_12) or in [PKCS-8](https://en.wikipedia.org/wiki/PKCS_8) [DER format](https://wiki.openssl.org/index.php/DER). A PEM key can be converted to DER format using the openssl command:
134134

135135
`openssl pkcs8 -topk8 -inform PEM -in postgresql.key -outform DER -out postgresql.pk8 -v1 PBE-MD5-DES`
136136

137+
PKCS-12 key files are only recognized if they have the ".p12" (42.2.9+) or the ".pfx" (42.2.16+) extension.
138+
137139
If your key has a password, provide it using the `sslpassword` connection parameter described below. Otherwise, you can add the flag `-nocrypt` to the above command to prevent the driver from requesting a password.
138140

139141
*Note:* The use of -v1 PBE-MD5-DES might be inadequate in environments where high level of security is needed and the key is not protected

docs/documentation/head/ssl-client.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ In the case where the certificate validation is failing you can try `sslcert=` a
4040
not send the client certificate. If the server is not configured to authenticate using the certificate
4141
it should connect.
4242

43-
The location of the client certificate, client key and root certificate can be overridden with the
43+
The location of the client certificate, the PKCS-8 client key and root certificate can be overridden with the
4444
`sslcert`, `sslkey`, and `sslrootcert` settings respectively. These default to /defaultdir/postgresql.crt,
4545
/defaultdir/postgresql.pk8, and /defaultdir/root.crt respectively where defaultdir is
4646
${user.home}/.postgresql/ in *nix systems and %appdata%/postgresql/ on windows
4747

48-
as of version 42.2.9 PKCS12 is supported. In this archive format the key, cert and root cert are all
49-
in one file which by default is /defaultdir/postgresql.p12
48+
As of version 42.2.9 PKCS-12 is also supported. In this archive format the client key and the client
49+
certificate are in one file, which needs to be set with the `sslkey` parameter. For the PKCS-12 format
50+
to be recognized, the file extension must be ".p12" (supported since 42.2.9) or ".pfx" (since 42.2.16).
51+
(In this case the `sslcert` parameter is ignored.)
5052

5153
Finer control of the SSL connection can be achieved using the `sslmode` connection parameter.
5254
This parameter is the same as the libpq `sslmode` parameter and the currently SSL implements the

0 commit comments

Comments
 (0)