Krz*_*lny 11 https google-chrome ssl-certificate google-chrome-extension
我正在对我的URL做简单的GET请求,我收到错误"ERR_INSECURE_RESPONSE".这很好,因为证书是自签名的.但我有两个问题:
有任何想法吗?
chrome.webRequest.onErrorOccurred事件来获取网络错误的通知.该error属性将包含网络错误代码.例如:
chrome.webRequest.onErrorOccurred.addListener(function(details) {
if (details.error == 'net::ERR_INSECURE_RESPONSE') {
console.log('Insecure request detected', details);
}
}, {
urls: ['*://*/*'],
types: ['xmlhttprequest']
});
var x = new XMLHttpRequest;
x.open('get','https://example.com');
x.send();
Run Code Online (Sandbox Code Playgroud)
如果仅用于测试,只需使用--ignore-certificate-errors标志启动Chrome 即可使用自签名证书.这会影响同一浏览会话中的所有网站,因此我建议通过附加--user-data-dir=/tmp/temporaryprofiledirectory到命令行参数来为此目的使用单独的配置文件目录.
首先避免错误的另一种方法是获得有效的SSL证书.对于非提供商业目的,你可以得到一个免费的SSL证书在https://www.startssl.com.
| 归档时间: |
|
| 查看次数: |
29613 次 |
| 最近记录: |