Skip to content

TLS initiator sessions fail: Logon is written before the SSL handshake completes, and SSLContextFactory is incompatible with MINA 2.2.10 (removed BogusTrustManagerFactory) #1356

Open

Description

@xhk

Environment

  • QuickFIX/J version: <fill in exact version/commit — e.g. 3.0.0-SNAPSHOT @ <commit>>
  • Apache MINA version: 2.2.5 (per bytecode inspection, all of MINA 2.0.x–2.2.9 is affected; the fix landed only in MINA 2.2.10)
  • OS/JVM: Windows (the native name-resolution fallback described below is OS-specific — LLMNR/NetBIOS on Windows)
  • Role: Initiator over SSL/TLS with mutual TLS (mTLS)
  • Connection target configured as an IP literal that has no resolvable PTR record

Summary

When an SSL initiator connects to a peer whose address is an IP literal without a PTR record, the session never completes logon and reconnects in a loop until logon timeout. The failure is the combination of one upstream MINA defect and two QuickFIX/J-side defects:

  1. (Upstream MINA, trigger condition) In MINA ≤ 2.2.9, SslFilter creates the SSLEngine via InetSocketAddress.getHostName(). For IP-literal addresses without PTR records this triggers the OS native resolver's multicast fallback (LLMNR/NetBIOS on Windows), blocking ~4.5 s before the TLS handshake even starts. This is MINA [DIRMINA-1202], fixed in MINA 2.2.10 by switching to getHostString().
  2. (QuickFIX/J defect A) The initiator's connection-readiness predicate only checks whether the TCP-level MINA session has been created (connectFuture.getSession() != null); it never waits for the SSL handshake completion event (SslFilter SECURED). As soon as the TCP session exists, the FIX session state machine writes the Logon message into a channel whose TLS handshake has not started yet.
  3. (QuickFIX/J defect B) SSLContextFactory hardcodes a reference to org.apache.mina.filter.ssl.BogusTrustManagerFactory (used as a fallback when no trust store is configured). MINA 2.2.10 removed that class ([DIRMINA-1203]), so upgrading to the only MINA release that fixes the delay fails at startup with NoClassDefFoundError.

Defect A alone is benign when the handshake starts promptly, and the MINA delay alone is survivable if the caller waits for handshake completion before writing — a minimal diagnostic tool using the same MINA version, the same SslFilter, and the same certificates succeeds precisely because it gates on handshake completion. The two together make mTLS logon deterministically fail.

Steps to reproduce

  1. Configure a QuickFIX/J initiator with SocketConnectHost set to an IP literal that has no PTR record (typical for many public/counterparty endpoints), SSL enabled, mTLS credentials correct.
  2. Start the initiator and let it attempt logon.

Observed behavior

The session reconnects in a loop and never logs in. Measured timeline (MINA 2.2.5, Session opened = t0):

The callstack code

ConnectTask.run() // 每 1s 一次
→ connect()
→ pollConnectFuture()
connectFuture.awaitUninterruptibly(2000l) // 硬编码 2s 轮询超时
if (connectFuture.getSession() == null) // 只判断 TCP session 是否拿到,不等 SSL 握手完成
log "Pending connection not established after ... ms."

Reference

  1. Mina 2.2.10 changlog https://mina.apache.org/mina-project/index.html.
  2. The mina DIRMINA-1202: TLS peer identity taken from InetSocketAddress.getHostName() reverse DNS.

Activity

  1. added theissue type on Oct 23, 2026
  2. chrjohn commented on Oct 23, 2026

    @chrjohn
    Member

    Hi @xhk , are you able to test a snapshot build?
    Currrent 3.0.3-SNAPSHOT has #1271 where one can disable reverse DNS lookup.
    Also will merge #1357 in due course if you want to use MINA 2.2.10. Please keep in mind that MINA 2.2.10 has a bug which leads to deadlocks when used with SSL and SOCKS proxy, see apache/mina#84.

    Edit: but defect A still needs to be looked at, I think.

  3. xhk commented on Oct 24, 2026

    @xhk
    Author

    2. Hi @xhk , are you able to test a snapshot build?
    Currrent 3.0.3-SNAPSHOT has #1271 where one can disable reverse DNS lookup.
    Also will merge #1357 in due course if you want to use MINA 2.2.10. Please keep in mind that MINA 2.2.10 has a bug which leads to deadlocks when used with SSL and SOCKS proxy, see apache/mina#84.
    Edit: but defect A still needs to be looked at, I think.

    Thanks! I will test 3.0.3-SNAPSHOT with reverse DNS lookup disabled
    (#1271) and confirm whether the 4.5s delay is gone.

    Our deployment does not use a SOCKS proxy, so the MINA 2.2.10 deadlock
    (apache/mina#84) should not affect us — looking forward to #1357.

    Glad to hear you agree defect A still needs fixing: even with the DNS
    delay eliminated, any handshake latency would still cause the Logon
    to be written before the session is SECURED, so gating readiness on
    SslEvent.SECURED seems the right fix. Happy to test a patch if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions