Click here to Skip to main content
12,950,084 members (63,785 online)
Click here to Skip to main content
Add your own
alternative version


20 bookmarked
Posted 2 Feb 2007

Send a request to an SSL page from C#

, 2 Feb 2007 CPOL
Rate this:
Please Sign up or sign in to vote.
How to send a request to an SSL page from C#.


Here, we will see a simple way to make a request to a page of type SSL from C#, using the HttpWebRequest class.

You can take this article as a reference:


The first thing we must do is generate a class that implements the IcertificatePolicy interface. The class will have the form:

public class MyPolicy : ICertificatePolicy 
    public bool CheckValidationResult( 
            ServicePoint srvPoint 
            , X509Certificate certificate 
            , WebRequest request 
            , int certificateProblem) 
        //Return True to force the certificate to be accepted. 
        return true; 
    } // end CheckValidationResult 

Next, to use this class, we must write:

//Set certificatePolicy. 
System.Net.ServicePointManager.CertificatePolicy = new MyPolicy();

This call will be done before we instantiate the HttpWebRequest class. Before we run the application, we must modify the machine.config file, which is in the %WINDIR%\Microsoft.NET\Framework\v1.1.4322\CONFIG directory. The modifications should be:

Find the node called servicePointManager and modify the value of the checkCertificateName attribute. This has the value true by default, and you must change the value to false. Then this node will look like this:

<servicePointManager checkCertificateName="false" 


Refer to Send a content type “multipart/form-data” request from C# for an example.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Pablo Russoniello
Web Developer
Argentina Argentina
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralThanks Pablo, Pin
ij_mac8-May-07 6:16
memberij_mac8-May-07 6:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170525.1 | Last Updated 2 Feb 2007
Article Copyright 2007 by Pablo Russoniello
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid