使用HTTPS请求,我尝试使用下面的文档指南连接到后端服务器: http://nodejs.org/api/https.html#https_https_request_options_callback的NodeJS,使HTTPS请求到后端服务器
function getHttpsReq (request, response)
{
var options = {
hostname: 'encrypted.google.com',
port: 443,
path: '/',
rejectUnauthorized: false,
strictSSL: false,
agent: false,
method: 'GET'
}
https.request(options, function(res) {
console.log("statusCode: ", res.statusCode);
console.log("headers: ", res.headers);
var data = '';
res.on('data', function(d) {
process.stdout.write(d);
data += data + d;
});
res.on('end', function() {
console.log("Done");
response.end(data);
});
});
}
但是,当我想这一点,它抛出以下错误:
Error: 140735290610048:error:0607907F:digital envelope routines:EVP_PKEY_get1_RSA:expecting an rsa key:../deps/openssl/openssl/crypto/evp/p_lib.c:288:
$ node --version
v0.8.15
请让我知道什么,我需要做一些额外的?
你是否尝试过使用这些东西的请求? https://www.npmjs.org/package/request – Zlatko