Search code examples
c#asp.netpostgresqlnpgsql

Npgsql error: System.IO.IOException


I am trying to use Npgsql to use database connections with C# asp.net, but I get an error code whenever I run some code with a connection in it.

    An exception of type 'System.IO.IOException' occurred in Npgsql.dll but was not handled in user code

    Additional information: TlsClientStream.ClientAlertException: CertificateExpired

   at TlsClientStream.TlsClientStream.SendAlertFatal(AlertDescription description, String message)

   at TlsClientStream.TlsClientStream.ParseCertificateMessage(Byte[] buf, Int32& pos)

   at TlsClientStream.TlsClientStream.TraverseHandshakeMessages()

   at TlsClientStream.TlsClientStream.GetInitialHandshakeMessages(Boolean allowApplicationData)

   at TlsClientStream.TlsClientStream.PerformInitialHandshake(String hostName, X509CertificateCollection clientCertificates, RemoteCertificateValidationCallback remoteCertificateValidationCallback, Boolean checkCertificateRevocation)

I've used the Npgsql installer and tried with just referencing it,but nothing works,what am I missing? I am working in a school project so there is nothing wrong with the code, its something with my Npgsql.

Thanks in advance.


Solution

  • You can always try to use: Trust Server Certificate=True in your connection string