繁体   English   中英

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

[英]How to generate privatePEMKey & thumbprint for 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

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

我使用一些为本地 PC 开发生成 TLS 1.2 公共/私有证书的脚本

  • mycompany.ssl.crt = 公钥
  • mycompany.ssl.key = 私钥

也许尝试针对我的公钥 + 私钥文件运行你的代码,看看你是否更进一步。 如果是这样,那么调整我的 makeCerts 脚本可能会解决您的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM