Skip to content

Commit

Permalink
Added ability to download the trust list.
Browse files Browse the repository at this point in the history
  • Loading branch information
barnstee committed Sep 21, 2024
1 parent 5c01c5e commit 68a2ab1
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,4 @@ MigrationBackup/
/Settings
/pki
/store
/trustlist.zip
25 changes: 25 additions & 0 deletions Controllers/CertManagerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -75,5 +76,29 @@ public async Task<IActionResult> Load(IFormFile file)
return View("Index", new SelectList(new List<string>() { 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<string>() { ex.Message }));
}
}
}
}
9 changes: 9 additions & 0 deletions Views/CertManager/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,14 @@
<input id="connectButton" class="btn btn-primary btn_browser" type="submit" value="Load">
</p>
</form>
<br />
<hr style="border-top: 1px solid blue" />
<br />
<p>
@using (Html.BeginForm("DownloadTrustlist", "CertManager"))
{
<input id="disconnectButton" class="btn btn-primary btn_browser" type="submit" value="Download Trust List" />
}
</p>
</div>

0 comments on commit 68a2ab1

Please sign in to comment.