【问题标题】:Invalid provider type specified. CryptographicException指定的提供程序类型无效。加密异常
【发布时间】:2018-06-19 05:20:54
【问题描述】:

我正在尝试从 Microsoft docs help setting up a Key Vault 运行脚本 GetAppConfigSettings.ps1

脚本包含以下内容

# **********************************************************************************************
# Prep the cert credential data
# **********************************************************************************************
$certificateName = "$applicationName" + "cert"
$myCertThumbprint = (New-SelfSignedCertificate -Type Custom -Subject "$certificateName"-KeyUsage DigitalSignature -KeyAlgorithm RSA -KeyLength 2048 -CertStoreLocation "Cert:\CurrentUser\My" -Provider "Microsoft Enhanced Cryptographic Provider v1.0" ).Thumbprint
$x509 = (Get-ChildItem -Path cert:\CurrentUser\My\$myCertthumbprint)
$password = Read-Host -Prompt "Please enter the certificate password." -AsSecureString

# Saving the self-signed cert and pfx (private key) in case it's needed later
Export-Certificate -cert $x509 -FilePath ".\$certificateName.cer"
Export-PfxCertificate -Cert $x509 -FilePath ".\$certificateName.pfx" -Password $password

运行脚本(设置变量后)会产生以下错误

New-SelfSignedCertificate : CertEnroll::CX509Enrollment::_CreateRequest: Provider type not defined. 
0x80090017 (-2146893801 NTE_PROV_TYPE_NOT_DEF)
At \\tsclient\E\EShared\Dev\Microsoft.Azure.KeyVault.Samples-2016.11.22 
(1)\Microsoft.Azure.KeyVault.Samples\scripts\GetAppConfigSettings.ps1:38 char:22
+ ... umbprint = (New-SelfSignedCertificate -Type Custom -Subject "$certifi ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-SelfSignedCertificate], Exception
    + FullyQualifiedErrorId : System.Exception,Microsoft.CertificateServices.Commands.NewSelfSignedC 
   ertificateCommand

[更新]

Microsoft 支持建议我将提供程序更改为“Microsoft Platform Crypto Provider”

但是我仍然得到错误。

对于 Powershell,$PSVersionTable 报告 5.1.17134.112

我安装了 AzureRM 5.7.0 版

【问题讨论】:

标签: powershell azure-keyvault


【解决方案1】:

Microsoft 支持帮助我解决了这一问题

$myCertThumbprint = (New-SelfSignedCertificate -CertStoreLocation Cert:\CurrentUser\My
-subject MyCert -KeyExportPolicy Exportable -NotAfter (Get-Date).AddYears(10) 
-Type CodeSigningCert -KeySpec Signature).Thumbprint

已创建 HelloKeyVault app.config 所需的 AuthClientId 和 AuthCertThumbprint 值。

AuthClientId 在门户中显示为应用程序 ID,并且在已注册的应用程序设置中可见。

要访问它,请单击 Azure Active Directory -> 应用注册 然后点击查看所有应用程序 点击应用然后设置

要查看指纹也是如此,然后单击键

我可以看到 AuthClientId

【讨论】:

    【解决方案2】:

    请使用此示例了解如何将 Key Vault 与 DotNet 结合使用,并使用服务主体的证书对 Azure Active Directory 进行身份验证 https://github.com/Azure-Samples/key-vault-dotnet-quickstart

    【讨论】:

    • 谢谢。我在github项目中提出了一些问题/
    • 很遗憾你删除了这个项目。您使用 Bouncy Castle 而不是 Key Vault 本身的任何原因?
    猜你喜欢
    • 1970-01-01
    • 2019-02-03
    • 1970-01-01
    • 1970-01-01
    • 2018-01-08
    • 2021-11-27
    • 2021-05-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多