Repository: dotnet/aspnetcore
File: src/Shared/CertificateGeneration/UnixCertificateManager.cs (C#)

Code before:
        var chain = new X509Chain();
        try
        {
            // This is just a heuristic for whether or not we should prompt the user to re-run with `--trust`
            // so we don't need to check revocation (which doesn't really make sense for dev certs anyway)
            chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck;
            if (chain.Build(certificate))
            {
                sawTrustSuccess = true;
            }
            else
            {
                sawTrustFailure = true;
                Log.UnixNotTrustedByDotnet();
            }
        }
        finally
        {
            // Disposing the chain does not dispose the elements we potentially built.
            // Do the full walk manually to dispose.
            for (int chainElementIndex = 0; chainElementIndex < chain.ChainElements.Count; ++chainElementIndex)
            {
                chain.ChainElements[chainElementIndex].Certificate.Dispose();
            }

            chain.Dispose();
        }

        // Will become the name of the file on disk and the nickname in the NSS DBs
        var certificateNickname = GetCertificateNickname(certificate);

        var sslCertDirString = Environment.GetEnvironmentVariable(OpenSslCertificateDirectoryVariableName);
        if (string.IsNullOrEmpty(sslCertDirString))
        {
            sawTrustFailure = true;
            Log.UnixNotTrustedByOpenSsl(OpenSslCertificateDirectoryVariableName);
        }
        else
        {
            var foundCert = false;
            var sslCertDirs = sslCertDirString.Split(Path.PathSeparator);
            foreach (var sslCertDir in sslCertDirs)
            {
                var certPath = Path.Combine(sslCertDir, certificateNickname + ".pem");
                if (File.Exists(certPath))
                {
                    using var candidate = X509CertificateLoader.LoadCertificateFromFile(certPath);
                    if (AreCertificatesEqual(certificate, candidate))
                    {
                        foundCert = true;
                        break;

Review comment (suggestion):
Nit (following the [coding guidelines](https://github.com/dotnet/aspnetcore/wiki/Engineering-guidelines#usage-of-the-var-keyword) of this repo):
```suggestion
            // Disposing the chain does not dispose the elements we potentially built.
            // Do the full walk manually to dispose.
            for (var i = 0; i < chain.ChainElements.Count; i++)
            {
                chain.ChainElements[i].Certificate.Dispose();
            }

            chain.Dispose();
```

Code after:
        var chain = new X509Chain();
        try
        {
            // This is just a heuristic for whether or not we should prompt the user to re-run with `--trust`
            // so we don't need to check revocation (which doesn't really make sense for dev certs anyway)
            chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck;
            if (chain.Build(certificate))
            {
                sawTrustSuccess = true;
            }
            else
            {
                sawTrustFailure = true;
                Log.UnixNotTrustedByDotnet();
            }
        }
        finally
        {
            // Disposing the chain does not dispose the elements we potentially built.
            // Do the full walk manually to dispose.
            for (var i = 0; i < chain.ChainElements.Count; i++)
            {
                chain.ChainElements[i].Certificate.Dispose();
            }

            chain.Dispose();
        }

        // Will become the name of the file on disk and the nickname in the NSS DBs
        var certificateNickname = GetCertificateNickname(certificate);

        var sslCertDirString = Environment.GetEnvironmentVariable(OpenSslCertificateDirectoryVariableName);
        if (string.IsNullOrEmpty(sslCertDirString))
        {
            sawTrustFailure = true;
            Log.UnixNotTrustedByOpenSsl(OpenSslCertificateDirectoryVariableName);
        }
        else
        {
            var foundCert = false;
            var sslCertDirs = sslCertDirString.Split(Path.PathSeparator);
            foreach (var sslCertDir in sslCertDirs)
            {
                var certPath = Path.Combine(sslCertDir, certificateNickname + ".pem");
                if (File.Exists(certPath))
                {
                    using var candidate = X509CertificateLoader.LoadCertificateFromFile(certPath);
                    if (AreCertificatesEqual(certificate, candidate))
                    {
                        foundCert = true;
                        break;