Why does not work `With CA Cert `

I configured Prometheus Datasource behind of self-signed tls Nginx proxy.
I got the following error.

But it works if …

  • checked Skip TLS Verify
  • curl --cacert /root/ca.crt https://localhost - https://localhost is nginx endpoint.

My Configuration

  • nginx.conf
$ cat /etc/Nginx/Nginx.conf
http {
  log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for" "$request_body"';
  server {
    listen                 443 ssl;
    server_name            localhost;
    ssl_certificate        /root/server.crt;
    ssl_certificate_key    /root/server.key;

    location / {
      proxy_pass http://localhost:9090/;
    }
  }
}

events {}
  • certifications
$ ln -s /root/ca.crt /root/"$(openssl x509 -hash -noout -in /root/ca.crt).0"
$ openssl verify -CApath /root /root/server.crt
/root/server.crt: OK
$ cat /root/ca.crt
-----BEGIN CERTIFICATE-----
MIIFAzCCAuugAwIBAgIUb/w9rveUgWxxJaQgB9F7tuOmNpEwDQYJKoZIhvcNAQEL
BQAwETEPMA0GA1UEAwwGcm9vdGNhMB4XDTIwMDIwMjE2MDI1N1oXDTIxMDIwMTE2
MDI1N1owETEPMA0GA1UEAwwGcm9vdGNhMIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
MIICCgKCAgEAuG5QOO4LmAOkgj1Y9o4Dfy0yYnO4MrPrWayP96huHLBqpz19YviQ
cr9YYrU5dydFS71StWuQObagzbFzV8ffZ9WngbuYtoKVLAcDBSYWYeNbVY2CaP6L
mytL1ftAi5weL1G3MbPCgLDdHkUhuXSKw+W35PqwnuuI3dCSzz8D/2LZ2XQS0EVW
q5URxhevfYA6UTvq/CqCma16JVk4fGBS1nLBtHz0WAIdwx6PcxAHtSNHDG74BLBP
vZPAZTXTHPEEpdat/6FMiexfLPN7svkPkriiJlR6ZDVo6xoPuFMrC5E9RtHEJS9z
mljnaO7GBKoVVOlvVWNo/4ny6+Ajkk612P9Kr38CIFnz5PcbHBu3d9IXHGG0E1h1
WXS0ENkFznPfpNtS76723j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ouzKraMgpwb63yeF
mnIVGilA3n/fBw7/ErH2mTR4m0/YuPi10/HWyJQZN9C7XFWv5Ymo
-----END CERTIFICATE-----

I solved.
It was caused by my code.
I created Prometheus datasource via Grafana API, but I sent the dashboard JSON data as a string value instead of a bool value. Such as

// wrong
"jsonData":{"httpMethod":"GET","tlsAuth":"true","tlsAuthWithCACert":"true"}
// correct
"jsonData":{"httpMethod":"GET","tlsAuth":true,"tlsAuthWithCACert":true}