When using Kibana in environments that require a proxy to reach external services, you might encounter issues with unrecognized SSL certificates. Specifically, if the proxy is exposed with its own certificate and acts as an SSL terminator, requests made by Kibana to external URLs can fail with HTTP status code errors. In this blog post, we’ll explore how to resolve this issue using the NODE_EXTRA_CA_CERTS environment variable.
Consider a scenario where Kibana tries to access the following URL:
https://epr.elastic.co/search?package=elastic_agent&prerelease=false&kibana.version=8.10.2If this request goes through a proxy using a custom SSL certificate, then without proper configuration you’ll encounter an error like:
Status code was 404 and not [200]: HTTP Error 404: Not FoundThis error is not due to a real 404 Not Found issue but rather because Kibana doesn’t recognize the proxy’s certificate. As a result, the Node.js client built into Kibana fails to establish a secure connection.
NODE_EXTRA_CA_CERTS VariableTo solve this issue, you can use the NODE_EXTRA_CA_CERTS environment variable provided by Node.js. This variable allows you to specify a file containing additional CA certificates that Node.js should trust.
It’s important to note that Kibana doesn’t automatically use the system’s trusted certificate chain. Even if the proxy’s certificate is added to the operating system’s certificate store, Kibana will not recognize it unless explicitly instructed to by using the NODE_EXTRA_CA_CERTS variable.
NODE_EXTRA_CA_CERTSopenssl command):
openssl s_client -showcerts -connect <proxy_host>:<proxy_port>/etc/pki/tls/certs/ca-bundle.crtNODE_EXTRA_CA_CERTS environment variable to the configuration file or the startup script for Kibana.
/neteye/shared/kibana/conf/sysconfig/kibana-user-customizationNODE_EXTRA_CA_CERTS="/etc/pki/tls/certs/ca-bundle.crt"sudo systemctl daemon-reloadsudo systemctl restart kibana-logmanagerjournalctl -fu kibana-logmanagerNODE_EXTRA_CA_CERTS?Using this variable is especially useful when you want to avoid completely disabling SSL verification (e.g., with the NODE_TLS_REJECT_UNAUTHORIZED=0 option), which poses a security risk. By specifying only the necessary certificates, you ensure connections are secure while still validating certificates correctly.
Configuring Kibana to work with a proxy exposed via a custom certificate might seem complex, but the NODE_EXTRA_CA_CERTS variable simplifies the process significantly. By following the steps outlined above, you can ensure that Kibana securely makes external requests through your proxy.