Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8141545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:32:47+00:00 2026-06-06T12:32:47+00:00

It is the first time I have to use certificate authentication. A commercial partner

  • 0

It is the first time I have to use certificate authentication.
A commercial partner expose two services, a XML Web Service and a HTTP service. I have to access both of them with .NET clients.

What I have tried

0. Setting up the environment

I have installed the SSLCACertificates (on root and two intermediate) and the client certificate in my local machine (win 7 professional) using certmgr.exe.

1. For the web service

  • I have the client certificate (der).
  • The service will be consumed via a .NET proxy.

Here’s the code:

OrderWSService proxy = new OrderWSService();
string CertFile = "ClientCert_DER.cer";

proxy.ClientCertificates.Add(new System.Security.Cryptography.X509Certificates.X509Certificate(CertFile));
orderTrackingTO ot = new orderTrackingTO() { order_id = "80", tracking_id = "82", status = stateOrderType.IN_PREPARATION };
resultResponseTO res = proxy.insertOrderTracking(ot);

Exception reported at last statement: The request failed with an empty response.

2. For the HTTP interface

  • it is a HTTPS interface I have to call through POST method.
  • The HTTPS request will be send from a .NET client using HTTPWebRequest.

Here’s the code:

string PostData = "MyPostData";

//setting the request
HttpWebRequest req;
req = (HttpWebRequest)HttpWebRequest.Create(url);
req.UserAgent = "MyUserAgent";
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ClientCertificates.Add(new System.Security.Cryptography.X509Certificates.X509Certificate(CertFile, "MyPassword")); 

//setting the request content
byte[] byteArray = Encoding.UTF8.GetBytes(PostData);
Stream dataStream = req.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();

//obtaining the response
WebResponse res = req.GetResponse();
r = new StreamReader(res.GetResponseStream());

Exception reported at last statement: The request was aborted: Could not create SSL/TLS secure channel.

3. Last try: using the browser

In Chrome, after installing the certificates, if I try to access both urls I get a 107 error:

Error 107 (net::ERR_SSL_PROTOCOL_ERROR)

I am stuck.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T12:32:48+00:00Added an answer on June 6, 2026 at 12:32 pm

    The following should help you identify the issue, here are two methods to test SSL connectivity one tests the site whilst the other is a callback method to identify why SSL failed. If nothing else it should give you a better idea why it is failing.

    When the method is called it will pop up with the select certificate dialog box, obviously when you do this for real you’ll want to read from the cert store automatically. The reason I have put this in is because if no valid certificate is found then you will know your problem is with the way the certificate is installed.

    The best thing to do is put this code in a simple console app:

    using System.Security.Cryptography.X509Certificates;
    using System.Net.Security;
    using System.Net;
    
    private static void CheckSite(string url, string method)
    {
        X509Certificate2 cert = null;
        ServicePointManager.ServerCertificateValidationCallback += ValidateRemoteCertificate;
    
        X509Store store = new X509Store(StoreLocation.LocalMachine);
        store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
        X509Certificate2Collection certcollection = (X509Certificate2Collection)store.Certificates;
        // pick a certificate from the store
        cert = X509Certificate2UI.SelectFromCollection(certcollection, 
                "Caption",
                "Message", X509SelectionFlag.SingleSelection)[0];
    
        store.Close();
    
        HttpWebRequest ws = (HttpWebRequest)WebRequest.Create(url);
        ws.Credentials = CredentialCache.DefaultCredentials;
        ws.Method = method;
        if (cert != null)
            ws.ClientCertificates.Add(cert);
    
        using (HttpWebResponse webResponse = (HttpWebResponse)ws.GetResponse())
        {
            using (Stream responseStream = webResponse.GetResponseStream())
            {
                using (StreamReader responseStreamReader = new StreamReader(responseStream, true))
                {
                    string response = responseStreamReader.ReadToEnd();
                    Console.WriteLine(response);
                    responseStreamReader.Close();
                }
    
                responseStream.Close();
            }
            webResponse.Close();
        }
    }
    
    /// <summary>
    /// Certificate validation callback.
    /// </summary>
    private static bool ValidateRemoteCertificate(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors error)
    {
        // If the certificate is a valid, signed certificate, return true.
        if (error == System.Net.Security.SslPolicyErrors.None)
        {
            return true;
        }
    
        Console.WriteLine("X509Certificate [{0}] Policy Error: '{1}'",
            cert.Subject,
            error.ToString());
    
        return false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

first time use JTree. Just wondering is it possible to have more than one
I am tryign to use Doctrine_Pager for the first time. So I have the
I have some problem with this mongoid. It's my first time to use mongoDB,
first time posting here so be gentle :) On my web pages I have
I'm writing my first C# web application that connects to an XML based service.
I am trying to use a mutex for the first time and have the
For my job, I have to use Hibernate for the first time on a
It's the first time I have done anything like this but wondered what the
This is the first time I have manipulated hashes and arrays in this way
This is the first time I have attempted to create a .dll, that will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.