【问题标题】:How to get the ssl certificate information from a webview?如何从 webview 获取 ssl 证书信息?
【发布时间】:2018-07-07 18:05:56
【问题描述】:

我似乎无法找到任何关于 webviews 的文档。有没有办法从 webview 获取 ssl 证书信息?

【问题讨论】:

    标签: javascript node.js electron chromium


    【解决方案1】:

    浏览器 API 或 Electron 都没有内置函数。但是你可以在主进程中通过node.js获取证书。例如使用“https”模块。

    const https = require('https');
    
    const options = {
        hostname: 'nodejs.org', 
        agent: false, 
        ciphers: "ALL",
        rejectUnauthorized: false
    };    
    
    new Promise(function (resolve, reject) { 
        https.get(options, function (res) {
            var certificate = res.socket.getPeerCertificate();
            if(typeof (certificate) === 'undefined' || certificate === null) {
                reject({message: 'The website did not provide a certificate'});
            } else {
                resolve(certificate);
            }
        });
    }).then(function(certificate) {
        console.log(certificate)
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-12-13
      • 2015-09-25
      • 2019-02-10
      • 2014-06-16
      • 2011-03-06
      • 2019-10-08
      • 1970-01-01
      相关资源
      最近更新 更多