Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After some research, I found a blog entry by <a href="http://weblogs.asp.net/jan/archive/2003/12/04/41154.aspx" rel="noreferrer">Jan Tielens</a> which explains what is going on and a workaround for my problem:</p> <blockquote> <p>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:</p> <blockquote> <p><strong>An unhandled exception of type <code>System.Net.WebException</code> occurred in System.dll</strong><br> Additional information: The underlying connection was closed: Could not establish trust relationship with remote server.</p> </blockquote> <p>But there is a solution for this problem, you can solve this in your code by creating your own <code>CertificatePolicy</code> class (which implements the <code>ICertificatePolicy</code> interface). In this class you will have to write your own <code>CheckValidationResult</code> function that has to return <code>true</code> or <code>false</code>, 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 <code>WebException</code> anymore:</p> </blockquote> <pre><code>public class TrustAllCertificatePolicy : System.Net.ICertificatePolicy { public TrustAllCertificatePolicy() { } public bool CheckValidationResult(ServicePoint sp, X509Certificate cert, WebRequest req, int problem) { return true; } } </code></pre> <blockquote> <p>As you can see the <code>CheckValidationResult</code> 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 <code>X509Certificate</code> parameter for example. To use this <code>CertificatePolicy</code>, you'll have to tell the <code>ServicePointManager</code> to use it:</p> </blockquote> <pre><code>System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy(); </code></pre> <blockquote> <p>This must be done (one time during the application life cycle) before making the call to your webservice.</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload