<div dir="ltr"><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Thank you for the very detailed explanation, Alex!</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Having looked at the sequence diagram of the mTLS handshake, I now see why I cannot get what I want.</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">I can either get plain-text HTTP to mTLS-secured forwarding, or I have to have two independent legs of communication when the authenticity of client-to-Squid connection is ensured using its (Squid's) own key-cert pair, which is different from authentication credentials of the handshake between Squid and my target server.</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">I cannot afford to have unencrypted the client-to-Squid leg, otherwise, I could do it in a single "socat" invocation.</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">I don't have the server key-cert pair, which makes the sslbump impractical too.</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">In NGINX, I implemented the reverse proxy model (option 2 on your list), when the proxy terminated SSL with its own cert, received the request, rewrote some headers, and forwarded it over an mTLS-secured connection. The problem is that under some circumstances I also need to rewrite the body of the HTTP request and this was taking the whole solution to a whole new level of complexity...</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">I guess I need to start looking into automation that would allow me to manage mTLS configuration of clients at scale instead of trying to defeat the whole purpose of the mTLS integrity mechanism :)</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 14, 2021 at 2:42 PM Alex Rousskov <<a href="mailto:rousskov@measurement-factory.com">rousskov@measurement-factory.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 1/14/21 2:41 PM, Sergey Maslyakov wrote:<br>
<br>
> Is the CONNECT tunnel designed in a way that enables it to "enrich" the<br>
> outgoing connection with mTLS authentication?<br>
<br>
If, by "designed", you are asking about HTTP protocol design, then the<br>
CONNECT tunnel is a blind TCP tunnel by that design. Hence, by design, a<br>
proxy dealing with CONNECT tunnels does not assume they are related to TLS.<br>
<br>
Squid SslBump feature allows the admin to disregard the general design<br>
principles above and interpret the CONNECT tunnel bytes as TLS. Usually,<br>
when folks ask about "enriching" TLS, they talk about SslBump. It is not<br>
yet clear to me whether you need SslBump.<br>
<br>
Neither Squid nor any other proxy can enrich a client TLS connection.<br>
TLS is designed to protect from such fiddling by proxies. I suspect that<br>
what you need is for Squid to use mTLS when forwarding a client request<br>
to the origin server. This is supported in principle, but the devil is<br>
in the details.<br>
<br>
<br>
> My destination server requires mTLS authentication of the client. I have<br>
> a valid key-cert pair and I can successfully execute a "curl" command to<br>
> fetch a document from that server using the key-cert pair at hand.<br>
<br>
Squid supports mTLS authentication with HTTPS cache_peers (including<br>
origin servers) via the cache_peers sslcert option.<br>
<br>
<br>
> I want to put Squid between my clients (Maven, Gradle, Docker Engine,<br>
> etc) and the server so that clients would be configured to use the<br>
> instance of Squid as an HTTPS proxy but would not have to be configured<br>
> with the mTLS key-cert pair.<br>
<br>
1. "HTTPS proxy" is a proxy that accepts TLS connections opened by<br>
clients that want to explicitly ask that proxy to forward their request<br>
to some origin server. I suspect that is not what you meant by "HTTPS<br>
proxy". Whether there are CONNECT requests in this case depends on the<br>
client, but all popular clients I know about do send CONNECT requests<br>
inside that secure TLS connection to the proxy (unfortunately). For<br>
those clients, SslBump is required.<br>
<br>
2. It is possible that you are talking about an HTTPS surrogate or HTTPS<br>
reverse proxy/accelerator. In this configuration, clients talk to Squid<br>
thinking that Squid is an HTTPS origin server. There are no CONNECT<br>
requests in this case. Clients receive Squid certificates. No SslBump.<br>
<br>
3. If you meant that Squid should intercept/hijack client TCP<br>
connections to HTTPS origin servers, then it is a third kind of<br>
configuration. There are no CONNECT requests in this case. Clients<br>
receive Squid certificates. SslBump is required.<br>
<br>
4. If you meant that Squid, as a regular HTTP forward proxy, should<br>
hijack client CONNECT tunnels to HTTPS origin servers, then it is a yet<br>
another kind of configuration. There are CONNECT requests in this case.<br>
Clients receive Squid certificates. SslBump is required.<br>
<br>
Each scenario above would present its own Squid challenges. Please<br>
clarify what you are dealing with.<br>
<br>
<br>
> Here is how I see it:<br>
<br>
> Maven --- (HTTPS/CONNECT) ---> Squid (stores my mTLS key-cert pair) ---<br>
> (mTLS/SSL) ---> Server<br>
<br>
> Is this doable within Squid architecture?<br>
 The "HTTPS/CONNECT" part can be misinterpreted as any of the four cases<br>
above. Please clarify what it means to you. If this is all too<br>
overwhelming, we can start with a simple question: Do your clients<br>
establish TCP connections to a Squid port (cases 1, 2, 4)? Or do they<br>
open TCP connections to origin servers instead (case 3)?<br>
<br>
<br>
Cheers,<br>
<br>
Alex.<br>
</blockquote></div>