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

Mina 2.1.5 + SSL + Android not working

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.1.5
    • None
    • SSL
    • None

    Description

      I'm using the mina library in my android app to connect to a server that also works with mina. Connection works without ssl, but after I added the ssl filter it stopped working. When using the pure ssl socket, everything works. This problem is only on android, but this problem does not exist when using the library on desktop app.

      I add SslFilter like this at the first point of the filter chain:

       

      SslFilter sslFilter = new SslFilter(sslContext);
      sslFilter.setUseClientMode(true);
      filters.addLast("sslFilter", sslFilter);

       

      android log:

       

      2022-02-10 16:10:25.935 I/c.u.m.m.MinaConnector: Initialized connector {max I/O threads: 10, max task threads: 10}
      2022-02-10 16:10:25.942 D/o.a.m.f.s.SslFilter: Adding the SSL Filter sslFilter to the chain
      2022-02-10 16:10:25.943 D/o.a.m.f.s.SslHandler: Session Client[143](no sslEngine) Initializing the SSL Handler
      2022-02-10 16:10:25.944 D/o.a.m.f.s.SslHandler: Session Client[143](no sslEngine) SSL Handler Initialization done.
      2022-02-10 16:10:25.945 D/o.a.m.f.s.SslFilter: Session Client[143](ssl...) : Starting the first handshake
      2022-02-10 16:10:25.945 D/o.a.m.f.s.SslHandler: Session Client[143](ssl...) processing the NEED_WRAP state
      2022-02-10 16:10:25.948 D/o.a.m.f.s.SslFilter: Session Client[143](ssl...): Writing Message : WriteRequest: HeapBuffer[pos=0 lim=239 cap=261: 16 03 01 00 EA 01 00 00 E6 03 03 EA 2E F4 1B 71 70 44 2E F5 33 A8 E8 58 3E 17 A1 04 6A 54 FB 93 40 04 F8 A3 0C 7D 3B 5C 1B 26 17 20 21 B4 F0 3F 3A B2 DD B3 52 89 37 E8 34 9A 87 FC 55 3F 27 7D B4 D1 AB 73 C4 84 28 B4 CC 67 28 87 00 24 13 01 13 02 13 03 C0 2B C0 2F C0 2C C0 30 CC A9 CC A8 C0 09 C0 13 C0 0A C0 14 00 9C 00 9D 00 2F 00 35 00 0A 01 00 00 79 00 17 00 00 FF 01 00 01 00 00 0A 00 08 00 06 00 1D 00 17 00 18 00 0B 00 02 01 00 00 05 00 05 01 00 00 00 00 00 0D 00 14 00 12 04 03 08 04 04 01 05 03 08 05 05 01 08 06 06 01 02 01 00 33 00 26 00 24 00 1D 00 20 8A 7B C8 DF 0C 6E F7 ED 82 71 28 11 DF 3C D9 EC 07 2D B6 C9 E1 FC E1 1D E9 81 AC D1 92 0A 40 4D 00 2D 00 02 01 01 00 2B 00 09 08 03 04 03 03 03 02 03 01...]
      2022-02-10 16:10:25.948 D/o.a.m.f.s.SslHandler: Session Client[143](ssl...) processing the NEED_UNWRAP state
      2022-02-10 16:10:25.949 I/o.a.m.f.l.LoggingFilter: CREATED
      2022-02-10 16:10:25.949 D/MinaAdapter: sessionCreated session=[(0x0000008F: nio socket, client, /192.168.0.170:47164 => /192.168.0.178:3336)]
      2022-02-10 16:10:25.952 I/c.u.m.m.MinaAdapter: Session 143 opened {local: /192.168.0.170:47164, remote: /192.168.0.178:3336}
      2022-02-10 16:10:25.954 D/o.a.m.c.f.IoFilterEvent: Firing a SESSION_OPENED event for session 143
      2022-02-10 16:10:25.954 I/o.a.m.f.l.LoggingFilter: OPENED
      2022-02-10 16:10:25.955 D/MinaAdapter: sessionOpened session=[(0x0000008F: nio socket, client, /192.168.0.170:47164 => /192.168.0.178:3336)]
      2022-02-10 16:10:25.956 D/o.a.m.c.f.IoFilterEvent: Event SESSION_OPENED has been fired for session 143
      2022-02-10 16:10:34.012 D/o.a.m.c.f.IoFilterEvent: Firing a SESSION_CLOSED event for session 143
      2022-02-10 16:10:34.012 I/o.a.m.f.l.LoggingFilter: CLOSED
      2022-02-10 16:10:34.014 D/MinaAdapter: sessionClosed session=[(0x0000008F: nio socket, client, ::/:::47164 => /192.168.0.178:3336)]
      2022-02-10 16:10:34.016 I/c.u.m.m.MinaAdapter: Session 143 closed {local: ::/:::47164, remote: null}
      2022-02-10 16:10:34.026 D/o.a.m.c.f.IoFilterEvent: Event SESSION_CLOSED has been fired for session 143

       

      The following error appears on the server, but when using the desktop Java client with mina, everything works.

      javax.net.ssl.SSLException: Improper close state: Status = OK HandshakeStatus = NEED_WRAP
      bytesConsumed = 0 bytesProduced = 7 sequenceNumber = 0
          at org.apache.mina.filter.ssl.SslHandler.closeOutbound(SslHandler.java:497)
          at org.apache.mina.filter.ssl.SslFilter.initiateClosure(SslFilter.java:762)
          at org.apache.mina.filter.ssl.SslFilter.filterClose(SslFilter.java:693)
          at org.apache.mina.core.filterchain.DefaultIoFilterChain.callPreviousFilterClose(DefaultIoFilterChain.java:776)
          at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1600(DefaultIoFilterChain.java:49)
          at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.filterClose(DefaultIoFilterChain.java:1155)
          at org.apache.mina.core.filterchain.IoFilterAdapter.filterClose(IoFilterAdapter.java:146)
          at org.apache.mina.core.filterchain.DefaultIoFilterChain.callPreviousFilterClose(DefaultIoFilterChain.java:776)
          at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1600(DefaultIoFilterChain.java:49)
          at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.filterClose(DefaultIoFilterChain.java:1155)
          at org.apache.mina.filter.executor.ExecutorFilter.filterClose(ExecutorFilter.java:608)
          at org.apache.mina.core.filterchain.DefaultIoFilterChain.callPreviousFilterClose(DefaultIoFilterChain.java:776)
          at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1600(DefaultIoFilterChain.java:49)
          at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.filterClose(DefaultIoFilterChain.java:1155)
          at org.apache.mina.core.filterchain.IoFilterAdapter.filterClose(IoFilterAdapter.java:146)
          at org.apache.mina.core.filterchain.DefaultIoFilterChain.callPreviousFilterClose(DefaultIoFilterChain.java:776)
          at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1600(DefaultIoFilterChain.java:49)
          at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.filterClose(DefaultIoFilterChain.java:1155)
          at org.apache.mina.core.filterchain.IoFilterAdapter.filterClose(IoFilterAdapter.java:146)
          at org.apache.mina.core.filterchain.DefaultIoFilterChain.callPreviousFilterClose(DefaultIoFilterChain.java:776)
          at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireFilterClose(DefaultIoFilterChain.java:769)
          at org.apache.mina.core.session.AbstractIoSession.closeNow(AbstractIoSession.java:353)
          at org.apache.mina.core.session.DefaultIoSessionDataStructureFactory$DefaultWriteRequestQueue.poll(DefaultIoSessionDataStructureFactory.java:237)
          at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.flushNow(AbstractPollingIoProcessor.java:981)
          at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.flush(AbstractPollingIoProcessor.java:921)
          at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:688)
          at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
          at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
          at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
          at java.base/java.lang.Thread.run(Unknown Source)

       

      Tested on different versions from 2.0.9 to 2.1.5

      Attachments

        Activity

          People

            Unassigned Unassigned
            Grigorev Grigory
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: