【问题标题】:How to retrieve token from acs using client certificate?如何使用客户端证书从 acs 检索令牌?
【发布时间】:2012-04-06 09:59:53
【问题描述】:

我想使用 ACS 作为服务总线的 STS。我已经设法使用 ACS 对 Web 服务进行身份验证。但是,服务总线需要令牌,我不知道如何从 ACS 中检索令牌?

简而言之,我希望我的客户端 wcf 服务能够通过使用与存储为 acs 中的服务身份的证书相匹配的证书(对应于服务总线 -sb)进行身份验证来使用服务总线。

另外,我正在为服务总线使用 NetTcpRelayBinding。

如果我可以使用客户端证书检索它,我想我可以使用来自 acs 的令牌...?

【问题讨论】:

    标签: wcf saml servicebus acs


    【解决方案1】:

    通过 WCF 使用客户端证书凭据从 ACS 获取令牌是一种得到很好支持的方案。

    有一个可用的 WCF 客户端证书身份验证的 ACS 示例here,请查找 Acs2CertificateBindingSample。兴趣点是如何创建从 ACS 获取令牌的绑定:

        public static Binding CreateServiceBinding(string acsCertificateEndpoint)
        {
            return new IssuedTokenWSTrustBinding(CreateAcsCertificateBinding(), new EndpointAddress(acsCertificateEndpoint));
        }
    
        public static Binding CreateAcsCertificateBinding()
        {
            return new CertificateWSTrustBinding(SecurityMode.TransportWithMessageCredential);
        }
    

    以及如何使用此绑定创建通道工厂,以及如何指定您的客户端证书凭证:

    ChannelFactory<IStringService> stringServiceFactory = new ChannelFactory<IStringService>(Bindings.CreateServiceBinding(acsCertificateEndpoint), serviceEndpointAddress);
    
    // Set the service credentials and disable certificate validation to work with sample certificates
    stringServiceFactory.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
    stringServiceFactory.Credentials.ServiceCertificate.DefaultCertificate = GetServiceCertificate();
    
    // Set the client credentials.
    stringServiceFactory.Credentials.ClientCertificate.Certificate = GetClientCertificateWithPrivateKey();
    

    该示例没有使用服务总线,只是一个简单的“IStringService”接口,但是如果您将您的 NetTcpRelayBinding 合并到绑定组合中,那么相同的机制应该适用于您的场景。

    【讨论】:

      猜你喜欢
      • 2019-05-12
      • 2023-03-05
      • 2013-03-07
      • 1970-01-01
      • 2021-01-24
      • 1970-01-01
      • 2012-03-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多