envoy icon indicating copy to clipboard operation
envoy copied to clipboard

envoy is unable to validate certificates signed by Let's Encrypt

Open linnea-s opened this issue 4 years ago • 3 comments

Title: envoy is unable to validate certificates signed by Let's Encrypt

Description: Requests to TLS upstreams with letsencrypt signed certificates are failing with certificate validation enabled, with the logs reporting that a certificate has expired. However there are no expired certificates in the chain and no errors are reported by curl or Chrome for the same domain. The exact same configuration works for domains with TLS certificates that are not signed by letsencrypt.

I first came across this issue using TLS termination in istio 1.11.x. I believe this is the same issue seen in https://github.com/envoyproxy/envoy/issues/18510.

Repro steps:

  1. Start envoy with docker-compose up
  2. Send request to https://letsencrypt.org via envoy with curl http://localhost:10000

Config: docker-compose.yml:

version: '3'
services:
  envoy:
    image: envoyproxy/envoy-distroless:v1.21-latest
    ports:
      - "10000:10000"
    volumes:
      - ./envoy_issue.yml:/etc/envoy/envoy.yaml:ro,z
    command:
      - -c
      - /etc/envoy/envoy.yaml
      - -l
      - trace

envoy_issue.yml:

static_resources:
  listeners:
  - name: listener_0
    address:
      socket_address:
        address: 0.0.0.0
        port_value: 10000
    filter_chains:
    - filters:
      - name: envoy.filters.network.http_connection_manager
        typed_config:
          "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
          stat_prefix: ingress_http
          http_filters:
          - name: envoy.filters.http.router
          route_config:
            name: local_route
            virtual_hosts:
            - name: local_service
              domains: ["*"]
              routes:
              - match:
                  prefix: "/"
                route:
                  host_rewrite_literal: letsencrypt.org
                  cluster: letsencrypt.org
  clusters:
  - name: letsencrypt.org
    type: LOGICAL_DNS
    dns_lookup_family: V4_ONLY
    load_assignment:
      cluster_name: letsencrypt.org
      endpoints:
      - lb_endpoints:
        - endpoint:
            address:
              socket_address:
                address: letsencrypt.org
                port_value: 443
    transport_socket:
      name: envoy.transport_sockets.tls
      typed_config:
        "@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
        sni: letsencrypt.org
        common_tls_context:
          validation_context:
            trusted_ca:
              filename: /etc/ssl/certs/ca-certificates.crt
            match_typed_subject_alt_names:
            - san_type: DNS
              matcher:
                exact: letsencrypt.org

Logs:

[2022-02-25 14:11:55.027][15][debug][connection] [source/extensions/transport_sockets/tls/cert_validator/default_validator.cc:202] X509_verify_cert: certificate verification error at depth 3: certificate has expired
[2022-02-25 14:11:55.027][15][trace][connection] [source/extensions/transport_sockets/tls/ssl_handshaker.cc:52] [C3] ssl error occurred while read: SSL
[2022-02-25 14:11:55.027][15][debug][connection] [source/extensions/transport_sockets/tls/ssl_socket.cc:225] [C3] TLS error: 268435581:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED
[2022-02-25 14:11:55.027][15][debug][connection] [source/common/network/connection_impl.cc:249] [C3] closing socket: 0
[2022-02-25 14:11:55.027][15][debug][connection] [source/extensions/transport_sockets/tls/ssl_socket.cc:225] [C3] TLS error: 268435581:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED

linnea-s avatar Feb 25 '22 14:02 linnea-s

@ggreenway

yanavlasov avatar Feb 26 '22 00:02 yanavlasov

Duplicate of #18510

ggreenway avatar Feb 28 '22 18:02 ggreenway

Am getting this issue , is there any fix for it ?

crataristo4 avatar Jan 02 '25 09:01 crataristo4