コード例 #1
0
 public static void SetServerCertificateValidationCallback(ServiceModelHttpMessageHandler handler)
 {
     if (!handler.SupportsClientCertificates)
     {
         throw ExceptionHelper.PlatformNotSupported("Server certificate validation not supported yet");
     }
     handler.ServerCertificateValidationCallback =
         ChainValidator(handler.ServerCertificateValidationCallback);
 }
コード例 #2
0
        internal override ServiceModelHttpMessageHandler GetHttpMessageHandler(EndpointAddress to, SecurityTokenContainer clientCertificateToken)
        {
            ServiceModelHttpMessageHandler handler = base.GetHttpMessageHandler(to, clientCertificateToken);

            if (RequireClientCertificate)
            {
                SetCertificate(handler, clientCertificateToken);
            }

            AddServerCertMappingOrSetRemoteCertificateValidationCallback(handler, to);
            return(handler);
        }
コード例 #3
0
        private static void SetCertificate(ServiceModelHttpMessageHandler handler, SecurityTokenContainer clientCertificateToken)
        {
            if (clientCertificateToken != null)
            {
                if (!handler.SupportsClientCertificates)
                {
                    throw ExceptionHelper.PlatformNotSupported("Client certificates not supported yet");
                }

                X509SecurityToken x509Token = (X509SecurityToken)clientCertificateToken.Token;
                handler.ClientCertificates.Add(x509Token.Certificate);
            }
        }
コード例 #4
0
 private void AddServerCertMappingOrSetRemoteCertificateValidationCallback(ServiceModelHttpMessageHandler messageHandler, EndpointAddress to)
 {
     Fx.Assert(messageHandler != null, "httpMessageHandler should not be null.");
     if (_sslCertificateValidator != null)
     {
         if (!messageHandler.SupportsClientCertificates)
         {
             throw ExceptionHelper.PlatformNotSupported("Client certificates not supported yet");
         }
         messageHandler.ServerCertificateValidationCallback = _remoteCertificateValidationCallback;
     }
     else
     {
         HttpTransportSecurityHelpers.SetServerCertificateValidationCallback(messageHandler);
     }
 }