views:

96

answers:

1

We have a function to send files to a public server usin X509 cert in C#, but the issue is on the receiving end the cert is not being picked up. we get a 403.7 message saying cert not supplied. the code to add the cert is as followed:

        try
        {
            X509Certificate certificate = X509Certificate.CreateFromCertFile(certificatePath);
            httpWebRequest.ClientCertificates.Add(certificate);
        }
        catch (Exception CertificateException)
        {
            return "Failed to add certificate to post:" + certificatePath + " " + CertificateException.Message;
        }

any thoughts

+1  A: 

Does the certificate have a corresponding private key? X509Certificate.CreateFromCertFile doesn't support loading certificates with a private key. You need to get the certificate from a certificate store with the private key or maybe from a PFX file - http://msdn.microsoft.com/en-us/library/ms148420.aspx

Pent Ploompuu
Yes I had figured out the issue but good job on figuring it out! +1 :)
greektreat