From 9bccd0937ea3b384fddccaf59c73a1a0f6bc8952 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sun, 11 Feb 2018 21:11:41 +1000 Subject: [PATCH 1/3] Add Tls1.2 to allowed protocols, for earlier target frameworks where this wasnt already the default. ServicePointManager class used to do this, is only available in the full framework, so a preprocessor constant needs to be used --- Octokit/Http/HttpClientAdapter.cs | 4 ++++ Octokit/Octokit.csproj | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Octokit/Http/HttpClientAdapter.cs b/Octokit/Http/HttpClientAdapter.cs index ca14a34821..2071ff4171 100644 --- a/Octokit/Http/HttpClientAdapter.cs +++ b/Octokit/Http/HttpClientAdapter.cs @@ -27,6 +27,10 @@ public HttpClientAdapter(Func getHandler) { Ensure.ArgumentNotNull(getHandler, "getHandler"); +#if HAS_SERVICEPOINTMANAGER + ServicePointManager.SecurityProtocol = ServicePointManager.SecurityProtocol | SecurityProtocolType.Tls12; +#endif + _http = new HttpClient(new RedirectHandler { InnerHandler = getHandler() }); } diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 9388c8c645..1a561c058b 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -23,7 +23,7 @@ - $(DefineConstants);HAS_ENVIRONMENT;HAS_REGEX_COMPILED_OPTIONS;SIMPLE_JSON_INTERNAL,SIMPLE_JSON_OBJARRAYINTERNAL,SIMPLE_JSON_READONLY_COLLECTIONS + $(DefineConstants);HAS_ENVIRONMENT;HAS_REGEX_COMPILED_OPTIONS;SIMPLE_JSON_INTERNAL;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_READONLY_COLLECTIONS;HAS_SERVICEPOINTMANAGER From 2101a260f0695f2709fe3e3a92f8712bf9070940 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sun, 11 Feb 2018 22:27:38 +1000 Subject: [PATCH 2/3] intergration tests net452 target wasn't setup --- Octokit.Tests.Integration/Octokit.Tests.Integration.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index f023046741..0a690798d5 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -4,7 +4,7 @@ Integration tests for Octokit Octokit.Tests.Integration GitHub - netcoreapp1.0 + netcoreapp1.0;net452 $(NoWarn);CS4014;CS1998 Octokit.Tests.Integration Octokit.Tests.Integration @@ -27,7 +27,7 @@ - + From 49fc34bb939298b77bb3d64dafd5b1e8b4854c85 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Tue, 13 Feb 2018 23:54:54 +1000 Subject: [PATCH 3/3] Use OR Assignment operator, just for Haacked --- Octokit/Http/HttpClientAdapter.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit/Http/HttpClientAdapter.cs b/Octokit/Http/HttpClientAdapter.cs index 2071ff4171..0050aae34b 100644 --- a/Octokit/Http/HttpClientAdapter.cs +++ b/Octokit/Http/HttpClientAdapter.cs @@ -28,7 +28,7 @@ public HttpClientAdapter(Func getHandler) Ensure.ArgumentNotNull(getHandler, "getHandler"); #if HAS_SERVICEPOINTMANAGER - ServicePointManager.SecurityProtocol = ServicePointManager.SecurityProtocol | SecurityProtocolType.Tls12; + ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12; #endif _http = new HttpClient(new RedirectHandler { InnerHandler = getHandler() }); @@ -282,4 +282,4 @@ public void SetRequestTimeout(TimeSpan timeout) internal class RedirectHandler : DelegatingHandler { } -} \ No newline at end of file +}