“Invalid provider type specified” CryptographicException when trying to load private key of certificate

前端 未结 18 2912
盖世英雄少女心
盖世英雄少女心 2020-11-29 22:04

I\'m trying to read the private key of a certificate which has been shared with me by a third-party service provider, so I can use it to encrypt some XML before sending it t

18条回答
  •  旧巷少年郎
    2020-11-29 22:36

    In my case, I was trying to use a self-signed certificate with PowerShell's New-SelfSignedCertificate command. By default, it will generate a certificate using the CNG (Crypto-Next Generation) API instead of the older/classic crypto CAPI. Some older pieces of code will have trouble with this; in my case it was an older version of the IdentityServer STS provider.

    By adding this at the end of my New-SelfSignedCertificate command, I got past the issue:

    -KeySpec KeyExchange

    Reference on the switch for the powershell command:

    https://docs.microsoft.com/en-us/powershell/module/pkiclient/new-selfsignedcertificate?view=win10-ps

提交回复
热议问题