Mono has no root certs! Uglyhacking.

This commit is contained in:
Rick Falkvinge
2014-12-27 21:06:02 +01:00
parent 8392247bfb
commit 6ee42d2787
3 changed files with 27 additions and 0 deletions
+3
View File
@@ -9,6 +9,7 @@ using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Xml.Serialization;
using Swarmops.Basic.Types.Financial;
using Swarmops.Logic.Support;
namespace Swarmops.Logic.Financial
{
@@ -39,6 +40,8 @@ namespace Swarmops.Logic.Financial
{
using(WebClient client = new WebClient())
{
SupportFunctions.DisableSslCertificateChecks(); // MONO BUG/MISFEATURE: Mono has no root certificates, so can't verify cert
client.Encoding = Encoding.UTF8;
string rateDataRaw = client.DownloadString("https://bitpay.com/api/rates");
+1
View File
@@ -252,6 +252,7 @@
<Compile Include="Support\ActivistEvents.cs" />
<Compile Include="Support\DatabaseMaintenance.cs" />
<Compile Include="Support\ExtensionMethods.cs" />
<Compile Include="Support\General.cs" />
<Compile Include="Support\Imagery.cs" />
<Compile Include="Support\IXmlPayload.cs" />
<Compile Include="Support\LogEntries\CashAdvanceRequestedLogEntry.cs" />
+23
View File
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
namespace Swarmops.Logic.Support
{
public class SupportFunctions
{
public static void DisableSslCertificateChecks()
{
// X.509 is SO SO SO broken. The reason we do this, btw, is that mono doesn't come with root certs. At all.
// This disables certificate checking completely and accepts ALL certificates.
System.Net.ServicePointManager.ServerCertificateValidationCallback +=
(sender, certificate, chain, sslPolicyErrors) => true;
}
}
}