访问Azure Web App中的SSL证书 [英] access SSL certificate in Azure Web App

查看:99
本文介绍了访问Azure Web App中的SSL证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将SSL证书上载到了在Node上运行的Azure Web应用程序中,现在我想从Node脚本中以编程方式访问我的证书,以将其用于JWT签名.有办法吗?

I've uploaded an SSL certificate to my Azure Web App, running on Node, and now I'd like to access my certificate programmatically from my Node scripts to use it for signing JWTs. Is there a way to do this?

我找到了类似的答案 C#,但我无法将其转换为Node-world.

I've found similar answers for C#, but I haven't been able to translate this into Node-world.

在@ peter-pan-msft的帮助下,这里的代码成功运行了.在运行此代码之前,我必须SFTP将SSL证书上传到服务器上的私有文件夹中.

Here is code that worked successfully, with help from @peter-pan-msft. Before running this code, I had to SFTP upload my SSL certificate to a private folder on the server.

process.env.KEY = fs.readFileSync('path-to-private-folder/mykey.pem');

const jwt = require('jsonwebtoken');

const token = jwt.sign(payload, process.env.KEY, opts);

推荐答案

有两个示例,分别来自GitHub上的AzureAD和npmjs.org上的azure-mgmt.

There are two samples separately from AzureAD on GitHub and azure-mgmt on npmjs.org.

  1. https://github.com/AzureAD/azure-activedirectory-library-for-nodejs/blob/master/sample/certificate-credentials-sample.js
  2. https://www.npmjs.com/package/azure-mgmt
  1. https://github.com/AzureAD/azure-activedirectory-library-for-nodejs/blob/master/sample/certificate-credentials-sample.js
  2. https://www.npmjs.com/package/azure-mgmt

如果要使用认证进行Azure管理,则可以直接参考第二个示例.

If you want to use the certification for doing Azure Management, you can directly refer to the second sample.

这篇关于访问Azure Web App中的SSL证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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