Skip to content

Commit

Permalink
Add TLS1.2 to enabled security protocols (.NET Framework 4.5 only) (#…
Browse files Browse the repository at this point in the history
…1758)

* 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

* intergration tests net452 target wasn't setup

* Use OR Assignment operator, just for Haacked
  • Loading branch information
ryangribble authored Feb 13, 2018
1 parent 2340f8d commit b35b60f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Octokit.Tests.Integration/Octokit.Tests.Integration.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Description>Integration tests for Octokit</Description>
<AssemblyTitle>Octokit.Tests.Integration</AssemblyTitle>
<Authors>GitHub</Authors>
<TargetFramework>netcoreapp1.0</TargetFramework>
<TargetFrameworks>netcoreapp1.0;net452</TargetFrameworks>
<NoWarn>$(NoWarn);CS4014;CS1998</NoWarn>
<AssemblyName>Octokit.Tests.Integration</AssemblyName>
<PackageId>Octokit.Tests.Integration</PackageId>
Expand All @@ -27,7 +27,7 @@
<None Include="app.config" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
<ItemGroup>
<ProjectReference Include="..\Octokit\Octokit.csproj" />
<ProjectReference Include="..\Octokit.Reactive\Octokit.Reactive.csproj" />
<ProjectReference Include="..\Octokit.Tests\Octokit.Tests.csproj" />
Expand Down
6 changes: 5 additions & 1 deletion Octokit/Http/HttpClientAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public HttpClientAdapter(Func<HttpMessageHandler> getHandler)
{
Ensure.ArgumentNotNull(getHandler, "getHandler");

#if HAS_SERVICEPOINTMANAGER
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;
#endif

_http = new HttpClient(new RedirectHandler { InnerHandler = getHandler() });
}

Expand Down Expand Up @@ -278,4 +282,4 @@ public void SetRequestTimeout(TimeSpan timeout)
internal class RedirectHandler : DelegatingHandler
{
}
}
}
2 changes: 1 addition & 1 deletion Octokit/Octokit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net45' ">
<DefineConstants>$(DefineConstants);HAS_ENVIRONMENT;HAS_REGEX_COMPILED_OPTIONS;SIMPLE_JSON_INTERNAL,SIMPLE_JSON_OBJARRAYINTERNAL,SIMPLE_JSON_READONLY_COLLECTIONS</DefineConstants>
<DefineConstants>$(DefineConstants);HAS_ENVIRONMENT;HAS_REGEX_COMPILED_OPTIONS;SIMPLE_JSON_INTERNAL;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_READONLY_COLLECTIONS;HAS_SERVICEPOINTMANAGER</DefineConstants>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
Expand Down

0 comments on commit b35b60f

Please sign in to comment.