V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
allenm
V2EX  ›  Node.js

求助关于 HTTPS client 证书的问题

  •  
  •   allenm · 2013-03-20 20:22:10 +08:00 · 3754 次点击
    这是一个创建于 4048 天前的主题,其中的信息可能已经有所发展或是发生改变。
    现在有一个系统,需要使用个人证书才能登陆,我使用 wget 命令: wget https://xxx.xxx/index.htm --certificate=client.pem --no-check-certificate
    这样可以正确抓取页面内容。

    请问如果用 node.js 或者 Python 写,才能正确的使用证书进行访问此网站?

    由于是内部系统,我无法提供真实的环境。

    我 node.js 的代码是这样写的:


    var https = require('https');
    var fs = require('fs');
    var tls = require('tls');

    var options = {
    hostname: 'xxx.com',
    host:'xxx.com',
    port: 443,
    path: '/index.htm',
    method: 'GET',
    pfx: fs.readFileSync('client.pfx'),
    passphrase:'111111',
    rejectUnauthorized:false
    };


    options.agent = new https.Agent(options);

    var req = https.request(options, function(res) {
    console.log("statusCode: ", res.statusCode);
    console.log("headers: ", res.headers);

    res.on('data', function(d) {
    // process.stdout.write(d);
    console.log( d );
    });
    });

    执行没有任何返回,也没报错,请问应该怎么做?
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2564 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 416ms · UTC 04:41 · PVG 12:41 · LAX 21:41 · JFK 00:41
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.