Ejemplo n.º 1
0
        private bool ValidateRemoteCertificate(object sender, X509Certificate certificate, X509Chain chain,
                                               SslPolicyErrors sslPolicyErrors)
        {
            // Note: add ref to handle since the caller will reset the cert after the callback return.

            // dotnet/wcf#1574
            // ORIGINAL CODE:
            // X509Certificate2 certificate2 = new X509Certificate2(certificate.Handle);
            X509Certificate2 certificate2 = certificate.CloneCertificateInternal();

            SecurityToken token = new X509SecurityToken(certificate2, false);
            ReadOnlyCollection <IAuthorizationPolicy> authorizationPolicies = _serverCertificateAuthenticator.ValidateToken(token);

            _serverSecurity = new SecurityMessageProperty();
            _serverSecurity.TransportToken         = new SecurityTokenSpecification(token, authorizationPolicies);
            _serverSecurity.ServiceSecurityContext = new ServiceSecurityContext(authorizationPolicies);

            AuthorizationContext authzContext = _serverSecurity.ServiceSecurityContext.AuthorizationContext;

            _parent.IdentityVerifier.EnsureOutgoingIdentity(RemoteAddress, Via, authzContext);

            return(true);
        }