【发布时间】:2016-05-27 15:46:51
【问题描述】:
我在使用 Windows Azure ACS 时遇到了问题,我不能完全确定它是否应该这样,或者我的代码中是否存在错误。
我在 ACS 中配置了许多依赖方,并且所有依赖方都配置了 HTTPS。每个服务都以需要令牌加密的方式配置。为此,我上传了使用 MakeCert.exe 创建的证书。
当客户端与依赖方通信时,我将证书的公共部分添加为服务证书,并将主题名称添加为 DnsIdentity:
var identity = EndpointIdentity.CreateDnsIdentity( GetClientCertificateSubjectName() );
var serviceEndpointAddress = new EndpointAddress( new Uri( _serviceAddress ), identity );
// Creation of channel factory
if( channelFactory.Credentials != null ) {
channelFactory.Credentials.ServiceCertificate.DefaultCertificate = GetClientCertificate();
channelFactory.Credentials.ClientCertificate.Certificate = GetServiceIdentityCertificate();
}
事情是这样的:当我通过HTTPS调用依赖方时,我可以跳过EndpointIdentity的创建,然后依赖方会给我一个正确的答案。我也可以跳过设置ServiceCertificate.DefaultCertificate属性或者设置一个完全随机的证书,依赖方仍然会给我一个正确的答案。
通过 HTTP 调用时,执行上述任何操作都会导致 ACS 出错,并显示消息表明我没有使用正确的证书。简而言之:通过 HTTP 调用时,我只能使用正确的客户端证书进行通信。我预计 HTTPS 也是如此。
我可以想象ChannelFactory<T> 或 ACS 足够智能,可以检测到使用 HTTPS 并跳过配置的加密,转而支持 SSL 加密。遗憾的是,我找不到任何支持这个想法的文档。
我的问题是:通过 HTTPS 调用依赖方时忽略 EndpointIdentity 和证书是否正常?还是我需要额外的配置才能完成这项工作?
提前致谢!
【问题讨论】: