通过代理服务器的节点HTTPS请求失败

时间:2018-11-15 11:00:35

标签: node.js http ssl https request

我有有效的ssl证书pem文件。

openssl rsa -in cert.pem -passin "pass:password"
writing RSA key

    -----BEGIN RSA PRIVATE KEY-----
    MIIEpAIBAAKCAQEAwqsU4MqkLOhm6xoueHu6x4U0zBBgcY+dQra3xD2ZJTXtvxDQ
    ...
    ...
    ...
    jKV7oDM0gfEF1bq0OQD0uTaNDvLXWBFaBKx5yxahr1+LL6H1r5wK6Q==
    -----END RSA PRIVATE KEY-----

我正在使用有效的代理服务器,该服务器在我的浏览器中可以正常工作,并使用标准的HTTP协议。

现在,当我运行自己的node.js代码时。

var fs = require('fs');
var request = require('request');

const data = JSON.stringify({
    "compression": "lz4", "replay" : false
  });
  var proxyServer = 'http://webproxy.e.corp.services:80';

var option = {
    proxy: proxyServer,
    method: 'POST',
    url: 'https://10.51.13.6:8301/request/stream',
    json: data,
    ca: fs.readFileSync('/]path to]/cert.pem'),  
    passphrase: 'password',
    headers: {
        'Host': 'rests_client.xxx.xxxx.com'
      }
}

request(option,function (error, response, body) {
    if (error) {
      return console.error('upload failed:', error);
    }
    console.log('Upload successful!  Server responded with:', body);
  });

我遇到以下错误:

upload failed: { Error: write EPROTO 4552209856:error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure:../deps/openssl/openssl/ssl/s3_pkt.c:1498:SSL alert number 40
4552209856:error:1409E0E5:SSL routines:ssl3_write_bytes:ssl handshake failure:../deps/openssl/openssl/ssl/s3_pkt.c:659:

    at WriteWrap.afterWrite [as oncomplete] (net.js:868:14) errno: 'EPROTO', code: 'EPROTO', syscall: 'write' }

我真的不明白我在想什么。

0 个答案:

没有答案