Information Security Stack Exchange is a question and answer site for information security professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Let me explain my situation.

I created a self-signed certificate and installed it in the Trusted Root Certification Authorities section in MMC.

I then created two certificates using the self-signed certificate:

  1. A certificate with subject name "localhost"
  2. A certificate with subject name ""

I then installed both certificates into the Personal certificates section in MMC.

I then deployed a web service as HTTPS (SSL with accept client certificates) in IIS. The certificate used to deploy the web service is the one with subject name "localhost".

Now, I have a client who wants to connect to the web service. I successfully added a web reference to the service. This is the code:

            ClientServices web_service = new ClientServices();
            X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
            X509Certificate2Collection col = store.Certificates.Find(X509FindType.FindBySubjectName, "", true);

            if (col.Count == 1)
                ServicePointManager.Expect100Continue = true;
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;

                    string hello = web_service.HelloWorld();
                    int add = web_service.add(4, 31);
                    int sub = web_service.subtract(30, 10);

                catch (WebException e)

                Console.WriteLine("The certificate was not found!");

As you can see, I am sending the "" certificate along with the web service request. Unfortunately, I am getting this exception:

The request was aborted: Could not create SSL/TLS secure channel

How can I solve this problem? I have already wasted 3 hours on this issue. Please help me.

share|improve this question
up vote 0 down vote accepted
        X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);

You're using the LocalMachine store. Either put your certificates are 'Machine Certificates' in mmc, (elevated MMC -> certificate snap-in -> Computer Account), or use the CurrentUser store.

Also this might be a better question for StackExchange since it's C#/Programming related.

share|improve this answer
The certificate is being located and loaded from the store. I checked by debugging the program. The problem is when the call for the web service is being made – Joe Borg Apr 25 '13 at 17:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.