WindowsCryptographicException: Keyset does not exist

后端 未结 3 1080
再見小時候
再見小時候 2021-02-04 02:07

I want to create or obtain a certificate, create a pfx-file, load it and have IdentityServer use it. However, IdentityServer is not able to use my pfx.

How to successful

3条回答
  •  感情败类
    2021-02-04 02:18

    I followed that blog post too and also had that issue. The problem was when you run this to create PKCS12 file:

    openssl pkcs12 -export -out example.pfx -inkey example.key -in example.crt -certfile example.crt
    

    Try to remove -certfile example.crt and it should work.

    Also according to .NET Core X509Certificate2 usage (under Windows/IIS, Docker, Linux) you can test if certificate was loaded from file correctly by accessing cert.PrivateKey. E.g.

    X509Certificate2 cert = new X509Certificate2(Path.Combine(Directory.GetCurrentDirectory(), "cert.pfx"), "password");
    Console.WriteLine("cert private key: " + cert.PrivateKey);
    

提交回复
热议问题