Opc.Ua.Server.StandardServer.RegistrationValidator_CertificateValidation C# (CSharp) Method

RegistrationValidator_CertificateValidation() private method

Checks that the domains in the certificate match the current host.
private RegistrationValidator_CertificateValidation ( CertificateValidator sender, CertificateValidationEventArgs e ) : void
sender CertificateValidator
e CertificateValidationEventArgs
return void
        private void RegistrationValidator_CertificateValidation(CertificateValidator sender, CertificateValidationEventArgs e)
        {
            System.Net.IPAddress[] targetAddresses = System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName());
            
            foreach (string domain in Utils.GetDomainsFromCertficate(e.Certificate))
            {
                System.Net.IPAddress[] actualAddresses = System.Net.Dns.GetHostAddresses(domain);

                foreach (System.Net.IPAddress actualAddress in actualAddresses)
                {
                    foreach (System.Net.IPAddress targetAddress in targetAddresses)
                    {
                        if (targetAddress.Equals(actualAddress))
                        {
                            e.Accept = true;
                            return;
                        }
                    }
                }
            }
        }