问题
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.
- https://github.com/AzureAD/azure-activedirectory-library-for-nodejs/blob/master/sample/certificate-credentials-sample.js
- 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