使用节点的作用域http客户端的选项,将rejectUnauthorized设置为false

使用节点的HTTP库,我可以轻松设置我想要的选项

options = port: 443 path: "/" method: 'GET' rejectUnauthorized: false https.get options, (res) -> ... 

我如何做node-scoped-http-client的同样的事情?

 # Passing options doesn't seem to work (defined as above) cli = msg.http(stats_url, options) # Injecting it doesn't pass it on either cli.options['rejectUnauthorized'] = false 

我仍然得到这个错误: ERROR Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE

我在这里错过了什么吗? 我对node和coffeescript相当陌生。

简答:

你不能。 目前,scoped-http-client仅将某些选项传递给httphttps

  req = (if @options.protocol == 'https:' then https else http).request( port: port host: @options.hostname method: method path: @fullPath() headers: headers agent: @options.agent or false ) 

长答案:

把它添加到你自己的分支,发送一个拉请求。 便宜的方法是将其直接添加到上述请求调用。 处理它的更好的方法是实际上使用创build客户端时传入的选项对象。

拒绝授权应该是代理人的财产。 尝试这样的事情…

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