Android Enable TLSv1.2 in OKHttp

后端 未结 5 1818
旧时难觅i
旧时难觅i 2020-12-08 16:06

i am using OKHttp for my project. i want to enable TLSv1.2 for my service call. can any body tell me how to enable it.

5条回答
  •  被撕碎了的回忆
    2020-12-08 16:24

    As far as I know OKHttp does not include own SSL/TLS libraries, therefore it just uses the standard SSLSocket provided by Android.

    What TLS versions are supported (and enabled) depends on the used Android version. On some phone TLS 1.2 is supported but not enabled by default. In such cases you could enable it by implementing a custom wrapper SSLSocketFactory that uses internally the default SSLSocketFactory and calls setEnabledProtocols(new String{"TLS1.2"}) on every Socket that is created.

提交回复
热议问题