如何在Android API 16中的WebView控件上支持TLS1.2?

时间:2018-07-11 13:29:59

标签: android ssl webview

我有一个需要通过API16运行的Android应用。基本上,该应用程序包含一个webview控件并访问第三方网站。好吧,问题在于该站点将仅在TLS1.2上启动,并且将禁用最旧的安全协议,并且从API 16到19的Web视图不支持它。我需要知道是否有一种方法可以使它工作而无需完全替换控件。

我尝试过的事情:

  1. 我创建了一个自定义类,并使其继承自WebViewClient类。我覆盖了shouldinterceptrequest方法来拦截请求,并使用我自己的套接字(配置为支持TLS1.2)进行呼叫,该套接字对GET调用有效,但对POST调用无效。

  2. 我知道支持TLS1.2,但它不是默认协议的一部分。

    public List<byte> crc16(List<byte> tempByteList)
        {
            ushort reg_crc = 0xFFFF;
            for(int i = 1; i<tempByteList.Count - 1; i++)
            {
                reg_crc ^= tempByteList[i];
                for(int j = 0; j < 8; j++)
                {
                    if((reg_crc & 0x01) == 1)
                    {
                        reg_crc = (ushort)((reg_crc >> 1) ^ 0xA001);
                    }
                    else
                    {
                        reg_crc = (ushort)(reg_crc >> 1);
                    }
                }
            }
            tempByteList.Insert(tempByteList.Count - 1, (byte)((reg_crc >> 8) & 0xFF));
            tempByteList.Insert(tempByteList.Count - 1, (byte)(reg_crc & 0xFF));
            return tempByteList;
        }
    

我试图找到一种从Context中启用它的方法,但是没有选择这样做。

任何帮助将不胜感激,谢谢!

0 个答案:

没有答案