1

I'm having problems creating a test X509Certificate in my store that I can use in WCF. All of the certificates I create have the same result when I try to use it in the WCF channel factory - "The private key is not present in the X.509 certificate".

channelFactory.Credentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.TrustedPeople, X509FindType.FindBySubjectName, "MyClientCert");

I've tried putting the certificate in LocalMachine, having it self-signed vs. a test CA. Nothing helps, the certificate always has the property HasPrivateKey equal to false.

UPDATES: I've gotten past the above problem, by following the instructions at http://msdn.microsoft.com/en-us/library/ff650751.aspx. However, I'm onto a new problem with the certificate now generating a new error when I try to send the message to the queue. The error is:

An error occurred while sending to the queue: A cryptographic function failed. (-1072824272, 0xc00e0030).Ensure that MSMQ is installed and running. If you are sending to a local queue, ensure the queue exists with the required access mode and authorization.

Again, the process works if I use a real cert instead of a test one, so it seems like it has to be something related to the certificate.

Random
  • 1,896
  • 3
  • 21
  • 33
  • 2
    http://msdn.microsoft.com/en-us/library/aa702621.aspx – NickD Mar 28 '13 at 21:21
  • your cert is false generated, probably for signing not keyexchange – NickD Mar 28 '13 at 21:27
  • I'm using the -sky exchange... parameter. The link you provided is good, but still doesn't provide me with a solution. – Random Mar 28 '13 at 21:49
  • how do you export from the pfx? – NickD Mar 28 '13 at 21:56
  • Posted updates above. I'm not exporting anything from a pfx. I generate the cert and revocation list, import them into the store, then generate a client cert directly. No exporting at all. – Random Mar 29 '13 at 15:51

0 Answers0