Tips and Tricks in a world of Mix

Posts tagged ‘certificate’

TrustAllCertificatePolicy – Handles a call to a web service via SSL that does not have a valid server certificate

    
/// <summary>
    /// Handles a call to a web service via SSL that does not have a valid server certificate
    /// </summary>
    /// <example>
    /// locate this code at the authorization class before validating the web service
    /// System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();
    /// </example>
    public class TrustAllCertificatePolicy : System.Net.ICertificatePolicy
    {
        public TrustAllCertificatePolicy()
        { }

         public bool CheckValidationResult(ServicePoint sp,
         X509Certificate cert, WebRequest req, int problem)
        {
            return true;
        }
    }

Tag Cloud

%d bloggers like this: