Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Npgsql 3.0.3 error with Power BI Desktop

I'm receiving the following error when connecting to an AWS Postgres database that requires SSL. I recently upgraded from npgsql 2.3.2 (which was buggy) to 3.0.3 which won't connect. Any suggestions would be appreciated.

DataSource.Error: TlsClientStream.ClientAlertException: CertificateUnknown: Server certificate was not accepted. Chain status: A certificate chain could not be built to a trusted root authority. . 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) Details: DataSourceKind=PostgreSQL

like image 299
Jon Capezzuto Avatar asked Oct 21 '15 02:10

Jon Capezzuto


4 Answers

Its not best way but worked for me since if u dont need encryption for security reason.

Go to Postgres config file on your DB server and go from

ssl = true

to

ssl = false

Then open your power bi desktop File-> Options and settings -> Data source settings -> then in global you will have saved your connection press Edit Permissions and uncheck "ENCRYPT CONNECTIONS"

Then it will work

WARNING: THIS IS NOT RECOMMENDED IF YOUR DB IS OPEN TO PUBLIC.

Regards,

Davlik

like image 67
Davlik Avatar answered Oct 29 '22 15:10

Davlik


I was able to fix the issue by installing the Amazon RDS public certificate on my machine. Once I did this, I was able to connect.

Steps I followed:

  1. Download the AWS RDS public certificate 1
  2. Create a .crt file from the .pem file downloaded. Sample instructions here 2
  3. Install the certificate (.crt file) on the machine. 3
  4. Connect!
like image 9
VinnyP Avatar answered Nov 20 '22 12:11

VinnyP


The docs from npgsql give the solution as changing the default trust server certificate of 'false' to 'true' in the connection string. Unfortunately, neither Excel (AFAIK) nor Power BI will allow you to edit the connection string. So if you are unable to get the SSL certificate from the DB admin (as suggested in another answer), or the SSL cert has a different server name to the name you connect to (in my case an IP address), there is not much that can be done.

I can see two ways of fixing this. Either Shay & co from npgsql (who are doing an excellent job btw) provide some way for users to change the default settings for the connection string parameters. Or Microsoft allows users to send keywords in the connection dialog of Power BI (and Excel).

like image 5
a-burge Avatar answered Nov 20 '22 10:11

a-burge


Npgsql 2.x didn’t perform validation on the server’s certificate by default, so self-signed certificate were accepted. The new default is to perform validation, which is probably why your connection is failing. Specify the Trust Server Certificate connection string parameter to get back previous behavior.

You can read more on the Npgsql security doc page, note also that this change is mentioned in our migration notes.

like image 3
Shay Rojansky Avatar answered Nov 20 '22 10:11

Shay Rojansky