Repository: dotnet/aspnetcore
File: src/Tools/dotnet-dev-certs/src/Program.cs (C#)

Code before:
    {
        reporter.Output(certificates.Count switch
        {
            1 => $"A {certificateState} certificate was found: {CertificateManager.GetDescription(certificates[0])}",
            _ => $"{certificates.Count} {certificateState} certificates were found: {CertificateManager.ToCertificateDescription(certificates)}"
        });
    }

    private static int CheckHttpsCertificateJsonOutput(IReporter reporter)
    {
        var availableCertificates = CertificateManager.Instance.ListCertificates(StoreName.My, StoreLocation.CurrentUser, isValid: true);

        var certReports = availableCertificates.Select(CertificateReport.FromX509Certificate2).ToList();
        reporter.Output(JsonSerializer.Serialize(certReports, options: new JsonSerializerOptions { WriteIndented = true }));

        return Success;
    }

    private static int EnsureHttpsCertificate(CommandOption exportPath, CommandOption password, CommandOption noPassword, CommandOption trust, CommandOption exportFormat, IReporter reporter)
    {
        var now = DateTimeOffset.Now;
        var manager = CertificateManager.Instance;

        if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
        {
            var certificates = manager.ListCertificates(StoreName.My, StoreLocation.CurrentUser, isValid: false, exportPath.HasValue());
            foreach (var certificate in certificates)
            {
                var status = manager.CheckCertificateState(certificate);
                if (!status.Success)
                {
                    reporter.Warn("One or more certificates might be in an invalid state. We will try to access the certificate key " +
                        "for each certificate and as a result you might be prompted one or more times to enter " +
                        "your password to access the user keychain. " +
                        "When that happens, select 'Always Allow' to grant 'dotnet' access to the certificate key in the future.");
                }

                break;
            }
        }

        var isTrustOptionSet = trust?.HasValue() == true;

        if (isTrustOptionSet)
        {
            if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                reporter.Warn("Trusting the HTTPS development certificate was requested. If the certificate is not " +
                    "already trusted we will run the following command:" + Environment.NewLine +
                    "'security add-trusted-cert -p basic -p ssl -k <<login-keychain>> <<certificate>>'" +
                    Environment.NewLine + "This command might prompt you for your password to install the certificate " +

Review comment (suggestion):
Review the change in filtering on OSX: switching isValid from true to false may result in listing certificates that are not currently valid, which could lead to unintended behavior.

Code after:
    {
        reporter.Output(certificates.Count switch
        {
            1 => $"A {certificateState} certificate was found: {CertificateManager.GetDescription(certificates[0])}",
            _ => $"{certificates.Count} {certificateState} certificates were found: {CertificateManager.ToCertificateDescription(certificates)}"
        });
    }

    private static int CheckHttpsCertificateJsonOutput(IReporter reporter)
    {
        var availableCertificates = CertificateManager.Instance.ListCertificates(StoreName.My, StoreLocation.CurrentUser, isValid: true);

        var certReports = availableCertificates.Select(CertificateReport.FromX509Certificate2).ToList();
        reporter.Output(JsonSerializer.Serialize(certReports, options: new JsonSerializerOptions { WriteIndented = true }));

        return Success;
    }

    private static int EnsureHttpsCertificate(CommandOption exportPath, CommandOption password, CommandOption noPassword, CommandOption trust, CommandOption exportFormat, IReporter reporter)
    {
        var now = DateTimeOffset.Now;
        var manager = CertificateManager.Instance;

        if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
        {
            var certificates = manager.ListCertificates(StoreName.My, StoreLocation.CurrentUser, isValid: true, exportPath.HasValue());
            foreach (var certificate in certificates)
            {
                var status = manager.CheckCertificateState(certificate);
                if (!status.Success)
                {
                    reporter.Warn("One or more certificates might be in an invalid state. We will try to access the certificate key " +
                        "for each certificate and as a result you might be prompted one or more times to enter " +
                        "your password to access the user keychain. " +
                        "When that happens, select 'Always Allow' to grant 'dotnet' access to the certificate key in the future.");
                }

                break;
            }
        }

        var isTrustOptionSet = trust?.HasValue() == true;

        if (isTrustOptionSet)
        {
            if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                reporter.Warn("Trusting the HTTPS development certificate was requested. If the certificate is not " +
                    "already trusted we will run the following command:" + Environment.NewLine +
                    "'security add-trusted-cert -p basic -p ssl -k <<login-keychain>> <<certificate>>'" +
                    Environment.NewLine + "This command might prompt you for your password to install the certificate " +