Ori Refael
Ori Refael

Reputation: 3008

C# x509Certificate2 cannot be created

im creating a certificate via a byte array I make from an Apple .p12 file.

X509Certificate2 cert = new X509Certificate2(AppleCertBytes, ApplePassword);

this works fine and creates the cert,BUT, only when im on localhost.

When i build and publish my WebService to the server it doesn't work.

I placed logs wherever I can, and i noticed that the request sort of gone when running this row.

I get no response for server and sometimes even get Err: connection_reset. When i debug the process i don't see any errors, and i thought maybe the .dll file was the issue bug I think i checked it for like 11 times with different logs and it seems updated at anytime.

EDIT No exception is thrown.

Is there anything I'm missing here? ApplicationPool maybe, plugin or such?

PLEASE NOTICE.

I DON'T want any plugins that create the certificate, i want a possible results. Thanks.

Upvotes: 1

Views: 551

Answers (1)

rene
rene

Reputation: 42414

You need to use another overload of the constructor to store the private keys in the local computer store.

Your constructor should read:

var cert = new X509Certificate2(
                        AppleCertBytes, 
                        ApplePassword,
                        X509KeyStorageFlags.MachineKeySet);

Upvotes: 2

Related Questions