access SSL certificate in Azure Web App

半城伤御伤魂 提交于 2020-06-14 07:42:11

问题


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?

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

Update

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);

回答1:


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

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



来源:https://stackoverflow.com/questions/35692440/access-ssl-certificate-in-azure-web-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!