Skip to content

Commit

Permalink
removed blacklist code, now that this library supports multiple frame…
Browse files Browse the repository at this point in the history
…work versions, getting around it is very trivial, closes #190
  • Loading branch information
jaymedavis committed Jan 21, 2015
1 parent d7ccb22 commit 8eeae0f
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 51 deletions.
1 change: 0 additions & 1 deletion src/Stripe.Tests/Stripe.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@
<Compile Include="recipients\when_updating_a_recipient.cs" />
<Compile Include="requestor\when_creating_a_request.cs" />
<Compile Include="requestor\when_requesting_an_old_api_version.cs" />
<Compile Include="requestor\when_requesting_a_blacklisted_certificate.cs" />
<Compile Include="requestor\when_requesting_a_mismatched_certificate.cs" />
<Compile Include="subscriptions\when_changing_a_subscription_plan.cs" />
<Compile Include="subscriptions\when_creating_a_subscription.cs" />
Expand Down

This file was deleted.

30 changes: 0 additions & 30 deletions src/Stripe/Infrastructure/Requestor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
using System.IO;
using System.Net;
using System.Text;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;

namespace Stripe
{
Expand Down Expand Up @@ -57,26 +55,6 @@ internal static WebRequest GetWebRequest(string url, string method, string apiKe
return request;
}

private static readonly string[] BlacklistedCertDigests = {
// api.stripe.com
"05C0B3643694470A888C6E7FEB5C9E24E823DC53",
// revoked.stripe.com
"5B7DC7FBC98D78BF76D4D4FA6F597A0C901FAD5C",
};

private static bool StripeCertificateVerificationCallback(Object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
var certDigest = certificate.GetCertHashString();

if(Array.Exists(BlacklistedCertDigests, digest => digest.Equals(certDigest, StringComparison.OrdinalIgnoreCase)))
return false;

if(sslPolicyErrors == SslPolicyErrors.None)
return true;

return false;
}

private static string GetAuthorizationHeaderValue(string apiKey)
{
var token = Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}:", apiKey)));
Expand All @@ -90,12 +68,8 @@ private static string GetAuthorizationHeaderValueBearer(string apiKey)

private static string ExecuteWebRequest(WebRequest webRequest)
{
var verificationCallback = new RemoteCertificateValidationCallback(StripeCertificateVerificationCallback);

try
{
ServicePointManager.ServerCertificateValidationCallback += verificationCallback;

using (var response = webRequest.GetResponse())
{
return ReadStream(response.GetResponseStream());
Expand All @@ -119,10 +93,6 @@ private static string ExecuteWebRequest(WebRequest webRequest)

throw;
}
finally
{
ServicePointManager.ServerCertificateValidationCallback -= verificationCallback;
}
}

private static string ReadStream(Stream stream)
Expand Down

0 comments on commit 8eeae0f

Please sign in to comment.