求助关于 HTTPS client 证书的问题

2013-03-20 20:22:10 +08:00
 allenm
现在有一个系统,需要使用个人证书才能登陆,我使用 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 );
});
});

执行没有任何返回,也没报错,请问应该怎么做?
3761 次点击
所在节点    Node.js
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/63536

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX