locked
SSL + IIS + C# RRS feed

  • Question

  • User-1753513272 posted

    I'm currently building a client that consumes a SSL webservice but I'm getting the following error:
    "The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. The remote certificate is invalid according to the validation procedure."
    Ok what have I done so far:
     
    Webserver:
    I created a certificate with makecert and installed it on the webservice ( IIS ). I installed the certificate on the webserver in the Certificate Store under: Trusted CertificateAuthority.
     
    Client:

    I didnt install the certificate on the client but I read it in my code:
    string strFilename = @"E:\VS2008\Projecten\SecureWebservice\SecureWinForm\server01.pfx";
    X509Certificate2 x509 = new X509Certificate2(strFilename, "pwd");
    X509Store store = new X509Store(StoreName.CertificateAuthority);
    store.Open(OpenFlags.ReadWrite);
    store.Add(x509);
    store.Close();
    testservice client = new testservice();
    client.ClientCertificates.Add(x509);
    MessageBox.Show(client.HelloWorld());
     
    What am i missing here?
    Thank you in advance!
    Dario Leanza

    Tuesday, January 27, 2009 6:22 AM

Answers

  • User1632528892 posted

    Hi,

    Is the certificate trusted by both the client and the server ? If it isn't you will get a warning which your code may not be able to handle correctly.

    Regards,

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Tuesday, January 27, 2009 8:00 AM