After a long time of trying to get the code working I could able to write a logic to reproduce the intermittent failure.
I have tried a lot many times and failure is reproducible every time with Multithreading .
However , please note I left a commented code in main function, where the logic is looped just in case you don���t see the intermittent failure.
The scenario is for testing ���setNeedClientAuth��� , the scenario is as follows reproducible with JDKb20
1. Basic idea is to get a Client SSLSocket which is based on an empty keystore , so client has no way to authorize itself.
2. Create a SSLServerSocket based on the JKS keystore attached (testkeys.jks) , configure it so that ���setNeedClientAuth��� is false.
3. Accept the connections from client on a port which is shared with client.
4. Client thread is started , the SSLSocketFactory is retrieved form a SSLContext which is initialized with an empty keystore ,
SSLSocket is created.
5. Client socket is connected to the server on the remote port
6. Client sends some data to server
7. Client closes its socket
8. Server tries to read the data
9. Server breaks with SSLException: Software caused connection abort: recv failed
Please find the logs attached with ���javax.net.debug=all��� VM option (SSLSocketHanshakeLogs.txt)
Please find the attached code ���SSLSocketHandshake.java���
If in the above order of operations, #7 is omitted, i.e. if the client socket is not closed, then there is NO intermittent SSLException