如何为护照azure-ad生成privatePEMKey和指纹

时间:2019-12-09 12:39:32

标签: javascript node.js openid-connect passport-azure-ad

我有一个base64证书文件,看起来像这样(带有有效的,格式正确的大写base64)。

-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----

我正在尝试在nodejs中创建代码以为我的配置生成privatePEMKeythumbprint

var config = JSON.parse(require('fs').readFileSync('./config.json'));
var cert = require('x509').parseCert('./mycert.cert');

//For thumbprint and privatePEMKey parameters, you need to specify a certificate for your app and register the public key in Azure Active Directory.
//- thumbprint is the base64url format of the thumbprint of the public key
//- privatePEMKey is the private pem key string.
config.creds.thumbprint = cert.fingerPrint.replace(/:/g,'').toString('base64');
config.creds.privatePEMKey = cert.publicKey.n;

如果我运行此命令,仍然会收到错误消息:

  

错误:未提供privatePEMKey。请提供   clientSecret或privatePEMKey和指纹。

我的问题是我想念什么? -如果“字符串”为大写/小写,会有所不同吗?

文档通过: https://github.com/AzureAD/passport-azure-ad#622-fill-the-test-parameters

1 个答案:

答案 0 :(得分:0)

通常,证书文件是公钥,我怀疑上面的privatePEMKey行是问题所在。

我使用一些脚本为本地PC开发生成TLS 1.2公共/私有证书: https://github.com/gary-archer/authguidance.websample.final/tree/master/host/certs

  • 我的company.ssl.crt =公钥
  • 我的company.ssl.key =私钥

也许可以尝试针对我的公钥和私钥文件运行您的代码,看看是否还有进一步的发展。如果是这样,那么修改我的makeCerts脚本可能会解决您的问题。

相关问题