Skip to content

Commit 16374e2

Browse files
Add support for Chromium Snap cert trust (#57257)
I thought this already worked, but it turns out it behaves differently depending on how you launch it. When it is launched as a snap (vs from the command line), it can only access things in its own folder, so it looks in a different NSS DB for trusted certs. Fixing this is as simple as adding one more well-known location to the list. Co-authored-by: Andrew Casey <amcasey@users.noreply.github.com>
1 parent 35f21b3 commit 16374e2

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/Shared/CertificateGeneration/UnixCertificateManager.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,11 @@ private static string GetChromiumNssDb(string homeDirectory)
476476
return Path.Combine(homeDirectory, ".pki", "nssdb");
477477
}
478478

479+
private static string GetChromiumSnapNssDb(string homeDirectory)
480+
{
481+
return Path.Combine(homeDirectory, "snap", "chromium", "current", ".pki", "nssdb");
482+
}
483+
479484
private static string GetFirefoxDirectory(string homeDirectory)
480485
{
481486
return Path.Combine(homeDirectory, ".mozilla", "firefox");
@@ -732,13 +737,21 @@ private static List<NssDb> GetNssDbs(string homeDirectory)
732737
return nssDbs;
733738
}
734739

735-
// Chrome, Chromium, Edge, and their respective snaps all use this directory
740+
// Chrome, Chromium, and Edge all use this directory
736741
var chromiumNssDb = GetChromiumNssDb(homeDirectory);
737742
if (Directory.Exists(chromiumNssDb))
738743
{
739744
nssDbs.Add(new NssDb(chromiumNssDb, isFirefox: false));
740745
}
741746

747+
// Chromium Snap, when launched under snap confinement, uses this directory
748+
// (On Ubuntu, the GUI launcher uses confinement, but the terminal does not)
749+
var chromiumSnapNssDb = GetChromiumSnapNssDb(homeDirectory);
750+
if (Directory.Exists(chromiumSnapNssDb))
751+
{
752+
nssDbs.Add(new NssDb(chromiumSnapNssDb, isFirefox: false));
753+
}
754+
742755
var firefoxDir = GetFirefoxDirectory(homeDirectory);
743756
if (Directory.Exists(firefoxDir))
744757
{

0 commit comments

Comments
 (0)