gpt4 book ai didi

android - Android 系统 WebView 中的 SSL 错误

转载 作者:太空宇宙 更新时间:2023-11-03 14:32:03 26 4
gpt4 key购买 nike

我需要在使用 Android System WebView“浏览器”的 Android 应用程序中显示我正在处理的内部网站。该站点的 SSL 在 Android、Linux 和 Windows 上的 Chrome 中正常工作,但是当我使用实现 WebView 的应用程序打开页面时,它返回 SSL 错误。该网站由 Nginx 提供服务,并使用我们公司来自 GoDaddy 的通配符 SSL 证书。我已经在运行 Android 7.1、8.0 和 8.1 的 Android 设备上进行了测试。我还从源代码编译了最新版本的 WebView 并将其安装在一台设备上,以确认旧版本不会导致问题。我跑了TestSSLServer针对网站的程序,没有收到任何警告。这是我的 Nginx 配置:

server {
listen 443 ssl http2;
server_name subdomain.example.com;
root /websites/subdomain.example.com;

ssl_certificate /etc/ssl/certs/wildcard_cert.crt;
ssl_certificate_key /etc/ssl/private/wildcard_key.key;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;

########################################################################
# from https://cipherli.st/ #
# and https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html #
########################################################################

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
ssl_ecdh_curve secp384r1;
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off;
ssl_stapling on;
ssl_stapling_verify on;
resolver 8.8.8.8 8.8.4.4 valid=300s;
resolver_timeout 5s;
# Disable preloading HSTS for now. You can use the commented out header line that includes
# the "preload" directive if you understand the implications.
#add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains";
# add_header X-Frame-Options DENY;
# add_header X-Content-Type-Options nosniff;

##################################
# END https://cipherli.st/ BLOCK #
##################################


# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;

# add_header X-Frame-Options "SAMEORIGIN";
# add_header X-XSS-Protection "1; mode=block";
# add_header X-Content-Type-Options "nosniff";
# add_header Access-Control-Allow-Origin *;
# add_header Access-Control-Allow-Methods "GET, OPTIONS";
# add_header Access-Control-Allow-Headers "Authorization";
# add_header Access-Control-Allow-Credentials "true";

index index.html index.htm;

# kill cache
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;

charset utf-8;

location / {
try_files $uri /index.html;
}

location = /index.html {
expires 30s;
}

}

在此先感谢您的帮助。

最佳答案

请在您的 webview 中添加以下内容

webView.enableJavaScript();
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.setWebViewClient(new WebViewClient(){
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {

}
});

关于android - Android 系统 WebView 中的 SSL 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51862502/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com