npgsql driver sslmode missing verify-ca and verify-full -- PostgreSql - postgresql

As per links below, PostgreSql supports several ssl mode connections, but its ADO.net driver, npgsql does not support the modes verify-ca and verify-full, which are supported by the its JDBC driver.
Is there any reason for this?
Is it possible to use these modes somehow else?
PostgreSql docu
https://www.postgresql.org/docs/9.1/libpq-ssl.html
Npgsql driver docu
https://www.npgsql.org/doc/connection-string-parameters.html
JDBC driver docu
https://jdbc.postgresql.org/documentation/head/ssl-client.html

Npgsql will by default verify the server certificate, so SSL Mode=Require would correspond to libpq's verify-ca or verify-full (the documentation is not entirely clear on that).
From the documentation link in your question:
By default, Npgsql will validate your server's certificate; if you're using a self-signed certificate, this will fail. You can instruct Npgsql to ignore this by specifying Trust Server Certificate=true in the connection string. To precisely control how the server's certificate is validated, you can register UserCertificateValidationCallback on NpgsqlConnection (this works just like on .NET's SslStream).

Related

Is there GSSAPI encryption support in pg/pgx libraries?

So I am trying to connect to postgres in golang using GSSAPI (kerberos). Currently I am using pgx library along with gopgkrb5. I am successfully connecting and authenticating with gssapi, the only problem is - connection is not secure. When I edit pg_hba.conf to accept only secure gssapi connections, It does not work (no entry found for insecure connection). I read that postgres supports GSSAPI encryption, but It seems like pgx(pgconn in particular) does not support it. Am I wrong? Or, if not, does pq support it?

Quarkus reactive postgres connection URI when verify-ca

I want to connect my quarkus app to a postgres instance with the reactive pg client.
The authentication is made through a verify-ca ssl mode.
With jdbc, I was able to connect to the db with this URI:
jdbc:postgresql://my.host:5432/myDb?targetServerType=master&ssl=true&sslmode=verify-ca&sslcert=/path/to/cert&sslkey=/path/to/key&sslpassword=&sslrootcert=/path/to/rootcert
With the reactive client, I got this error with the same URI (without the jdbc prefix of course):
java.lang.IllegalArgumentException: Trust options must be specified under verify-full or verify-ca sslmode
at io.vertx.pgclient.impl.PgConnectionFactory.initializeConfiguration(PgConnectionFactory.java:69)
I tried to define the quarkus.datasource.reactive.postgresql.ssl-mode option to verify-ca but it does not work.
Can anyone help me on this ? Maybe I missed the documentation about the connection URI format but I dit not find anything relevant.
Thanks

Error to connect Postgresql DB from Oracle dblink using Oracle Database Gateway

I'm trying to connect from Oracle Database (dblink) to Postgresql database use Oracle Database Gateway (dg4msql 19), on the Oracle Database Gateway for MS SQL Server all work fine. On the Oracle DB create dblink, but when try to connect get Error message:
ORA-28500 Oracle ODBC SQL Server Wire Protocol driver Socket closed
08S01 Oracle ODBC SQL Server Wire protocol driver
The server does not support SSL {HY000} !
listener work, tnsnames.ora also give correct answer. May be in initdg4msql.ora file I have to use some string to connect without SSL?
HS_FDS_CONNECT_INFO = postgre_servet.net:5432//database - I don`t known that is correct for PostgreSQL, or for PostgreSQL should use only ODBC connection?
How correctly use HS_FDS_CONNECT_INFO = postgre_servet.net:5432//database, or for PostgreSQL should I use only ODBC connection?
The PostgreSQL server is not configured to accept SSL connections.
First, verify that PostgreSQL was built with SSL support: that can be seen from the output of pg_config --configure (should contain --with-openssl).
To configure SSL support, set ssl = on in postgresql.conf and provide a server certificate and private key (parameters ssl_vert_file and ssl_key_file). Reload PostgreSQL to activate.
For details, read the documentation.

Passing ssl certificates paths to PostgreSQL ODBC driver

I'm attempting to connect to a Postgres database that requires the client pass the paths to client and server SSL certificates using the ODBC driver for postgres. I'm using psqlodbc v11 x86 on Windows 10. I need to have three options passed to the ODBC driver sslrootcert, sslcert, and sslkey. I know that the paths are not being passed by the odbc driver since when I connect using the following connection string where I specify the pqopts it is able to connect.
Driver={PostgreSQL UNICODE};Server=XXXX;Port=5432;Database=XXXX;Uid=XXXX;Pwd=XXX;sslmode=verify-ca;pqopt={sslrootcert=C:\\ssl\\pgSQL.ca.cert sslcert=C:\\ssl\\pgSQL.cert sslkey=C:\\ssl\\pgSQL.key}
According to the document section
Advanced Options 3/3 Dialog Box->Libpq parameters, I should be able to pass the parameters by typing the values within the braces directly into the text box. It displays the error message saying that it cannot find the certificate because it is looking in the default location and is not using the value that was provided in the Libpq text box. Am I doing something wrong? Any advise on how to connect passing client certificates would be greatly appreciated.
Answering this in case anyone else finds this useful. The problem seems to be that the Test button on the ODBC Driver doesn't take the options set in the libpq parameters into account and just uses the default settings. When I saved the ODBC connection closed the ODBC Data Source Administrator window and used the connection from a different program it was able to connect successfully.

Postgres SSLMode Value "require" Invalid When SSL Support Is Not Compiled Using Foreign Data Wrapper

I'm attempting to connect to a remote server using a foreign data wrapper to transfer some data between databases but keey getting 'SSLMode Value "require" Invalid When SSL Support Is Not Compiled In'. These are the snippets I'm running:
CREATE SERVER remote FOREIGN DATA WRAPPER postgres_fdw
OPTIONS(dbname '...', host '...', port '...', sslmode 'require');
CREATE USER MAPPING FOR USER SERVER remote
OPTIONS (user '...', password '...');
CREATE FOREIGN TABLE remote.accounts (
...
);
SELECT * FROM remote.accounts;
DETAIL: sslmode value "require" invalid when SSL support is not compiled in
I've tried connecting into psql using "sslmode=require" - but that doesn't seem to help. I've also included sslmode as a flag when creating the server. The postgres instance I'm connecting to is on Heroku. The queries run if I connect to a different database on a remote server - but fail from my local database. How can I fix the SSL support is not compiled in?
The local PostgreSQL instance uses the local libpq library to connect to the remote instance.
If, at compile time, that library has been configured with --with-openssl (an option to pass to the top-level ./configure script of postgres source tree), then it gets dynamically linked to the openssl library and the call sites to encrypt a session are added.
If on the other hand, it was not configured with this option, the libpq produced doesn't have any SSL capability at all, and it's impossible with that library to connect to remote servers that require SSL.
According to the error message, you are in the second case.
The only way out of this problem is to replace your installed libpq library by another one that is compiled with SSL support, which also mean that you have OpenSSL installed on your system. Either compile it yourself or install it through packages depending on your preferences. In general pre-compiled versions of PostgreSQL tend to have SSL support enabled these days.
Even if libpq sources are inside the server's source, it's possible to compile them separately and use just that library independently of the rest.
There's a question on that: How to download, compile & install ONLY the libpq source on a server that DOES NOT have PostgreSQL installed