From 2cb1d17dbcbc2a8da66806a0a8a9be05deb76caa Mon Sep 17 00:00:00 2001 From: ttp Date: Mon, 9 Oct 2017 23:39:26 +0900 Subject: [PATCH] =?utf8?q?na-get-lib,"=E3=82=BB=E3=82=AD=E3=83=A5=E3=83=AA?= =?utf8?q?=E3=83=86=E3=82=A3=E3=83=97=E3=83=AD=E3=83=88=E3=82=B3=E3=83=AB?= =?utf8?q?=E8=A8=AD=E5=AE=9A=E3=81=AE=E7=A2=BA=E8=AA=8D"=E3=82=92=E8=BF=BD?= =?utf8?q?=E5=8A=A0=E3=80=82SSLv3=E3=82=92=E7=84=A1=E5=8A=B9=E5=8C=96?= =?utf8?q?=E3=81=97=E3=80=81=E4=BD=BF=E7=94=A8=E5=8F=AF=E8=83=BD=E3=81=AA?= =?utf8?q?=E3=82=89=E3=81=B0TLSv1.1=E3=81=A8TLSv1.2=E3=82=92=E6=9C=89?= =?utf8?q?=E5=8A=B9=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../SecurityProtocolConfigSubTask.cs | 41 ++++++++++++++++++++++ .../NaGet.SubCommands/NaGetDownloadToCache2.cs | 2 ++ na-get-lib/NaGet.SubCommands/NaGetInstall2.cs | 2 ++ na-get-lib/NaGet.SubCommands/NaGetUpdate2.cs | 2 ++ na-get-lib/na-get-lib.csproj | 1 + 5 files changed, 48 insertions(+) create mode 100644 na-get-lib/NaGet.SubCommands.SubTask/SecurityProtocolConfigSubTask.cs diff --git a/na-get-lib/NaGet.SubCommands.SubTask/SecurityProtocolConfigSubTask.cs b/na-get-lib/NaGet.SubCommands.SubTask/SecurityProtocolConfigSubTask.cs new file mode 100644 index 0000000..fdfc096 --- /dev/null +++ b/na-get-lib/NaGet.SubCommands.SubTask/SecurityProtocolConfigSubTask.cs @@ -0,0 +1,41 @@ +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(); + } + } +} diff --git a/na-get-lib/NaGet.SubCommands/NaGetDownloadToCache2.cs b/na-get-lib/NaGet.SubCommands/NaGetDownloadToCache2.cs index 94cfe29..a435685 100644 --- a/na-get-lib/NaGet.SubCommands/NaGetDownloadToCache2.cs +++ b/na-get-lib/NaGet.SubCommands/NaGetDownloadToCache2.cs @@ -41,6 +41,8 @@ namespace NaGet.SubCommands // taskセットの初期化 initSubTask(); + registSubTask("セキュリティプロトコル設定の確認", + new SecurityProtocolConfigSubTask()); foreach (Installation inst in installations) { DownloadSubTask dlSTask = new DownloadSubTask(inst.InstallerURL, inst.InstallerFile); VirusScanSubTask scanSTask = new VirusScanSubTask(scanner, inst.InstallerFile, inst.InstallerURL); diff --git a/na-get-lib/NaGet.SubCommands/NaGetInstall2.cs b/na-get-lib/NaGet.SubCommands/NaGetInstall2.cs index 9e215e0..514896a 100644 --- a/na-get-lib/NaGet.SubCommands/NaGetInstall2.cs +++ b/na-get-lib/NaGet.SubCommands/NaGetInstall2.cs @@ -49,6 +49,8 @@ namespace NaGet.SubCommands { // taskセットの初期化 initSubTask(); + registSubTask("セキュリティプロトコル設定の確認", + new SecurityProtocolConfigSubTask()); foreach (Installation inst in installations) { VirusScanSubTask scanSTask = new VirusScanSubTask(scanner, inst.InstallerFile, inst.InstallerURL); diff --git a/na-get-lib/NaGet.SubCommands/NaGetUpdate2.cs b/na-get-lib/NaGet.SubCommands/NaGetUpdate2.cs index 8ea2c4a..9b84cc8 100644 --- a/na-get-lib/NaGet.SubCommands/NaGetUpdate2.cs +++ b/na-get-lib/NaGet.SubCommands/NaGetUpdate2.cs @@ -40,6 +40,8 @@ namespace NaGet.SubCommands // taskセットの初期化 initSubTask(); + registSubTask("セキュリティプロトコル設定の確認", + new SecurityProtocolConfigSubTask()); if (this.downloadPackageLists) { // repos.list.xmlがあるとき、そこからよみとる。 repoList = NaGet.Utils.GetDeserializedObject(NaGet.Env.RepositoriesListFile); diff --git a/na-get-lib/na-get-lib.csproj b/na-get-lib/na-get-lib.csproj index a11dd1c..324536b 100644 --- a/na-get-lib/na-get-lib.csproj +++ b/na-get-lib/na-get-lib.csproj @@ -77,6 +77,7 @@ + -- 2.11.0