Uploaded image for project: 'MINA'
  1. MINA
  2. DIRMINA-1082

SSLHandler calling wrap method after closeOutBound() on SSLEngine

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0.16
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None

      Description

      Hi,

      I am trying to connect through SSL and Proxy and getting below error.

      ERROR quickfix.mina.initiator.InitiatorIoHandler - Socket : javax.net.ssl.SSLException: Improper close state: Status = OK HandshakeStatus = NEED_WRAP
      bytesConsumed = 0 bytesProduced = 87
      javax.net.ssl.SSLException: Improper close state: Status = OK HandshakeStatus = NEED_WRAP
      bytesConsumed = 0 bytesProduced = 87
      at org.apache.mina.filter.ssl.SslHandler.closeOutbound(SslHandler.java:500) ~[mina-core.jar:?]
      at org.apache.mina.filter.ssl.SslFilter.initiateClosure(SslFilter.java:742) ~[mina-core.jar:?]
      at org.apache.mina.filter.ssl.SslFilter.filterClose(SslFilter.java:677) ~[mina-core.jar:?]
      at org.apache.mina.core.filterchain.DefaultIoFilterChain.callPreviousFilterClose(DefaultIoFilterChain.java:648) ~[mina-core.jar:?]

       

      I had a look at closeOutBound() method of SslHandler.java and suspect bug there.

      Line 484: sslEngine.closeOutBound()

      Line 490: sslEngine.wrap(emptyBuffer.buf(), outNetBuffer.buf());

       

      In the scenario the sslEngine is closed first and then the wrap method is called. 

      As per java docs:

       In all cases, closure handshake messages are generated by the engine, and wrap() should be repeatedly called until the resulting SSLEngineResult's status returns "CLOSED", or isOutboundDone() returns true. All data obtained from the wrap() method should be sent to the peer.

      closeOutbound() is used to signal the engine that the application will not be sending any more data.

      So as per docs, wrap should be called repeatedly and then closeOutbound() method, but in code its reverse, after closeOutbound wrap is called.

      Can someone please check and comment on this?

        Attachments

          Activity

            People

            • Assignee:
              elecharny Emmanuel Lécharny
              Reporter:
              ratkam Kamal Rathod
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: