Skip to content

Connecting over an authenticating HTTP proxy fails #295

Closed

Description

@cd-ppi

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.

Activity

  1. cd-ppi commented on Jun 4, 2020

    @cd-ppi
    Author

    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.

  2. chrjohn commented on Jun 4, 2020

    @chrjohn
    Member

    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?

  3. chrjohn commented on Jun 4, 2020

    @chrjohn
    Member
  4. cd-ppi commented on Jun 5, 2020

    @cd-ppi
    Author

    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.

  5. the-thing commented on Jun 5, 2020

    @the-thing
    Collaborator

    Are you guys working on it or planning to or can I pick it up?

  6. chrjohn commented on Jun 5, 2020

    @chrjohn
    Member

    @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?

  7. the-thing commented on Jun 5, 2020

    @the-thing
    Collaborator

    It should be, but I will set up a proxy on myst host as I need some test evidence to confirm.

  8. cd-ppi commented on Jun 5, 2020

    @cd-ppi
    Author

    I could do some testing with the proxy I've set up to analyze this.

  9. added theissue type on May 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions