Repository: microsoft/garnet
File: libs/server/TLS/GarnetTlsOptions.cs (C#)

Code before:
        }


        /// <summary>
        /// Callback to verify the TLS certificate
        /// </summary>
        /// <param name="issuerCertificatePath">The path to issuer certificate file. </param>
        /// <returns></returns>
        /// <exception cref="ArgumentException"></exception>
        /// <exception cref="ArgumentNullException"></exception>
        RemoteCertificateValidationCallback ValidateServerCertificateCallback(string targetHostName, string issuerCertificatePath)
        {
            var issuer = GetCertificateIssuer(issuerCertificatePath);
            return (object _, X509Certificate certificate, X509Chain __, SslPolicyErrors sslPolicyErrors)
                => (sslPolicyErrors == SslPolicyErrors.None) || (sslPolicyErrors == SslPolicyErrors.RemoteCertificateChainErrors
                   && certificate is X509Certificate2 certificate2
                   && ValidateCertificateName(certificate2, targetHostName)
                   && ValidateCertificateIssuer(certificate2, issuer));
        }

        /// <summary>
        /// Validates certificate subject name by looking into DNS name property (preferred), if missing it falls back to
        /// legacy SimpleName. The input certificate subject should match the expected host name provided in server config.
        /// </summary>
        /// <param name="certificate2">the remote certificate to validate.</param>
        /// <param name="targetHostName">The expected target host name. </param>
        private bool ValidateCertificateName(X509Certificate2 certificate2, string targetHostName)
        {
            var subjectName = certificate2.GetNameInfo(X509NameType.DnsName, false);
            if (string.IsNullOrWhiteSpace(subjectName))
            {
                subjectName = certificate2.GetNameInfo(X509NameType.SimpleName, false);
            }

            return subjectName.Equals(targetHostName, StringComparison.InvariantCultureIgnoreCase);
        }

        /// <summary>
        /// Callback to verify the TLS certificate
        /// </summary>
        /// <param name="issuerCertificatePath">The path to issuer certificate file.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentException"></exception>
        /// <exception cref="ArgumentNullException"></exception>
        RemoteCertificateValidationCallback ValidateClientCertificateCallback(string issuerCertificatePath)
        {
            if (!ClientCertificateRequired)
            {
                logger?.LogWarning("ClientCertificateRequired is false. Remote certificate validation will always succeed.");
                return (object _, X509Certificate certificate, X509Chain __, SslPolicyErrors sslPolicyErrors)
                    => true;

Review comment (suggestion):
NIT: Typo

```suggestion
        /// <param name="certificate2">The remote certificate to validate.</param>
        /// <param name="targetHostName">The expected target host name.</param>
```

Code after:
        }


        /// <summary>
        /// Callback to verify the TLS certificate
        /// </summary>
        /// <param name="issuerCertificatePath">The path to issuer certificate file. </param>
        /// <returns></returns>
        RemoteCertificateValidationCallback ValidateServerCertificateCallback(string targetHostName, string issuerCertificatePath)
        {
            var issuer = GetCertificateIssuer(issuerCertificatePath);
            return (object _, X509Certificate certificate, X509Chain __, SslPolicyErrors sslPolicyErrors)
                => (sslPolicyErrors == SslPolicyErrors.None) || (sslPolicyErrors == SslPolicyErrors.RemoteCertificateChainErrors
                   && certificate is X509Certificate2 certificate2
                   && ValidateCertificateName(certificate2, targetHostName)
                   && ValidateCertificateIssuer(certificate2, issuer));
        }

        /// <summary>
        /// Validates certificate subject name by looking into DNS name property (preferred), if missing it falls back to
        /// legacy SimpleName. The input certificate subject should match the expected host name provided in server config.
        /// </summary>
        /// <param name="certificate2">The remote certificate to validate.</param>
        /// <param name="targetHostName">The expected target host name. </param>
        private bool ValidateCertificateName(X509Certificate2 certificate2, string targetHostName)
        {
            var subjectName = certificate2.GetNameInfo(X509NameType.DnsName, false);
            if (string.IsNullOrWhiteSpace(subjectName))
            {
                subjectName = certificate2.GetNameInfo(X509NameType.SimpleName, false);
            }

            return subjectName.Equals(targetHostName, StringComparison.InvariantCultureIgnoreCase);
        }

        /// <summary>
        /// Callback to verify the TLS certificate
        /// </summary>
        /// <param name="issuerCertificatePath">The path to issuer certificate file.</param>
        /// <returns>The RemoteCertificateValidationCallback delegate to invoke.</returns>
        RemoteCertificateValidationCallback ValidateClientCertificateCallback(string issuerCertificatePath)
        {
            if (!ClientCertificateRequired)
            {
                logger?.LogWarning("ClientCertificateRequired is false. Remote certificate validation will always succeed.");
                return (object _, X509Certificate certificate, X509Chain __, SslPolicyErrors sslPolicyErrors)
                    => true;
            }
            var issuer = GetCertificateIssuer(issuerCertificatePath);
            return (object _, X509Certificate certificate, X509Chain __, SslPolicyErrors sslPolicyErrors)
                => (sslPolicyErrors == SslPolicyErrors.None) || (sslPolicyErrors == SslPolicyErrors.RemoteCertificateChainErrors