allenm
V2EX  ›  Node.js

求助关于 HTTPS client 证书的问题

  •  
  •   allenm · Mar 20, 2013 · 4642 views
    This topic created in 4816 days ago, the information mentioned may be changed or developed.
    现在有一个系统,需要使用个人证书才能登陆,我使用 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 );
    });
    });

    执行没有任何返回,也没报错,请问应该怎么做?
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1355 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 23:54 · PVG 07:54 · LAX 16:54 · JFK 19:54
    ♥ Do have faith in what you're doing.