Client connections to openfire fails with: Caused by:

I am using Openfire version: 4.7.5 with iOS clients.

When iOS clients attempt to connect to openfire, we are running into ssl exceptions. As per out current openfire configuration, STARTTLS policy was set to ‘Required’ with TLSv1.2 as the encryption protocol.

Closing connection due to exception in session: (0x00052A54: nio socket, server, null =>
org.apache.mina.core.filterchain.IoFilterLifeCycleException: clear(): tls in (0x00052A54: nio socket, server, null =>
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.clear( [mina-core-2.1.6.jar:?]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.sessionClosed( ~[mina-core-2.1.6.jar:?]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextSessionClosed( [mina-core-2.1.6.jar:?]
Caused by: org.apache.mina.core.filterchain.IoFilterLifeCycleException: onPreRemove(): tls:SslFilter in (0x00052A54: nio socket, server, null =>
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.deregister( ~[mina-core-2.1.6.jar:?]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.clear( [mina-core-2.1.6.jar:?]
    ... 18 more
Caused by: Improper close state: Status = OK HandshakeStatus = NEED_WRAP
bytesConsumed = 0 bytesProduced = 7
    at org.apache.mina.filter.ssl.SslHandler.closeOutbound( ~[mina-core-2.1.6.jar:?]
    at org.apache.mina.filter.ssl.SslFilter.initiateClosure( ~[mina-core-2.1.6.jar:?]
    at org.apache.mina.filter.ssl.SslFilter.stopSsl( ~[mina-core-2.1.6.jar:?]

Once we updated the STARTTLS policy to ‘optional’, the clients are able to connect to openfire, but then the traffic is not encrypted.
Trying to figure out the root cause in this case, and also what needs to be done to get it working with STARTTLS policy= required.

some more investigations into this show that these failures happen during the increased loads when clients are logging off and then trying to login again. Assuming its related to load, but still not clear why it would end up with: Improper close state: Status = OK HandshakeStatus = NEED_WRAP bytesConsumed = 0 bytesProduced = 7