Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignoring invalid SSL certificate

I`m trying to print out log messages from our sub version. But I'm struggling with bypassing the invalid SSL certificate. This is the error:

OPTIONS of 'https://xxxxx/svn/SiteFabrics/trunk/AppLaunch/Bloc/Frontend': Server certificate verification failed: certificate issued for a different hostname, issuer is not trusted (https://xxxx)

My attempt of ignoring the certificate error was to add this line:

ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;

However that didn't make any difference as the .net error is still the same. Below is the code, can anyone see what I am doing wrong?

        using (SvnClient client = new SvnClient())
        {
            Collection<SvnLogEventArgs> list;
            client.Authentication.DefaultCredentials = new NetworkCredential("user", "pass");

            ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;

            SvnLogArgs la = new SvnLogArgs(); //{ Start=128; End=132; };
            client.LoadConfiguration(Path.Combine(Path.GetTempPath(), "Svn"), true);
            client.GetLog(new Uri("https://[svnurl]"), la, out list);
            ViewBag.SVNLog = list;
        }
like image 239
Joakim Avatar asked Nov 14 '11 11:11

Joakim


People also ask

How do I ignore an invalid certificate in Chrome?

Disable Chrome Checking All SSL Certificates If you're on Windows simply right-click into the properties of the launcher. Then add --ignore-certificate-errors in the target field. Then restart Chrome.

What happens if SSL certificate is invalid?

An SSL certificate error occurs when the browser cannot verify the SSL certificates returned by the server. When the error happens, the browser blocks the website and warns the user that the website cannot be trusted as shown below. These warnings will negatively impact the user's trust in your website.


1 Answers

FOUND THE SOLUTION TO THIS PROBLEM:

First add this:

        static void SVN_SSL_Override(object sender, SharpSvn.Security.SvnSslServerTrustEventArgs e)
    {
        e.AcceptedFailures = e.Failures;
        e.Save = true;
    }

and then replace my original magic line:

            ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;

with this:

client.Authentication.SslServerTrustHandlers += new EventHandler<SharpSvn.Security.SvnSslServerTrustEventArgs>(SVN_SSL_Override);
like image 159
Joakim Avatar answered Sep 24 '22 15:09

Joakim