如何在 Node 中使用 TLS 连接到没有证书的 RabbitMQ 服务器

发布于 2025-01-09 03:21:17 字数 971 浏览 4 评论 0原文

我需要使用 Node.js 连接到带有 TLS 的 RabbitMQ 的帮助。

客户端向我们提供了连接到其 RabbitMQ 服务器的凭据。

他们说我们不需要任何 TLS 连接证书,而且我正在使用 NodeJS。

我们收到这个错误。 OperationalError: 证书已过期

我们正在尝试使用此 Node 客户端库 https: //github.com/amqp-node/amqplib 及其 SSL 指南(https://amqp-node.github.io/amqplib/ssl.html)上面写着

If you're not going to use a client certificate, you need only to make sure you will trust the server certificate:
var opts = {
  ca: [fs.readFileSync('cacert.pem')]
};

这是我们当前的代码

const conn = await connect({
    hostname: process.env.RABBITMQ_HOST,
    port: Number(process.env.RABBITMQ_PORT),
    username: process.env.RABBITMQ_USER,
    password: process.env.RABBITMQ_PASSWORD,
    vhost: process.env.RABBITMQ_VHOST,
    protocol: 'amqps',
  }

I need help connecting to RabbitMQ with TLS using Node.

The client gave us credentials for connecting to their RabbitMQ server.

They say we don’t need any certificates for TLS connection, and I’m using NodeJS.

We’re getting this error.
OperationalError: certificate has expired

We’re trying to use this Node client library https://github.com/amqp-node/amqplib and in their SSL guide(https://amqp-node.github.io/amqplib/ssl.html) it’s written

If you're not going to use a client certificate, you need only to make sure you will trust the server certificate:
var opts = {
  ca: [fs.readFileSync('cacert.pem')]
};

this is our current code

const conn = await connect({
    hostname: process.env.RABBITMQ_HOST,
    port: Number(process.env.RABBITMQ_PORT),
    username: process.env.RABBITMQ_USER,
    password: process.env.RABBITMQ_PASSWORD,
    vhost: process.env.RABBITMQ_VHOST,
    protocol: 'amqps',
  }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文