You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Connecting over an authenticating HTTP proxy fails #295
We are trying to connect over an HTTP proxy that enforces authentication, i.e. user and password need to be set. But even though we put them into the dictionary (and set the appropriate proxy type and the correct proxy host and port) the connection fails.
Snooping into the network traffic with wireshark reveals that, at first, a CONNECT request is sent by our application to the proxy. As usual, this initial request contains no authentication data, and is answered by the proxy with an 407 Authentication Required. The expected behaviour would be that a new CONNECT request is send, this time with a Basic Proxy-Authorization header containing the user and password. Instead, the connection is closed.
I ran the code in a debugger and found that the problem seems to be that in quickfix.mina.ProtocolFactory (line 145 to 150) a prefered order of the authentication methods is set into the proxyIoSession. This order, however, has NO_AUTH at the first position. So that, after receiving the 407 and when going through the possible authentication methods, Mina's HttpSmartProxyHandler first encounters a NO_AUTH and sees this as a sign that every further search for an authentication method is futile. And therefore closes the connection.
The prefered order of the authentication methods in ProtocolFactory seems to be rather obviously wrong. But instead of correcting it, you might want to just not set it, in which case Mina would go with their own idea of which method to prefer, which seems to be a good idea.
I forced the prefered order list to be null in my debugger, and was able to succesfully connect through the proxy.
I just noticed that at the end of the discussion of #92 the same issue with pretty much the same explanation was mentioned. I can confirm that the current prefered order prevents the authentication with http proxies from working, and that setting no order at all would be better.
Sounds like a simple fix to me. Maybe someone with more proxy experience than me can comment whether this change will break something else.
Maybe we should make it configurable?
The whole method autoSelectAuthHandler in HttpSmartProxyHandler.java is only ever reached after the 407, i.e. only if the proxy needs authentication.
So yes, removing the prefered order also works with a proxy without username and password.
Activity
cd-ppi commentedon Jun 4, 2020
I just noticed that at the end of the discussion of #92 the same issue with pretty much the same explanation was mentioned. I can confirm that the current prefered order prevents the authentication with http proxies from working, and that setting no order at all would be better.
chrjohn commentedon Jun 4, 2020
Sounds like a simple fix to me. Maybe someone with more proxy experience than me can comment whether this change will break something else.
Maybe we should make it configurable?
chrjohn commentedon Jun 4, 2020
Will removing the prefered order also work with a proxy without username and password?
Edit: OK, seems to work:
https://github.com/apache/mina/blob/37a004b9193d64ff12c790be7f97b842452803e3/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/HttpSmartProxyHandler.java#L143-L144
cd-ppi commentedon Jun 5, 2020
The whole method autoSelectAuthHandler in HttpSmartProxyHandler.java is only ever reached after the 407, i.e. only if the proxy needs authentication.
So yes, removing the prefered order also works with a proxy without username and password.
the-thing commentedon Jun 5, 2020
Are you guys working on it or planning to or can I pick it up?
chrjohn commentedon Jun 5, 2020
@the-thing , feel free to do it. Thanks in advance. :)
Edit: I think I will cut a release 2.2.0 next week. Do you think it is safe to include it there?
the-thing commentedon Jun 5, 2020
It should be, but I will set up a proxy on myst host as I need some test evidence to confirm.
cd-ppi commentedon Jun 5, 2020
I could do some testing with the proxy I've set up to analyze this.