envoy icon indicating copy to clipboard operation
envoy copied to clipboard

Dynamic forward proxy: can't disable certificate validation

Open ohkojai opened this issue 5 years ago • 2 comments

Hi all. Using Envoy 1.19.1 here. We've got a dynamic forward proxy setup, and sometimes our upstream hosts use self-signed certificates. In these situations, we need envoy to avoid validating those certs.

From the docs: https://www.envoyproxy.io/docs/envoy/v1.19.1/api-v3/extensions/transport_sockets/tls/v3/tls.proto.html

Server certificate verification is not enabled by default. Configure trusted_ca to enable verification.

Also from the docs: https://www.envoyproxy.io/docs/envoy/v1.19.1/api-v3/extensions/transport_sockets/tls/v3/common.proto#envoy-v3-api-msg-extensions-transport-sockets-tls-v3-certificatevalidationcontext

trusted_ca:
[...] If not specified and a peer certificate is presented it will not be verified.

So, we figured that if we left trusted_ca unconfigured, Envoy would not perform cert validation. Here's our transport_socket config; notice we've omitted the typed_config (and thus the trusted_ca key):

 transport_socket:
      name: envoy.transport_sockets.tls

However, this does not seem to work as we expected. When Envoy tries to connect to the upstream host, we get the following error:

upstream connect error or disconnect/reset before headers. reset reason: connection failure, transport failure reason: TLS error: 268435581:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED

Are the docs inaccurate? Are our assumptions about trusted_ca incorrect? Is there another way to make Envoy accept upstream self-signed certs?

Thank you!

ohkojai avatar Sep 04 '21 02:09 ohkojai

See this code:

https://github.com/envoyproxy/envoy/blob/cc1d41e7ee9fbfb7ee3c8f73724cdc41d7c6bbb0/source/extensions/clusters/dynamic_forward_proxy/cluster.cc#L183-L204

Which admittedly could be better documented. Basically auto_san_validation is turned on by default which I assume is what is failing. You will need to explicitly disable this and also enable allow_insecure_cluster_options.

mattklein123 avatar Sep 07 '21 02:09 mattklein123

After much investigation and hand-wringing, we discovered the following config field: trust_chain_verification, and set it to ACCEPT_UNTRUSTED. That did the trick! Thank you.

ohkojai avatar Sep 10 '21 19:09 ohkojai