From 68a2ab1b95da1ef6cd7c8ebfb8e8bc9cc67ab1cb Mon Sep 17 00:00:00 2001
From: barnstee
Date: Sat, 21 Sep 2024 22:24:13 +0200
Subject: [PATCH] Added ability to download the trust list.
---
.gitignore | 1 +
Controllers/CertManagerController.cs | 25 +++++++++++++++++++++++++
Views/CertManager/Index.cshtml | 9 +++++++++
3 files changed, 35 insertions(+)
diff --git a/.gitignore b/.gitignore
index 3394d70..1755562 100644
--- a/.gitignore
+++ b/.gitignore
@@ -353,3 +353,4 @@ MigrationBackup/
/Settings
/pki
/store
+/trustlist.zip
diff --git a/Controllers/CertManagerController.cs b/Controllers/CertManagerController.cs
index 0bf4387..598e779 100644
--- a/Controllers/CertManagerController.cs
+++ b/Controllers/CertManagerController.cs
@@ -9,6 +9,7 @@ namespace Opc.Ua.Cloud.Publisher.Controllers
using System;
using System.Collections.Generic;
using System.IO;
+ using System.IO.Compression;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
using System.Threading.Tasks;
@@ -75,5 +76,29 @@ public async Task Load(IFormFile file)
return View("Index", new SelectList(new List() { ex.Message }));
}
}
+
+ [HttpPost]
+ public ActionResult DownloadTrustlist()
+ {
+ try
+ {
+ string zipfile = "trustlist.zip";
+
+ if (System.IO.File.Exists(zipfile))
+ {
+ System.IO.File.Delete(zipfile);
+ }
+
+ string pathToTrustList = Path.Combine(Directory.GetCurrentDirectory(), "pki", "trusted", "certs");
+ ZipFile.CreateFromDirectory(pathToTrustList, zipfile);
+
+ return File(System.IO.File.ReadAllBytes(zipfile), "APPLICATION/octet-stream", zipfile);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex.Message);
+ return View("Index", new SelectList(new List() { ex.Message }));
+ }
+ }
}
}
diff --git a/Views/CertManager/Index.cshtml b/Views/CertManager/Index.cshtml
index 3571d01..a7eea4c 100644
--- a/Views/CertManager/Index.cshtml
+++ b/Views/CertManager/Index.cshtml
@@ -29,5 +29,14 @@
+
+
+
+
+ @using (Html.BeginForm("DownloadTrustlist", "CertManager"))
+ {
+
+ }
+