语言

IChannelCredentials 接口

定义

允许在服务代理上设置某些安全功能的接口。

public interface class IChannelCredentials
[System.Runtime.InteropServices.Guid("181b448c-c17c-4b17-ac6d-06699b93198f")]
[System.Runtime.InteropServices.InterfaceType(System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIDispatch)]
public interface IChannelCredentials
[<System.Runtime.InteropServices.Guid("181b448c-c17c-4b17-ac6d-06699b93198f")>]
[<System.Runtime.InteropServices.InterfaceType(System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIDispatch)>]
type IChannelCredentials = interface
Public Interface IChannelCredentials
属性

示例

monString = "service:mexAddress=http://localhost:8000/ServiceModelSamples/Service?wsdl"  
    monString = monString + ", address=http://localhost:8000/ServiceModelSamples/Service"  
    monString = monString + ", binding=BasicHttpBinding_ICalculator, bindingNamespace=http://Microsoft.ServiceModel.Samples"  
    monString = monString + ", contract=ICalculator, contractNamespace=http://Microsoft.ServiceModel.Samples"  

    Set monikerProxy = GetObject(monString)  

    'Set the Service Certificate.  
    monikerProxy.ChannelCredentials.SetServiceCertificateAuthentication "CurrentUser", "NoCheck", "PeerOrChainTrust"  
    monikerProxy.ChannelCredentials.SetDefaultServiceCertificateFromStore "CurrentUser", "TrustedPeople", "FindBySubjectName", "localhost"  

    'Set the Client Certificate.  
    monikerProxy.ChannelCredentials.SetClientCertificateFromStoreByName "CN=client.com", "CurrentUser", "My"  
    MsgBox monikerProxy.Add(3, 4)  

注解

非托管客户端使用“服务”名字对象访问Windows Communication Foundation(WCF)服务。 这些客户端受 WCF 安全模型的约束,而不是 COM 安全模型。 提供 IChannelCredentials 接口以指定通道凭据。 这是必需的,因为 COM 名字对象无法访问托管 WCF 安全对象模型。

创建通道后, IChannelCredentials 在接口上调用方法并不合法。 这是因为Windows Communication Foundation(WCF)不支持在已打开的通道上更改安全设置。 当服务名字对象客户端获取代理时,尚未创建通道。 因此,客户端必须在调用服务方法之前调用 IChannelCredentials 方法。 如果在调用服务方法后客户端调用方法 IChannelCredentials ,则会引发异常RPC_E_TOO_LATE。

方法

名称 说明
SetClientCertificateFromFile(String, String, String)

从文件中检索证书并将其添加到客户端凭据。

SetClientCertificateFromStore(String, String, String, Object)

从证书存储中检索证书并将其添加到客户端凭据。

SetClientCertificateFromStoreByName(String, String, String)

按名称从证书存储中检索证书,并将其添加到客户端凭据。

SetDefaultServiceCertificateFromFile(String, String, String)

从文件中检索证书,并将其作为默认证书添加到服务凭据。

SetDefaultServiceCertificateFromStore(String, String, String, Object)

从证书存储中检索证书,并将其作为默认证书添加到服务凭据。

SetDefaultServiceCertificateFromStoreByName(String, String, String)

按名称从证书存储中检索证书,并将其作为默认证书添加到服务凭据。

SetIssuedToken(String, String, String)

设置已颁发的令牌的参数。

SetServiceCertificateAuthentication(String, String, String)

设置服务证书身份验证参数。

SetUserNameCredential(String, String)

设置用户名凭据。

SetWindowsCredential(String, String, String, Int32, Boolean)

设置Windows凭据。

适用于