How to specify the ciphersuite to be used in SSL session

前端 未结 1 901
孤城傲影
孤城傲影 2020-12-18 23:24

I have created a socket on port 443 as in the following line:

socket = (SSLSocket) factory.createSocket(hostName, port);

Then, I wanted to

相关标签:
1条回答
  • 2020-12-19 00:22

    I found out that I added socket.getsession() before the setEnableCipherSuite() in order to print out the enabled cipheres before setting them. When I removed it, the cipher has been set. why is that ?

    As documented in the SSLSocket JavaDoc:

    The initial handshake on this connection can be initiated in one of three ways:

    • calling startHandshake which explicitly begins handshakes, or
    • any attempt to read or write application data on this socket causes an implicit handshake, or
    • a call to getSession tries to set up a session if there is no currently valid session, and an implicit handshake is done.

    If you call getSession() before calling setEnabledCipherSuite(), the handshake has already been done when you try to set the enabled cipher suites, so this session's cipher suite has already been selected.

    0 讨论(0)
提交回复
热议问题