如何在 node.js 天蓝色函数中访问公共证书 [英] How to access a public certificate in a node.js azure function

查看:16
本文介绍了如何在 node.js 天蓝色函数中访问公共证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已通过

我的 Azure 函数应用服务 -> 平台功能选项卡 -> SSL ->公钥证书 (.cer)

My Azure function app service -> Platform Features tab -> SSL -> Public Key Certificates (.cer)

现在如何通过我的 azure 函数访问它?

Now how do I access this through my azure function?

我已经尝试对此进行研究,但唯一的 结果我可以找到使用私有证书的方法

I've tried researching this but the only results I can find are for using a private certificate

目前为了解决这个问题,我告诉节点忽略我正在集成的端点的自签名证书,方法是设置 process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';

Currently to get around this I am telling node to ignore the self signed certificate for the endpoint I am integrating with by setting process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';

我想改用证书.

我最终将证书链添加到一个文件夹并从我的应用程序的文件夹中读取文件.仍然没有回答关于如何使用天蓝色上传证书的问题

I ended up adding the certificate chain to a folder and reading the files from the folder in my application. Still doesn't answer the question on how to use the azure uploaded certificate though

const https = require('https');
https.globalAgent.options.ca = [
    fs.readFileSync(__dirname + '/certs/master.pem'),
    fs.readFileSync(__dirname + '/certs/root.pem')
];

推荐答案

我用 文档页面 他们更新它说你只能用 c# 加载存储在 azure 中的 SSL 证书

I created an issue with the documentation page and they updated it to say you can only load SSL certs stored in azure with c#

如果您不使用 c#,则必须将 ssl 证书与您的代码一起存储在一个文件夹中,并从文件中读取它,如我的示例所示.

If you're not using c# you have to store the ssl cert in a folder with your code and read it from the file as in my example.

这篇关于如何在 node.js 天蓝色函数中访问公共证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆