The normal way to get an SSLSocketFactory
would be to initialize a new SSLContext
with a TrustManager
, KeyManager
and SecureRandom
and use the getSocketFactory()
method. However, this does not allow me to enable the required cipher suites or protocols.
The only configuration that HttpsURLConnection
permits that would allow such a change is by setting its default SSLSocketFactory
. I can create a class that extends SSLSocketFactory
and override the getDefaultCipherSuites()
method and wrap the sockets created by createSocket()
to have the required ciphers and protocols set. However, this method does not allow me to initialize a TrustManager
for the connection?
Is there a method I can do both - set cipher suites and protocols and initialize a trust manager?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…