Mono has no root certs! Uglyhacking.
This commit is contained in:
@@ -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");
|
||||
|
||||
|
||||
@@ -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" />
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user