예제 #1
0
        private void RemoveCertificate(X509Certificate2 certificate, RemoveLocations locations, DiagnosticInformation diagnostics = null)
        {
            switch (locations)
            {
            case RemoveLocations.Undefined:
                throw new InvalidOperationException($"'{nameof(RemoveLocations.Undefined)}' is not a valid location.");

            case RemoveLocations.Local:
                RemoveCertificateFromUserStore(certificate, diagnostics);
                break;

            case RemoveLocations.Trusted when !RuntimeInformation.IsOSPlatform(OSPlatform.Linux):
                RemoveCertificateFromTrustedRoots(certificate, diagnostics);
                break;

            case RemoveLocations.All:
                if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
                {
                    RemoveCertificateFromTrustedRoots(certificate, diagnostics);
                }
                RemoveCertificateFromUserStore(certificate, diagnostics);
                break;

            default:
                throw new InvalidOperationException("Invalid location.");
            }
        }
예제 #2
0
        internal void RemoveCertificate(X509Certificate2 certificate, RemoveLocations locations)
        {
            switch (locations)
            {
            case RemoveLocations.Undefined:
                throw new InvalidOperationException($"'{nameof(RemoveLocations.Undefined)}' is not a valid location.");

            case RemoveLocations.Local:
                RemoveCertificateFromUserStore(certificate);
                break;

            case RemoveLocations.Trusted:
                RemoveCertificateFromTrustedRoots(certificate);
                break;

            case RemoveLocations.All:
                RemoveCertificateFromTrustedRoots(certificate);
                RemoveCertificateFromUserStore(certificate);
                break;

            default:
                throw new InvalidOperationException("Invalid location.");
            }
        }