WebView中Http和Https混合問題

2021-08-03 19:46:28 字數 1067 閱讀 3514

在android5.0 以及以上的系統,當webview載入的鏈結為https開頭,但是鏈結裡面的內容,比如為http鏈結,這時候,就會載入不出來,在瀏覽器中的console會有如下警告log:

the page at 'https://***********/test.html?username=26535fd656sdf966339eecc013esfd91' was loaded overhttps, but requested an insecure image 'http://***********/images/demo1.png'. this content shoud over https.
從android5.0開始,webview預設不支援同時載入https和http混合模式。

從android5.0以後,當乙個安全的站點(https)去載入乙個非安全的站點(http)時,需要配置webview載入內容的混合模式,一共有如下三種模式:

mixed_content_always_allow:在這種模式下,webview是可以在乙個安全的站點(https)裡載入非安全的站點內容(http),這是webview最不安全的操作模式,盡可能地不要使用這種模式。

在android5.0以下,預設是採用的mixed_content_always_allow模式,即總是允許webview同時載入https和http;而從android5.0開始,預設用mixed_content_never_allow模式,即總是不允許webview同時載入https和http。

雖然官網給出的建議是,為了安全考慮,使用mixed_content_never_allow模式,但是在實際引用中,當我們的伺服器已經公升級到https,但是一些頁面的資源是第三方的,我們不能要求第三方也都公升級到https,所以我們只能根據系統版本,用**去設定載入模式為mixed_content_always_allow。

在webview載入頁面之前,設定載入模式為mixed_content_always_allow

if (build.version.sdk_int >= build.version_codes.lollipop)

nginx安裝配置部署http服務和https服務

其他命令 宣告 wget tar zxvf nginx 1.18.0.tar.gz安裝依賴 yum y install pcre pcre devel zlib zlib devel https繞過彎路 yum y install make zlib zlib devel gcc c libtool...

nginx配置http訪問自動跳轉到https

nginx配置http訪問自動跳轉到https 一般我們的nignx配置ssl的時候 server location ht location location apache 我的ssl證書是這樣配置的 但是這種 http的還是可以訪問 沒有預設到https的站點 那麼我們把 兩個配置分開 serve...

nginx配置http訪問自動跳轉到https

按照如下格式修改nginx.conf 配置檔案,80埠會自動轉給443埠,這樣就強制使用ssl證書加密了。訪問http的時候會自動跳轉到https上面。server listen 80 server name www.網域名稱.com server name www.網域名稱.com root ho...