如何从自签名证书中获取证书密码
How to get the certificate password from a self signed certificate
我想从带有证书的 Azure 应用程序注册中获取令牌。
我按照说明 here 并使用 Powershell 生成了自签名证书。我还将 public 密钥导入到门户中。
但是如果我想通过 .NET 访问应用程序,我需要提供以下 MSAL 配置:
CertificateFileContents 就是我从 certgmgr 导出的 public 密钥。但是我应该把什么作为 CertificatePass?这是哈希吗?还是私钥?我在文档中找不到任何内容,而且上面的 link 也没有给我任何建议...
我也不太明白为什么私钥没有导入到门户中?
根据我的经验,导出私钥时应该需要 CertificatePass。
本文档之前有这样的内容:
Export the private key, specify a password for the cert file, and
export to a file.
但是现在它只告诉你导出一个public密钥。您可以从 this issue.
查看详细信息
因此,根据 SharePoint document,如果您正在从本地计算机读取 PFX 文件,我认为您应该使用带密码的私钥。
好的,CertificatePass 是证书本身的密码。
Azure 门户本身仅包含 public 密钥。
客户端应用程序需要提供带有私钥和 public 密钥的整个证书。
如果您在 Windows 10 中从证书管理器导出 private/public 密钥,您将无法直接将其导出为 base64,但您可以创建一个 pfx 文件。
稍后可以使用您选择的工具将这些文件编码为 Base64。例如 this.
证书的密码必须是 CertificatePass,FileContents 是 Base64 public 和私钥,但使用密码解密。
这当然只是一种用于测试目的的方法。在生产环境中,您宁愿使用密钥保管库或类似的东西,而不是在 appsettings.json.
中没有任何秘密
我想从带有证书的 Azure 应用程序注册中获取令牌。
我按照说明 here 并使用 Powershell 生成了自签名证书。我还将 public 密钥导入到门户中。
但是如果我想通过 .NET 访问应用程序,我需要提供以下 MSAL 配置:
CertificateFileContents 就是我从 certgmgr 导出的 public 密钥。但是我应该把什么作为 CertificatePass?这是哈希吗?还是私钥?我在文档中找不到任何内容,而且上面的 link 也没有给我任何建议...
我也不太明白为什么私钥没有导入到门户中?
根据我的经验,导出私钥时应该需要 CertificatePass。
本文档之前有这样的内容:
Export the private key, specify a password for the cert file, and export to a file.
但是现在它只告诉你导出一个public密钥。您可以从 this issue.
查看详细信息因此,根据 SharePoint document,如果您正在从本地计算机读取 PFX 文件,我认为您应该使用带密码的私钥。
好的,CertificatePass 是证书本身的密码。
Azure 门户本身仅包含 public 密钥。
客户端应用程序需要提供带有私钥和 public 密钥的整个证书。
如果您在 Windows 10 中从证书管理器导出 private/public 密钥,您将无法直接将其导出为 base64,但您可以创建一个 pfx 文件。
稍后可以使用您选择的工具将这些文件编码为 Base64。例如 this.
证书的密码必须是 CertificatePass,FileContents 是 Base64 public 和私钥,但使用密码解密。
这当然只是一种用于测试目的的方法。在生产环境中,您宁愿使用密钥保管库或类似的东西,而不是在 appsettings.json.
中没有任何秘密