LostDeveloper
LostDeveloper

Reputation: 21

PostgreSQL connection error ONLY when attached to network

I have a .NET application on a client that connects to a PostgreSQL database using Npgsql library. The issue the client is having is that when trying to establish the connection from the client to the database, an error is thrown in the database log and a timeout error is displayed by the application:

08006: could not receive data from client: An existing connection was forcibly closed by the remote host.

This only happens if the computer is attached to a network. If no network is available, everything works fine.

Computer runs on Windows 7 32 bits

PostgreSQl version is 10.5 32 bits

Npgsql version 3.1.10

Connection is made using client certificates on port 5439

Any other test made in computers with the same characteristics (same Windows version, same RAM amount) do not throw any error and works with or without net connection.

Any suggestions?

Thank you very much.

Edit: Both Database and client are installed on the same computer and Windows Firewall is enabled and configured to allow 5439 traffic. Anyway, if Firewall is disabled the error is still there.

UPDATE:

I have noticed several CAPI2 errors on the Windows event viewer stating

A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.

Certificates used to connect to the database are self signed, and created on intallation time with a validity period of 10 years. They are not validated against any external provider or anything.

Upvotes: 1

Views: 248

Answers (1)

LostDeveloper
LostDeveloper

Reputation: 21

Finally found the cuase of the error. Windows did not trust the certificates due a lack of SHA2 support. Installed SHA2 support on Windows (KB4474419 and KB4490628) and everything worked again as it should.

Upvotes: 1

Related Questions