我已将 SSL 证书上传到在 Node 上运行的 Azure Web App,现在我想从 Node 脚本以编程方式访问我的证书,以使用它来签署 JWT。有没有办法做到这一点?
我找到了类似的答案 https://stackoverflow.com/questions/23827884/accessing-uploaded-certificates-in-azure-web-sites/23844770#23844770对于 C#,但我无法将其转换为 Node-world。
Update
这是在 @peter-pan-msft 的帮助下成功运行的代码。在运行此代码之前,我必须通过 SFTP 将 SSL 证书上传到服务器上的私人文件夹。
process.env.KEY = fs.readFileSync('path-to-private-folder/mykey.pem');
const jwt = require('jsonwebtoken');
const token = jwt.sign(payload, process.env.KEY, opts);
有两个样本分别来自AzureAD
在 GitHub 上和azure-mgmt
在 npmjs.org 上。
- https://github.com/AzureAD/azure-activedirectory-library-for-nodejs/blob/master/sample/certificate-credentials-sample.js https://github.com/AzureAD/azure-activedirectory-library-for-nodejs/blob/master/sample/certificate-credentials-sample.js
- https://www.npmjs.com/package/azure-mgmt https://www.npmjs.com/package/azure-mgmt
如果您想使用认证进行Azure管理,可以直接参考第二个示例。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)