TLS connection using SSLSocket is slow in Android OS

后端 未结 4 1074
感动是毒
感动是毒 2020-12-28 22:33

I\'m developing an Android app which uses SSLSocket to connect to a server. This is the code I\'m using:

// Connect
if (socket == null || socket.isClosed() |         


        
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-28 23:35

    You are using a new SecureRandom per connection, instead of using a single static pre-initialized SecureRandom. Everytime you create a new SecureRandom(), you need to gather entropy for seeding (a slow process).

    SecureRandom does not self-seed until it is first used, which is why the delay does not occur until the call to getSession()

提交回复
热议问题