Using X509Certificate class and private key RRS feed

  • Question


    Hi Experts,

    I have a C# application that uses client certificate to talk to an apache web server.  I have the client certificate chain and the corresponding private key.  I was able to get it working after I change the certificate to PKCS12 format where I incorporate the certificate and the private key into a .p12 file.  Then I had to install the .p12 certificate in the Windows XP PC I was running the client. All seems to work.  But, I would like to use the certificate and the private key as is is, without formatting them to a .p12 format.  So, what I am trying to do is to tell the app that this is the cert file and this is the priv key file, and get it from these files instead of I have to install that in the PC.  

    If I try to use the cert as it, in PEM format(cer file) then how can I associate the private key file.
    Where can I get the documentation for X509Certificate class

    string certificatePath = "cert.p12";
    string certificatePassword = "testpasswd";
    X509Certificate clientCertificate = new X509Certificate2(certificatePath, certificatePassword);
    = new TestApp.WebReference.Features();
    I find references to
    string certFile = "C:\\certfile.cer";
    X509Certificate certificate = X509Certificate.CreateFromCertFile(certFile);
    But, how do I associate the private key???
    Saturday, February 16, 2008 5:23 PM

All replies

  • Any suggestions Please..

    Sunday, February 17, 2008 12:04 AM
  • Try using an X509Certificate2 Object, that allows you to associate a PrivateKey.





    • Proposed as answer by Nitin Bhatt Thursday, September 1, 2011 11:24 PM
    Wednesday, February 20, 2008 2:48 AM