我编码的Azure的WCF服务总线的服务,这是通过编程配置为使用证书,有消息安全:但是WCF:配置消息安全编程
ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Tcp;
// create the service URI based on the service namespace
Uri address = ServiceBusEnvironment.CreateServiceUri("sb", ConfigurationManager.AppSettings["serviceNamespace"], "TestService");
// create the credentials object for the endpoint
TransportClientEndpointBehavior sharedSecretServiceBusCredential = new TransportClientEndpointBehavior();
sharedSecretServiceBusCredential.TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(ConfigurationManager.AppSettings["issuerName"], ConfigurationManager.AppSettings["issuerSecret"]);
//Create and bind the serviceEndpoint
ContractDescription contractDescription = ContractDescription.GetContract(typeof(ITestContract), typeof(TestServiceImpl));
ServiceEndpoint serviceEndPoint = new ServiceEndpoint(contractDescription);
serviceEndPoint.Address = new EndpointAddress(address);
var NetTcpRelayBinding = new NetTcpRelayBinding(EndToEndSecurityMode.TransportWithMessageCredential, RelayClientAuthenticationType.RelayAccessToken);
NetTcpRelayBinding.Security.Message.ClientCredentialType = MessageCredentialType.Certificate; //The serivice will check the TrustedPeople store for the client
serviceEndPoint.Binding = NetTcpRelayBinding;
serviceEndPoint.Behaviors.Add(sharedSecretServiceBusCredential);
Host = new ServiceHost(typeof(TestServiceImpl), address);
//Add a service certificate
Host.Credentials.ClientCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.PeerTrust;
Host.Credentials.ServiceCertificate.SetCertificate(StoreLocation.LocalMachine,StoreName.My,X509FindType.FindByThumbprint,"E86870F0118CE39D771A49B9337C28444F3C7348");
// create the service host reading the configuration
Host.Description.Endpoints.Add(serviceEndPoint);
我能得到这个服务启动和运行, ,任何客户端),只有ServiceBus SharedSecret,clientCredentials未设置为使用任何证书)能够无误地调用我的服务。 上述代码是否足以表明证书(并且只有证书基础授权)应该用于消息安全? 有关以编程方式配置WCF消息安全的好文章?
作为补充,这里' sa链接如何编程连接到Windows服务Azure总线与SimpleWebToken [http://blog.longle.net/2012/09/18/declaritively-and-programitcally-subscribeing-to-the-windows-azure-service-总线中继用的WCF /(http://blog.longle.net/2012/09/18/declaritively-and-programitcally-subscribing-to-the-windows-azure-service-bus-relay-with- WCF /)。 – LeLong37