--- /dev/null
+using System;
+using System.Net;
+using NaGet.Tasks;
+
+namespace NaGet.SubCommands.SubTask
+{
+ public class SecurityProtocolConfigSubTask : NaGetSubTask
+ {
+ public SecurityProtocolConfigSubTask()
+ {
+ }
+
+ public override void Run()
+ {
+ NotifyStarted();
+ RaiseTaskSetEvent(TaskEventType.STARTED, "セキュリティプロトコル設定の確認", 0);
+
+ if ((ServicePointManager.SecurityProtocol & SecurityProtocolType.Ssl3) != 0) {
+ ServicePointManager.SecurityProtocol &= ~SecurityProtocolType.Ssl3;
+ RaiseTaskSetEvent(TaskEventType.PING, string.Empty, 33);
+ }
+
+ try {
+ ServicePointManager.SecurityProtocol |= (SecurityProtocolType)768; // SecurityProtocolType.Tls11
+ RaiseTaskSetEvent(TaskEventType.PING, string.Empty, 66);
+ } catch (NotSupportedException) {
+ RaiseTaskSetEvent(TaskEventType.WARNING, "TLSv1.1は有効ではありません", 66);
+ }
+
+ try {
+ ServicePointManager.SecurityProtocol |= (SecurityProtocolType)3072; // SecurityProtocolType.Tls12
+ RaiseTaskSetEvent(TaskEventType.PING, string.Empty, 99);
+ } catch (NotSupportedException) {
+ RaiseTaskSetEvent(TaskEventType.WARNING, "TLSv1.2は有効ではありません", 99);
+ }
+
+ RaiseTaskSetEvent(TaskEventType.COMPLETED, "セキュリティプロトコル設定の確認", 100);
+ NotifyCompleted();
+ }
+ }
+}