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

  • Home
  • SEARCH
  • 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 6102673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:38:30+00:00 2026-05-23T13:38:30+00:00

When making a call to a web service running on a server using HTTPS

  • 0

When making a call to a web service running on a server using HTTPS my application throws a System.Net.WebException with the message “The underlying connection was closed: Could not establish trust relationship with remote server”. I’m not sure how to get around this issue and successfully make the call.

  • 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-05-23T13:38:31+00:00Added an answer on May 23, 2026 at 1:38 pm

    After some research, I found a blog entry by Jan Tielens which explains what is going on and a workaround for my problem:

    When you browse to a HTTPS site, you probably get a dialog window asking you if you want to trust the certificate provided by the webserver. So the responsibility of accepting the certificate is handled by the user. Let’s get back to the webservice scenario, if you want to invoke a webservice located on a webserver which uses SSL and HTTPS there is a problem. When you make the call from code, there is no dialog window popping up, and asking if you trust the certificate (luckily because this would be pretty ugly in server-side scenarios); probably you’ll get following exception:

    An unhandled exception of type System.Net.WebException occurred in System.dll
    Additional information: The underlying
    connection was closed: Could not
    establish trust relationship with
    remote server.

    But there is a solution for this
    problem, you can solve this in your
    code by creating your own
    CertificatePolicy class (which
    implements the ICertificatePolicy
    interface). In this class you will
    have to write your own
    CheckValidationResult function that
    has to return true or false, like you
    would press yes or no in the dialog
    window. For development purposes I’ve
    created the following class which
    accepts all certificates, so you won’t
    get the nasty WebException anymore:

    public class TrustAllCertificatePolicy : System.Net.ICertificatePolicy
    {
        public TrustAllCertificatePolicy() { }
    
        public bool CheckValidationResult(ServicePoint sp, X509Certificate cert, WebRequest req, int problem)
        {
            return true;
        }
    }
    

    As you can see the
    CheckValidationResult function always
    returns true, so all certificates will
    be trusted. If you want to make this
    class a little bit more secure, you
    can add additional checks using the
    X509Certificate parameter for example.
    To use this CertificatePolicy, you’ll
    have to tell the ServicePointManager
    to use it:

    System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();
    

    This must be done (one time during the
    application life cycle) before making
    the call to your webservice.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ASP.NET web application running on an IIS6 server. The application is
I am using a third-party application, and making a call to create an instance
If I'm making a call to an ASMX web service and an exception occurs,
I have a simple ASP.NET site making a call to a WCF service. The
making a call to a web service method with nusoap returns an error array(3)
When making a call out to the yahoo web service (http://boss.yahooapis.com/ysearch) to return a
I'm working on a web page where I'm making an AJAX call that returns
I'm having a big problem when calling a web service from my WPF application.
I've got an asp.net web page that is making 7 async requests to a
I've got a Silverlight app that talks to an HTTPS web service. On most

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.