AppliStation
修订版 | 2cb1d17dbcbc2a8da66806a0a8a9be05deb76caa (tree) |
---|---|
时间 | 2017-10-09 23:41:20 |
作者 | ttp <ttp@user...> |
Commiter | ttp |
na-get-lib,"セキュリティプロトコル設定の確認"を追加。SSLv3を無効化し、使用可能ならばTLSv1.1とTLSv1.2を有効にする
@@ -0,0 +1,41 @@ | ||
1 | +using System; | |
2 | +using System.Net; | |
3 | +using NaGet.Tasks; | |
4 | + | |
5 | +namespace NaGet.SubCommands.SubTask | |
6 | +{ | |
7 | + public class SecurityProtocolConfigSubTask : NaGetSubTask | |
8 | + { | |
9 | + public SecurityProtocolConfigSubTask() | |
10 | + { | |
11 | + } | |
12 | + | |
13 | + public override void Run() | |
14 | + { | |
15 | + NotifyStarted(); | |
16 | + RaiseTaskSetEvent(TaskEventType.STARTED, "セキュリティプロトコル設定の確認", 0); | |
17 | + | |
18 | + if ((ServicePointManager.SecurityProtocol & SecurityProtocolType.Ssl3) != 0) { | |
19 | + ServicePointManager.SecurityProtocol &= ~SecurityProtocolType.Ssl3; | |
20 | + RaiseTaskSetEvent(TaskEventType.PING, string.Empty, 33); | |
21 | + } | |
22 | + | |
23 | + try { | |
24 | + ServicePointManager.SecurityProtocol |= (SecurityProtocolType)768; // SecurityProtocolType.Tls11 | |
25 | + RaiseTaskSetEvent(TaskEventType.PING, string.Empty, 66); | |
26 | + } catch (NotSupportedException) { | |
27 | + RaiseTaskSetEvent(TaskEventType.WARNING, "TLSv1.1は有効ではありません", 66); | |
28 | + } | |
29 | + | |
30 | + try { | |
31 | + ServicePointManager.SecurityProtocol |= (SecurityProtocolType)3072; // SecurityProtocolType.Tls12 | |
32 | + RaiseTaskSetEvent(TaskEventType.PING, string.Empty, 99); | |
33 | + } catch (NotSupportedException) { | |
34 | + RaiseTaskSetEvent(TaskEventType.WARNING, "TLSv1.2は有効ではありません", 99); | |
35 | + } | |
36 | + | |
37 | + RaiseTaskSetEvent(TaskEventType.COMPLETED, "セキュリティプロトコル設定の確認", 100); | |
38 | + NotifyCompleted(); | |
39 | + } | |
40 | + } | |
41 | +} |
@@ -41,6 +41,8 @@ namespace NaGet.SubCommands | ||
41 | 41 | |
42 | 42 | // taskセットの初期化 |
43 | 43 | initSubTask(); |
44 | + registSubTask("セキュリティプロトコル設定の確認", | |
45 | + new SecurityProtocolConfigSubTask()); | |
44 | 46 | foreach (Installation inst in installations) { |
45 | 47 | DownloadSubTask dlSTask = new DownloadSubTask(inst.InstallerURL, inst.InstallerFile); |
46 | 48 | VirusScanSubTask scanSTask = new VirusScanSubTask(scanner, inst.InstallerFile, inst.InstallerURL); |
@@ -49,6 +49,8 @@ namespace NaGet.SubCommands | ||
49 | 49 | { |
50 | 50 | // taskセットの初期化 |
51 | 51 | initSubTask(); |
52 | + registSubTask("セキュリティプロトコル設定の確認", | |
53 | + new SecurityProtocolConfigSubTask()); | |
52 | 54 | foreach (Installation inst in installations) { |
53 | 55 | VirusScanSubTask scanSTask = new VirusScanSubTask(scanner, inst.InstallerFile, inst.InstallerURL); |
54 | 56 |
@@ -40,6 +40,8 @@ namespace NaGet.SubCommands | ||
40 | 40 | |
41 | 41 | // taskセットの初期化 |
42 | 42 | initSubTask(); |
43 | + registSubTask("セキュリティプロトコル設定の確認", | |
44 | + new SecurityProtocolConfigSubTask()); | |
43 | 45 | if (this.downloadPackageLists) { |
44 | 46 | // repos.list.xmlがあるとき、そこからよみとる。 |
45 | 47 | repoList = NaGet.Utils.GetDeserializedObject<RepositoriesList>(NaGet.Env.RepositoriesListFile); |
@@ -77,6 +77,7 @@ | ||
77 | 77 | <Compile Include="NaGet.SubCommands.SubTask\DownloadSubTask.cs" /> |
78 | 78 | <Compile Include="NaGet.SubCommands.SubTask\LocalUpdateSubTask.cs" /> |
79 | 79 | <Compile Include="NaGet.SubCommands.SubTask\NaGetSubTask.cs" /> |
80 | + <Compile Include="NaGet.SubCommands.SubTask\SecurityProtocolConfigSubTask.cs" /> | |
80 | 81 | <Compile Include="NaGet.SubCommands.SubTask\VerifyInstallerFileSubTask.cs" /> |
81 | 82 | <Compile Include="NaGet.SubCommands.SubTask\VirusScanSubTask.cs" /> |
82 | 83 | <Compile Include="NaGet.SubCommands\NaGetDownloadToCache2.cs" /> |