HTTPS and Certificate

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default HTTPS and Certificate

    Hello.
    I have an ASP .NET Application that I have been using
    that calls a web service on another machine.

    Our company wants to implement HTTPS between the two
    applications. I have changed the call to the web service
    URL to [url]https://example:8700/example[/url]. Now I get a message
    indicating:

    The underlying connection was closed: Could not establish
    trust relationship with remote server.

    Does anyone know what I need to do to implement HTTPS? I
    have installed the certificate through my browser in a
    trusted folder but I can't get my development environment
    (Visual Studio) to work. A piece of example code would be
    great.

    I have seen the same error on many other posts but didn't
    see a resolution. Thanks for your help.

    Chris Guest

  2. Similar Questions and Discussions

    1. #38631 [Bgs]: fopen('https://...') or curl with https gives Segmentation fault
      ID: 38631 Updated by: darkelder@php.net Reported By: roberto dot berto at gmail dot com Status: Bogus Bug...
    2. Win32::OLE and CAPICOM to find a certificate in certificate store will raise exception
      Hi, I am trying to use win32::OLE to access certificate store via CAPICOM. If certificates in the store meet the searching criteria, the...
    3. Error when trying to connect over HTTPS using a client certificate.
      Hi, I am trying to connect over HTTPS using a client certificate. I am able to connect fine when using IE. From my application, however, I get...
    4. PHP HTTPS POST Como hacer un POST https con PHP
      http://wedoit4you.com/forums4you/display_message.php?Msg_pk_id=628 /** Author: Ing. Angel Leon Function: postHttps($url,$params) Given the...
    5. Certificate Server and Windows XP - Cannot install certificate
      Hello all, I would like to implement certificate server. I have installed the service on Win2003 server in standalone mode. I have created from...
  3. #2

    Default HTTPS and Certificate

    Hello.
    I have an ASP .NET Application that I have been using
    that calls a web service on another machine.

    Our company wants to implement HTTPS between the two
    applications. I have changed the call to the web service
    URL to [url]https://example:8700/example[/url]. Now I get a message
    indicating:

    The underlying connection was closed: Could not establish
    trust relationship with remote server.

    Does anyone know what I need to do to implement HTTPS? I
    have installed the certificate through my browser in a
    trusted folder but I can't get my development environment
    (Visual Studio) to work. A piece of example code would be
    great.

    I have seen the same error on many other posts but didn't
    see a resolution. Thanks for your help.

    I have tried the following code before the call:

    wsDBObj.Credentials = CredentialCache.DefaultCredentials
    Dim sCertName As String = "C:\TestSSLCertificate\test.cer"
    If sCertName.Length <> 0 Then
    Dim x509 As X509Certificate =
    X509Certificate.CreateFromCertFile(sCertName)
    wsDBObj.ClientCertificates.Add(x509)
    End If

    chris Guest

  4. #3

    Default Re: HTTPS and Certificate

    Could it be a problem with the certificate name not matching the URL and the
    cert policy causing the failure? I've seen lots of weird cert policy
    problems cause failures in the underlying webrequest object that the client
    proxy uses.

    To combat this, you can create your own ICertificatePolicy class and add it
    to the ServicePointManager CertificatePolicy property. I usually have the
    CheckValidationResult return true for all cases to start with and then go
    from there.

    If that fixes the problem, then you know it was a certificate trust issue
    that caused the failure.

    HTH,

    Joe K.

    "Chris" <anonymous@discussions.microsoft.com> wrote in message
    news:055301c3daaa$3f10b1a0$a001280a@phx.gbl...
    > Hello.
    > I have an ASP .NET Application that I have been using
    > that calls a web service on another machine.
    >
    > Our company wants to implement HTTPS between the two
    > applications. I have changed the call to the web service
    > URL to [url]https://example:8700/example[/url]. Now I get a message
    > indicating:
    >
    > The underlying connection was closed: Could not establish
    > trust relationship with remote server.
    >
    > Does anyone know what I need to do to implement HTTPS? I
    > have installed the certificate through my browser in a
    > trusted folder but I can't get my development environment
    > (Visual Studio) to work. A piece of example code would be
    > great.
    >
    > I have seen the same error on many other posts but didn't
    > see a resolution. Thanks for your help.
    >

    Joe Kaplan \(MVP - ADSI\) Guest

  5. #4

    Default Re: HTTPS and Certificate

    [url]http://weblogs.asp.net/jan/archive/2003/12/04/41154.aspx[/url]

    When Webservices are used, a common concern is security: SOAP messages are
    transferred in plain text over the network, so anyone with a sniffer could
    intercept the SOAP message and read it. In my opinion this could happen also
    to binary data, but probably it requires a little bit more hacker skills. So
    a solution is to use HTTPS (SSL) instead of HTTP, so the communication is
    encrypted. To accomplish this, you need to get and install a certificate
    (issued by a Certificate Authority) on your webserver. In a production
    environment you would buy a certificate from Verisign or another well known
    CA, or you would install your own CA, which is a component of Windows
    Server. If you only want to play with HTTPS, SSL and certificates or your
    project is in the development phase, you can also generate a test
    certificate using the MakeCert.exe tool (included in the .NET Framework
    SDK). After that you have to add this certificate to a website in IIS, and
    set a port which HTTPS should use.

    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.
    --
    Greetz,
    Jan
    __________________________________
    Read my weblog: [url]http://weblogs.asp.net/jan[/url]

    "chris" <anonymous@discussions.microsoft.com> schreef in bericht
    news:0c9801c3dabd$0e015bb0$a501280a@phx.gbl...
    > Hello.
    > I have an ASP .NET Application that I have been using
    > that calls a web service on another machine.
    >
    > Our company wants to implement HTTPS between the two
    > applications. I have changed the call to the web service
    > URL to [url]https://example:8700/example[/url]. Now I get a message
    > indicating:
    >
    > The underlying connection was closed: Could not establish
    > trust relationship with remote server.
    >
    > Does anyone know what I need to do to implement HTTPS? I
    > have installed the certificate through my browser in a
    > trusted folder but I can't get my development environment
    > (Visual Studio) to work. A piece of example code would be
    > great.
    >
    > I have seen the same error on many other posts but didn't
    > see a resolution. Thanks for your help.
    >
    > I have tried the following code before the call:
    >
    > wsDBObj.Credentials = CredentialCache.DefaultCredentials
    > Dim sCertName As String = "C:\TestSSLCertificate\test.cer"
    > If sCertName.Length <> 0 Then
    > Dim x509 As X509Certificate =
    > X509Certificate.CreateFromCertFile(sCertName)
    > wsDBObj.ClientCertificates.Add(x509)
    > End If
    >

    Jan Tielens Guest

  6. #5

    Default Re: HTTPS and Certificate

    As a start point, you may try to visit your new service
    [url]https://example:8700/example[/url] using IE, you will see a few dialog boxes
    poping up which will provide information on exactly what is not accepted by
    your computer.

    "Chris" <anonymous@discussions.microsoft.com> wrote in message
    news:055301c3daaa$3f10b1a0$a001280a@phx.gbl...
    > Hello.
    > I have an ASP .NET Application that I have been using
    > that calls a web service on another machine.
    >
    > Our company wants to implement HTTPS between the two
    > applications. I have changed the call to the web service
    > URL to [url]https://example:8700/example[/url]. Now I get a message
    > indicating:
    >
    > The underlying connection was closed: Could not establish
    > trust relationship with remote server.
    >
    > Does anyone know what I need to do to implement HTTPS? I
    > have installed the certificate through my browser in a
    > trusted folder but I can't get my development environment
    > (Visual Studio) to work. A piece of example code would be
    > great.
    >
    > I have seen the same error on many other posts but didn't
    > see a resolution. Thanks for your help.
    >

    Guogang Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139