Using SQL_COPT_INMEMORY_TRUSTSTORECERT
- Last Updated: May 9, 2022
- 1 minute read
- DataDirect Connectors
- ODBC
- PostgreSQL 8.0
- Documentation
SQL_COPT_INMEMORY_TRUSTSTORECERT is a
pre-connection attribute that specifies the contents of the TLS/SSL certificates for TLS/SSL
server authentication. When using SQL_COPT_INMEMORY_TRUSTSTORECERT, the driver stores the certificate content in
memory, which eliminates the need to store the truststore file on the disk and lets
applications use TLS/SSL server authentication without any disk dependency.
Note: The certificate content can be specified
using the Trust Store (Truststore) connection option as well. However, if it is specified
using both Trust Store and
SQL_COPT_INMEMORY_TRUSTSTORECERT,
SQL_COPT_INMEMORY_TRUSTSTORECERT takes precedence over
Trust Store.The following example shows how to specify the contents of 3 certificates
using
SQL_COPT_INMEMORY_TRUSTSTORECERT:
SQLCHAR certificate[] = "
-----BEGIN CERTIFICATE-----12345abc-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----abcd123456-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----aabbcc11----END CERTIFICATE-----";
//The content of each certificate must be specified between -----BEGIN CERTIFICATE----- and -----END CERTIFICATE-----. Also, the number of dashes (-----) must be the same before and after both BEGIN CERTIFICATE and END CERTIFICATE.
...
SQLSetConnectAttr(dbc, SQL_COPT_INMEMORY_TRUSTSTORECERT, (SQLPOINTER)certificate, SQL_IS_POINTER);
ret = SQLDriverConnect(dbc, NULL,
(SQLCHAR*)"DSN=PostgreSQLWP_SSL;UID=jsmith;PWD=secret", SQL_NTS,
NULL, 0, NULL, SQL_DRIVER_NOPROMPT);