Accept concatenated PEM files for trustStore (aka make it easy to use SSL with Amazon RDS) #2459
Labels
Backlog
The topic in question has been recognized and added to development backlog
Enhancement
An enhancement to the driver. Lower priority than bugs.
Is your feature request related to a problem? If so, please give a short summary of the problem and how the feature would resolve it
To connect securely to a SQL Server instance, the trustStore connection property must point to a file that contains any necessary root certificate(s) and intermediate certificates. Currently, this file must be in the Java KeyStore (jks) or PKCS-12 (pk8/pfx) format. For databases hosted on Amazon RDS, however, these certificates are provided in a concatenated PEM format (
global-bundle.pem
which can be downloaded here).The problem is that there is no straightforward way to convert from PEM to an acceptable JKS or PKCS12 format when the original PEM file contains many concatenated certificates. One ends up needing a script or custom tool (referenced in this StackOverflow question) that splits up the individual certificates in the PEM file and inserts them into the keystore.
Describe the preferred solution
The MSSQL JDBC driver should accept a concatenated PEM file for the trustStore parameter (in addition to any previously supported formats).
Describe alternatives you've considered
For me, the working approach was the aforementioned script, which after fixing one bug, produced a JKS file that allowed me to connect to MSSQL on RDS with JDBC without
trustServerCertificate=true
. This is not an approach I can easily document to other users, however.The "easier" approach which did not work was the following command:
The resulting PFX file, while it does contain certificate data, was not in a form that worked as a keystore for the SQL Server JDBC driver. (Curiously, though, I was able to convert the working JKS file to a working PFX file with
keytool
.)Additional context
I came upon this problem while writing documentation for Ultorg, a graphical database tool. I need simple steps to get SSL working that works on MacOS, Linux, and Windows. So I can't provide scripts that won't work on Windows etc., and I can't depend on certificates living in the Windows-native certificate stores etc.
Reference Documentations/Specifications
https://learn.microsoft.com/en-us/sql/connect/jdbc/connecting-with-ssl-encryption?view=sql-server-ver16
Reference Implementation
The PostgreSQL JDBC driver does accept concatenated PEM files for the
sslrootcert
property (I successfully tried it withglobal-bundle.pem
from Amazon RDS). It looks like only a few lines of JDBC driver code would be needed to support it in the MSSQL JDBC driver. Basically:For comparison, the relevant code in the MSSQL JDBC driver is here.
The text was updated successfully, but these errors were encountered: