jcmoraisjr / haproxy-ingress

HAProxy Ingress
https://haproxy-ingress.github.io
Apache License 2.0
1.03k stars 269 forks source link

mTLS support without using sni #786

Open ndbemmanuel opened 3 years ago

ndbemmanuel commented 3 years ago

Is it possible to add support to have mutual TLS authentication without having SNI support. We have deployed devices that need to have mutual TLS authentication and doesn’t support SNI. We did get a somewhat working solution by having the following config :

bind-https: ":443 ssl crt /var/lib/haproxy/crt/sw0081-dev_sw0081-srv.pem.pem ca-file /var/lib/haproxy/cacerts/ca_sw0081-dev_sw0081-ca.pem.pem verify optional"

config-frontend
        http-request set-var(req.hostbackend) var(req.base),map_dir(/etc/haproxy/maps/_front_https_sni__prefix.map) if !{ var(req.hostbackend) -m found }
        acl tls-has-invalid-crt ssl_c_ca_err gt 0
        acl tls-has-invalid-crt ssl_c_err gt 0
        acl tls-need-crt hdr(host) -i -m str -f /etc/haproxy/maps/_front_tls_needcrt__exact.list
        acl tls-check-crt hdr(host)  -i -m str -f /etc/haproxy/maps/_front_tls_auth__exact.list
        http-request set-var(req.tls_invalidcrt_redir) str(_internal) if tls-has-invalid-crt tls-check-crt

In sort, it’s a copy the SNI config but applied to the host header field

But that solution has some problems:

Our suggestion:

jcmoraisjr commented 3 years ago

Iirc the details of this functionality, the SNI extension has three roles:

The first two options is a matter of configuring mTLS in the default backend, but HAProxy Ingress currently doesn't do this and I'll take care. The third and last option compares SNI and Host header if a certificate was provided, this behavior can be changed on behalf of a less secure deployment, which isn't a problem at all if all of your clients use the same CA bundle.

Is this approach useful in your use case?

ndbemmanuel commented 3 years ago

Yes, that would be useful.
We only have one host name that requires to support non-sni configuration It is also currently the only host name that currently require mTLS. It would cover actual use cases and allow to set the configuration without knowing the internal working of the haproxy.cfg configuration.

So, It will cover these required use cases:

Non required use case but may be useful for someone else and is not covered by the solution:

mogoman commented 5 days ago

hi jcmoraisjr

I am working on vertifying my cluster with a large provider and it seems they don't support SNI - it was difficult to debug that until I finally did curl https://<ip address> and got the same error in my logs vs the query from the vendor:

2024-09-23T17:42:51.159898544Z 2024-09-23T17:42:51+00:00 127.0.0.1 1 2024-09-23T17:42:51.159750+00:00 - ingress 4697 - - 10.42.6.110:44780 [23/Sep/2024:17:42:51.124] _front_https/1: SSL handshake failure

mTLS with the fqdn works fine in my tests, but it seems the remote server at the vendor doesn't support this; they are resolving and then using the IP.

I'm happy to create a dedicated ingress controller or even cluster, if this is possible?

Thanks