error fetching from postgres, err: x509: certificate signed by unknown authority

Kishor 0 Reputation points
2024-07-05T07:21:57.52+00:00

i have i virtual network where in 1 subnet my aks cluster is present and another subnet my private postgress flexible server is present.

i am connecting my application from aks cluster to private postgress server through private network using "sslmode=require" ,
while trying to connect i am getting error in my application pod "error fetching from postgres, err: x509: certificate signed by unknown authority"

PostgreSQL version : 16.3

can you tell me how to solve this error, do i need to add any certificate if yes then in which place ?

Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,146 questions
Azure Database for PostgreSQL
{count} votes

1 answer

Sort by: Most helpful
  1. Amira Bedhiafi 26,186 Reputation points
    2024-07-05T22:42:43.51+00:00

    Based on this article :

    To have a CA certificate available to the client Certification needs to be added to the system or it can be supplied via -ca-cert/-ca-path or related environmental variables.

    We can apply these two ways: 

    • Use either the environment variable VAULT_CACERT or the vault CLI flag -ca-cert=with a value that is the full path to the PEM encoded CA certificate file
    • Use either the environment variable VAULT_CAPATH, or the vault CLI flag -ca-path= with a value that is the full path to a directory containing certificates including that of the relevant CA

    If we like to disable checking for testing purposes we can use  tls_skip_verify

    Disable verification of TLS certificates. Using this option is highly discouraged.

    https://support.hashicorp.com/hc/en-us/articles/8107320508947-x509-certificate-signed-by-unknown-authority

    https://stackoverflow.com/questions/23615411/postgresql-pq-open-not-successful-x509-certificate-signed-by-unknown-authority


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.