node.js - 从 nodejs 调用 https - 将数字 cer 文件放在哪里?

标签 node.js ssl https certificate

我有一个在 RedHat 上运行的应用程序,它对外部地址进行 https 调用。 当我向外部地址发出 wget 命令时,它工作正常。但由于 SSL 握手问题,应用程序内部的相同运行失败。 数字证书文件位于/etc/ssl/certs

亲切的问候

萨维奥

最佳答案

这是来自 Node API reference :

const https = require('https');

https.get('https://encrypted.google.com/', (res) => {
  console.log('statusCode:', res.statusCode);
  console.log('headers:', res.headers);

  res.on('data', (d) => {
    process.stdout.write(d);
  });

}).on('error', (e) => {
  console.error(e);
});

或者您可以使用 request module :

const request = require("request");

request.get('https://google.com', function (error, response, body) {
  if (error) throw new Error(error);
  console.log(body);
});

关于node.js - 从 nodejs 调用 https - 将数字 cer 文件放在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52817940/

相关文章:

ssl - 非对称 HMAC

java - Android HTTPS 请求?

ssl - 如何在 ASP.NET Core 2.x 中将 HTTPS/SSL 与 Kestrel 一起使用?

javascript - 我怎样才能将一个配置对象共享给多个数据

javascript - 如何删除html标签中关联的所有属性和值

node.js - 如何使查询结果可从所有页面访问

delphi - Indy TIdSSLIOHandlerSocketOpenSSL - 它可以在我的电脑上运行,但不能在我 friend 的电脑上运行

ios - react 原生 ios 构建 : Can't find node

java - 无法构建 CAS 服务器

https - https的socat端口转发