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, we will 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.2
If this request goes through a proxy using a custom SSL certificate, without proper configuration, you will encounter an error like:
Status code was 404 and not [200]: HTTP Error 404: Not Found
This error is not due to a real “404 Not Found” issue but rather because Kibana does not 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 does not 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 specified using the NODE_EXTRA_CA_CERTS
variable.
NODE_EXTRA_CA_CERTS
openssl
command):
openssl s_client -showcerts -connect <proxy_host>:<proxy_port>
/etc/pki/tls/certs/ca-bundle.crt
NODE_EXTRA_CA_CERTS
environment variable to the configuration file or the startup script for Kibana.
/neteye/shared/kibana/conf/sysconfig/kibana-user-customization
NODE_EXTRA_CA_CERTS="/etc/pki/tls/certs/ca-bundle.crt"
sudo systemctl daemon-reload
sudo systemctl restart kibana-logmanager
journalctl -fu kibana-logmanager
Why Use NODE_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 secure connections while validating certificates correctly.
Conclusion
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 in this article, you can ensure that Kibana securely makes external requests through your proxy.