How do I set SSL protocol version in java? And how do I know which one? javax.net.ssl.SSLException: Received fatal alert: protocol_version

后端 未结 4 1431
执念已碎
执念已碎 2021-02-02 05:03

I am using Apache HttpClient 4.3 to interact with the API of hubic.com. My minimal reproducable example is just a one liner:

<         


        
4条回答
  •  不思量自难忘°
    2021-02-02 05:26

    HttpClient can take an SSLContext for its SSLConnectionSocketFactory.

    You can set the appropriate TLS version in the properties for the SSLContext with the getInstance static method.

    Something like SSLContext context = SSLContext.getInstance("TLSv1");

    If you need to force just one protocol (as getInstance can return one that supports multiple protocols), you can use the setEnabledProtocols method (which takes a String[]) on the context you retrieved using getInstance.

提交回复
热议问题