BackendTLSPolicy's Service attachment is problematic #3554
Description
These comments were made during the initial design, but I wanted to persist them into an issue.
BackendTLSPolicy currently attaches to a Service.
In the simple case, this works fine. For example, I may have:
Gateway:
port: 443
protocol: HTTPS
tls: TERMINATE
HTTPRoute:
backendRef: foo, port 443
BackendTLSPolicy:
targetRef: Service foo
and I will terminate TLS and encrypt it on the upstream. This works great.
Where things fall apart is when we have multiple paths.
For example, imagine I have the above config, but then also have a service mesh. An application in the service mesh calls curl https://foo
.
The foo
service has the TLS config saying "Add TLS to this request". The service mesh adds TLS and now it has 2 layers of TLS which is clearly broken.
If the API semantic is supposed to be "make sure this request is TLS" not "Add TLS to the this request" (which I don't think it is, nor do I think it should be, just covering the bases here) that is infeasible to implement since it would require any implementation to know whether a request is already TLS encrypted or not.
This same issue can occur without mesh as well. For example, if in addition to my configs above I have:
Gateway:
port: 443
protocol: HTTPS
tls: PASSTHROUGH
TLSRoute:
backendRef: foo, port 443
then I have the same problem of TLS being added again. Again, we could say the impl should detect this is already TLS and it should not be added. However, this falls apart in other cases:
Gateway:
port: 443
protocol: TCP
TCPRoute:
backendRef: foo, port 443
As it this is opaque TCP, we are not aware if it is TLS or not.
Overall, these issues prevent BackendTLSPolicy from being a viable replacement for DestinationRule for Istio