예제 #1
0
        NativeOpenSsl.RemoteValidationCallback GetValidationCallback()
        {
            CertificateValidator validator = null;

            if (IsServer)
            {
                validator = (CertificateValidator)Parameters.ServerCertificateValidator;
            }
            else
            {
                validator = (CertificateValidator)Parameters.ClientCertificateValidator;
            }

            if (validator == null)
            {
                return(null);
            }

            return((ok, cert) => {
                var errors = SslPolicyErrors.None;
                if (!ok)
                {
                    errors |= SslPolicyErrors.RemoteCertificateChainErrors;
                }
                return validator.ValidationCallback(this, cert, null, errors);
            });
        }
예제 #2
0
        internal static void AddCertificateValidator(MSI.MonoTlsSettings settings, CertificateValidator validator)
        {
            if (validator == null)
            {
                return;
            }

            settings.RemoteCertificateValidationCallback = (s, c, ch, e) => {
                return(validator.ValidationCallback(s, c, ch, (SslPolicyErrors)e));
            };
        }