Skip to content

Commit 6626b65

Browse files
committed
Support TLS1.2 on .NET Framework 3.5
1 parent 7999999 commit 6626b65

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Net;
34
using System.Windows.Forms;
45

56
namespace TwitterClient
@@ -12,6 +13,7 @@ static class Program
1213
[STAThread]
1314
static int Main(string[] args)
1415
{
16+
ServicePointManager.SecurityProtocol = SecurityProtocolTypeExtensions.Tls11 | SecurityProtocolTypeExtensions.Tls12;
1517
if (args.Length == 0) return 1;
1618
if (args[0] == "--config")
1719
{

SecurityProtocolTypeExtensions.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace System.Net
2+
{
3+
using System.Security.Authentication;
4+
public static class SecurityProtocolTypeExtensions
5+
{
6+
public const SecurityProtocolType Tls12 = (SecurityProtocolType)SslProtocolsExtensions.Tls12;
7+
public const SecurityProtocolType Tls11 = (SecurityProtocolType)SslProtocolsExtensions.Tls11;
8+
public const SecurityProtocolType SystemDefault = (SecurityProtocolType)0;
9+
}
10+
}

SslProtocolsExtensions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace System.Security.Authentication
2+
{
3+
public static class SslProtocolsExtensions
4+
{
5+
public const SslProtocols Tls12 = (SslProtocols)0x00000C00;
6+
public const SslProtocols Tls11 = (SslProtocols)0x00000300;
7+
}
8+
}

TwitterClient.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<AppDesignerFolder>Properties</AppDesignerFolder>
1111
<RootNamespace>TwitterClient</RootNamespace>
1212
<AssemblyName>sstwitter</AssemblyName>
13-
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
13+
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
1414
<FileAlignment>512</FileAlignment>
1515
</PropertyGroup>
1616
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
@@ -51,6 +51,8 @@
5151
<Compile Include="OAuthBase.cs" />
5252
<Compile Include="Program.cs" />
5353
<Compile Include="Properties\AssemblyInfo.cs" />
54+
<Compile Include="SecurityProtocolTypeExtensions.cs" />
55+
<Compile Include="SslProtocolsExtensions.cs" />
5456
<Compile Include="Twitter.cs" />
5557
<Compile Include="TwitterToken.cs" />
5658
<Compile Include="WebClient.cs" />

0 commit comments

Comments
 (0)