网络负载均衡环境下wsHttpBinding+Message Security+Windows Authentication的常见异常

BindService ---使用Messenger在服务端接收信息给客户端发送的消息 1,BindService ---使用Messenger 我们接着来了解服务与远程进程(即不同进程间)通信,而不同进程间的通信,最简单的方式就是使用 Messenger 服务提供通信接口,利用此方式,我们无需使用 AIDL 便可执行进程间通信 (IPC)。以下是 Messenger 使用的主要步骤: 【1】服务实现一个 Handler,由其接收来自客户端的每个调用的回调 ... 阅读详情

提高Windows Communication Foundation (WCF) 应用程序负载能力的方法之一就是通过把它们部署到负载均衡的服务器场中. 其中可以使用标准的负载均衡技术, Windows 网络负载均衡(NLB)的软件(例如 Application Request Routing), 或者硬件(F5)实现NLB的功能. 随着这些NLB场景变得越来越复杂, 对WCF的架构带来了越来越多的挑战. 本文仅对wsHttpBinding+Message Security+Windows Authentication在NLB的环境下最常见的文件进行讨论..

%26nbsp;

介绍 :

%26nbsp;

通过阅读本文, 您可以了解到:

  1. NLB下wsHttpBinding+Message Security+Windows Authentication常见的异常.`
  2. WCF Message Security的Windows Authentication是如何进行的.
  3. 提供几种典型的WCF Security的配置方式.

%26nbsp;

预备知识 :

%26nbsp;

WCF wsHttpBinding默认采用Message Security模式. 相比Transport Security模式,它有很多优点。例如:提供了End-to-End security, 允许选择性的加密部分消息,与传输协议无关可以用于任何传输协议,提供更多的安全选择。更多内容可以参考 :

http://msdn.microsoft.com/en-us/library/ff648863.aspx

http://msdn.microsoft.com/en-us/library/ms733137(v=vs.110).aspx

%26nbsp;

Message Security 下有多种客户端验证方式。 其中Windows authentication是比较常用的Credential Type,并且是默认值。更多内容可以参考:

http://msdn.microsoft.com/en-us/library/ms731346(v=vs.110).aspx

%26nbsp;

%26nbsp;

常见问题 :

%26nbsp;

在Standalone的服务器上WCF Security能够很好的工作. 但是在NLB的环境上, 由于错误的配置方式, 可能会遇到下面的常见错误 :

%26nbsp;

l%26nbsp; The SecurityContextSecurityToken with context-id=urn:uuid:xxxx(key generation-id=) is not registered. at System.ServiceModel.Security.WSSecureConversation.SecurityContextTokenEntry.ReadTokenCore

l%26nbsp; %26lt;System.ServiceModel.Security.SecurityNegotiationException: Cannot find the negotiation state for the context 'uuid-xxxx

%26nbsp;

%26nbsp;

WsHttpBinding+Message Security+Windows Authentication是如何工作的 :

%26nbsp;

要了解这两个错误是如何发生的, 首先需要了解正常情况下wsHttpBinding Message Security是如何进行Windows 验证的.

%26nbsp;

一般情况下, wsHttpBinding按照SPNEGO来引导一个SecurityContextToken(SCT)的生成, 并且将SCT缓存到服务器端. STCs 是基于对称密钥生成的,能够非常有效的签注/加密(signing/encrypting)消息。 当确定客户端会向服务器端发送多次请求的时候,这是一种非常好的提供效率的方式。通过观察WCF TRACE,一般来说会看到这样的过程。首先客户端和服务端生成一个SCT,然后进行一个SPNEGO的过程(有可能是多次请求才能完成),最后客户端和服务端交换SCT并且使用SCT加密WCF的调用。

下面比较详细的列举出整个步骤

  1. 客户端首先进行SP-Nego 握手, 这个过程完成后会生成一个SCT。

1)%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp; 客户端先发送一个Request Security Token(RST)。RST的目的是生成SP-Nego TokenType,它包含了一个SP-Nego块.

2)%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp; 服务端返回一个Request Security Token Response (RSTR).

3)%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp; 如果需要的话,客户端会将RSTR再次发送给服务端.

4)%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp; 服务端将一个对称密钥包裹在STC里, 又将STC包裹在Request Security Token Response Collection (RSTRC). 然后把RSTRC发送给客户端.

一般来说3)和4)可能会发生多次, 一般情况下可能会有4次, 2次客户端2次服务端.

%26nbsp;

  1. 客户端向服务端请求另外一个SCT用于消息层面的security。这个SCT是一个长生命是周期,并且真正代表了客户端和服务端之间的session key.

1)%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp; 客户端用SCT加注并且加密RST, 并把RST发送到服务端.

2)%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp; 服务器端用SCT加注并加密一个RSTR并发送会客户端. 这个RSTR中包含了一个SCT.

这里仅发生一次RST/RSTR.

%26nbsp;

  1. 客户端在得到 2 所产生的SCT之后,开始执行WCF调用。

1)%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp; 客户端使用上一步所得到的SCT来加密消息. 进行WCF调用.

2)%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp; 服务端执行完成之后, 使用同一的SCT来加密消息并返回给客户的. 在这里addressing headers会被签注, 消息体会被签注并且加密.

%26nbsp;

问题分析 :

%26nbsp;

问题一 :

%26nbsp;

The SecurityContextSecurityToken with context-id=urn:uuid:a02a1879-3297-4dee-8035-68eb30ed4195 (key generation-id=) is not registered.

at System.ServiceModel.Security.WSSecureConversation.SecurityContextTokenEntry.ReadTokenCore(XmlDictionaryReader reader, SecurityTokenResolver tokenResolver)

at System.ServiceModel.Security.WSSecurityTokenSerializer.ReadTokenCore(XmlReader reader, SecurityTokenResolver tokenResolver)

at System.IdentityModel.Selectors.SecurityTokenSerializer.ReadToken(XmlReader reader, SecurityTokenResolver tokenResolver)

at System.ServiceModel.Security.ReceiveSecurityHeader.ReadToken(XmlReader reader, SecurityTokenResolver tokenResolver, IList1 allowedTokenAuthenticators, SecurityTokenAuthenticator%26amp;amp;amp; usedTokenAuthenticator)

at System.ServiceModel.Security.ReceiveSecurityHeader.ReadToken(XmlDictionaryReader reader, Int32 position, Byte[] decryptedBuffer, SecurityToken encryptionToken, String idInEncryptedForm, TimeSpan timeout)

at System.ServiceModel.Security.ReceiveSecurityHeader.ExecuteFullPass(XmlDictionaryReader reader)

at System.ServiceModel.Security.StrictModeSecurityHeaderElementInferenceEngine.ExecuteProcessingPasses(ReceiveSecurityHeader securityHeader, XmlDictionaryReader reader)

at System.ServiceModel.Security.ReceiveSecurityHeader.Process(TimeSpan timeout)

at System.ServiceModel.Security.MessageSecurityProtocol.ProcessSecurityHeader(ReceiveSecurityHeader securityHeader, Message%26amp;amp;amp; message, SecurityToken requiredSigningToken, TimeSpan timeout, SecurityProtocolCorrelationState[] correlationStates)

at System.ServiceModel.Security.SymmetricSecurityProtocol.VerifyIncomingMessageCore(Message%26amp;amp;amp; message, String actor, TimeSpan timeout, SecurityProtocolCorrelationState[] correlationStates)

at System.ServiceModel.Security.MessageSecurityProtocol.VerifyIncomingMessage(Message%26amp;amp;amp; message, TimeSpan timeout, SecurityProtocolCorrelationState[] correlationStates)

at System.ServiceModel.Channels.SecurityChannelListener1.ServerSecurityChannel1.VerifyIncomingMessage(Message%26amp;amp;amp; message, TimeSpan timeout, SecurityProtocolCorrelationState[] correlationState)

at System.ServiceModel.Channels.SecurityChannelListener1.SecurityReplyChannel.ProcessReceivedRequest(RequestContext requestContext, TimeSpan timeout)

at System.ServiceModel.Channels.SecurityChannelListener1.ReceiveRequestAndVerifySecurityAsyncResult.ProcessInnerItem(RequestContext innerItem, TimeSpan timeout)

at System.ServiceModel.Channels.SecurityChannelListener1.ReceiveItemAndVerifySecurityAsyncResult2.OnInnerReceiveDone()

at System.ServiceModel.Channels.SecurityChannelListener1.ReceiveItemAndVerifySecurityAsyncResult2.InnerTryReceiveCompletedCallback(IAsyncResult result)

at System.ServiceModel.Diagnostics.Utility.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)

at System.ServiceModel.AsyncResult.Complete(Boolean completedSynchronously)

at System.ServiceModel.Channels.InputQueue1.AsyncQueueReader.Set(Item item)

at System.ServiceModel.Channels.InputQueue1.Dispatch()

at System.ServiceModel.Channels.InputQueue1.OnDispatchCallback(Object state)

at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.WorkItem.Invoke2()

at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.WorkItem.OnSecurityContextCallback(Object o)

at System.Security.SecurityContext.Run(SecurityContext securityContext, ContextCallback callback, Object state)

at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.WorkItem.Invoke()

at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.ProcessCallbacks()

at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.CompletionCallback(Object state)

at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)

at System.ServiceModel.Diagnostics.Utility.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)

at System.Threading.IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped pOVERLAP)

%26nbsp;

这个错误在服务端和客户端均能看到, 但大多数情况下是在服务端发生, 并且将这一的错误饭或到了客户端. 这个错误的字面意思就是找不到SCT. 但是既然能够肯到STC的UUID, 那么说明这个SCT确实存在.

参照上面STC生成的过程可以看到, STC是服务端和客户端进过多次的交涉最终才能形成. 这个STC只能在这个服务端和客户端之间传递, 并不能分享给第三方. 这是出于安全的考虑.

这个问题最常见于NLB的环境中.如果NLB设备或者软件没有启用Sticky Session. 在有多台WCF服务器的情况下, 客户端发起的请求很有可能被转移到另外一台服务器上. 由于STC并不会被第三方获取, 那么另外一个服务器上不会有相同的SCT. 因此服务端会认为这个STC并没有被注册.

%26nbsp;

%26nbsp;

问题二:

%26nbsp;

%26lt;ExceptionType%26gt;System.ServiceModel.Security.SecurityNegotiationException, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089%26lt;/ExceptionType%26gt;

%26lt;Message%26gt;Cannot find the negotiation state for the context 'uuid-954e94c0-6e42-4816-b53f-bc75e18a9534-2'.%26lt;/Message%26gt;

%26lt;StackTrace%26gt;

at System.ServiceModel.Security.NegotiationTokenAuthenticator`1.ProcessRequestCore(Message request)

at System.ServiceModel.Security.NegotiationTokenAuthenticator`1.NegotiationHost.NegotiationSyncInvoker.Invoke(Object instance, Object[] inputs, Object[]%26amp;amp; outputs)

at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc%26amp;amp; rpc)

at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc%26amp;amp; rpc)

at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc%26amp;amp; rpc)

at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc%26amp;amp; rpc)

at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc%26amp;amp; rpc)

at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc%26amp;amp; rpc)

at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

at System.ServiceModel.Dispatcher.ChannelHandler.DispatchAndReleasePump(RequestContext request, Boolean cleanThread, OperationContext currentOperationContext)

at System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(RequestContext request, OperationContext currentOperationContext)

at System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(IAsyncResult result)

at System.ServiceModel.Dispatcher.ChannelHandler.OnAsyncReceiveComplete(IAsyncResult result)

at System.ServiceModel.Diagnostics.Utility.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)

at System.ServiceModel.AsyncResult.Complete(Boolean completedSynchronously)

at System.ServiceModel.Channels.InputQueue`1.AsyncQueueReader.Set(Item item)

at System.ServiceModel.Channels.InputQueue`1.Dispatch()

at System.ServiceModel.Channels.InputQueue`1.OnDispatchCallback(Object state)

at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.WorkItem.Invoke2()

at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.WorkItem.OnSecurityContextCallback(Object o)

at System.Security.SecurityContext.Run(SecurityContext securityContext, ContextCallback callback, Object state)

at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.WorkItem.Invoke()

at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.ProcessCallbacks()

at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.CompletionCallback(Object state)

at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)

at System.ServiceModel.Diagnostics.Utility.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)

at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

%26lt;/StackTrace%26gt;

%26nbsp;

这个问题较多情况是发生在SPNego的阶段. 从上面介绍的步骤能够看到, SPNego的整个阶段很长,需要服务端和客户端进行多次的交流. 这这个交流的过程中, 任何一次请求被NLB递交到一个错误的服务器上都有可能造成这样的错误.

%26nbsp;

%26nbsp;

解决方案 :

%26nbsp;

造成上面问题的主要原因之一就是NLB的设备或者软件将客户端的请求递交到了一台错误的的服务器上. 要解决这一的问题, 最好的方法就是启用NLB上的Sticky Session. 在某些情形下, 如果NLB并不支持这种做法, 那么可以通过修改WCF配置来绕过这写问题.

%26nbsp;

为了解决第一个问题, 需要禁用Establishing Security Context. 禁用后, STC并不会被缓存起来, 也不会使用对称密钥, 而是改用非对称密钥, 而且每次都需要重新生成STC. 这种做法的副作用是降低WCF的性能.

%26nbsp;

 1 %26lt;bindings%26gt;
 2 
 3    %26lt;wsHttpBinding%26gt;
 4 
 5     %26lt;binding name=%26rdquo;MyServiceBinding%26rdquo;%26gt;    
 6 
 7      %26lt;security mode=%26rdquo;Message%26rdquo; %26gt;
 8 
 9       %26lt;message establishSecurityContext=%26rdquo;false%26rdquo; clientCredentialType=%26rdquo;Windows%26rdquo; /%26gt;           
10 
11      %26lt;/security%26gt;
12 
13     %26lt;/binding%26gt;
14 
15    %26lt;/wsHttpBinding%26gt;
16 
17   %26lt;/bindings%26gt;

%26nbsp;

%26nbsp;

%26nbsp;

在解决第一个问题后, 仍然可能会遇到第二个问题. 因为默认情况下会服务端和客户端仍然会Negotiate Service Credential. 在这个过程中, 同样有可能会被NLB的行为中断从而引发问题. 可以通过禁用NegotiateServiceCredential来绕过这个问题.

 1 %26lt;bindings%26gt;
 2 
 3    %26lt;wsHttpBinding%26gt;
 4 
 5     %26lt;binding name=%26rdquo;MyServiceBinding%26rdquo;%26gt;    
 6 
 7      %26lt;security mode=%26rdquo;Message%26rdquo; %26gt;
 8       %26lt;message establishSecurityContext=%26rdquo;false%26rdquo; NegotiateServiceCredential=%26rdquo;false%26rdquo;
 9 
10 clientCredentialType=%26rdquo;Windows%26rdquo; /%26gt;           
11 
12      %26lt;/security%26gt;
13 
14     %26lt;/binding%26gt;
15 
16    %26lt;/wsHttpBinding%26gt;
17 
18   %26lt;/bindings%26gt;

%26nbsp;

%26nbsp;

将属性设置为%26nbsp;true%26nbsp;需要客户端和服务支持 WS-Trust 和 WS-SecureConversation。%26nbsp;将属性设置为%26nbsp;false%26nbsp;时不需要 WS-Trust 或 WS-SecureConversation 受支持。对于 Windows 凭据,将此属性设置为%26nbsp;false%26nbsp;将导致基于%26nbsp;KerberosToken%26nbsp;的身份验证。%26nbsp;这要求客户端和服务都是 Kerberos 域的一部分。%26nbsp;此模式可与实现 OASIS Kerberos 令牌配置文件的 SOAP 堆栈交互操作。%26nbsp;将此属性为%26nbsp;true%26nbsp;会引起通过 SOAP 消息进行 SPNego 交换的 SOAP 协商. 如果将此属性设置为%26nbsp;false,并且将绑定配置为使用 Windows 作为客户端凭据类型,则必须将服务帐户与服务主体名称 (SPN) 相关联。%26nbsp;为此,请在 NETWORK SERVICE 帐户或 LOCAL SYSTEM 帐户下运行服务。%26nbsp;也可以使用 SetSpn.exe 工具为服务帐户创建一个 SPN。%26nbsp;不论何种情况,客户端都必须使用%26lt;servicePrincipalName%26gt;%26nbsp;元素中的正确 SPN,或者通过使用%26nbsp;EndpointAddress%26nbsp;构造函数来应用正确的 SPN。

%26nbsp;

除此之外, 还有下面的集中组合可以适用于NLB的环境中. 其中, BasicHttpBinding和wsHttpBinding均可以相互替换

%26bull;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp; BasicHttpBinding - TransportCredentialOnly - Windows

%26bull;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp; BasicHttpBinding - TransportCredentialOnly - Ntlm

%26bull;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp; BasicHttpBinding - TransportWithMessageCredential - UserName

%26bull;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp; BasicHttpBinding - TransportWithMessageCredential - Certificate

%26bull;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp; wsHttpBinding - Transport - Ntlm

%26nbsp;

l%26nbsp;%26nbsp; BasicHttp %26ndash; TransportCredentialOnly %26ndash; Windows

Service %26ndash; web.config

%26nbsp;

 1 %26lt;basicHttpBinding%26gt;
 2 
 3         %26lt;binding name="basicN"%26gt;
 4 
 5           %26lt;security mode="TransportCredentialOnly"%26gt;
 6 
 7             %26lt;transport clientCredentialType="Windows"/%26gt;
 8 
 9           %26lt;/security%26gt;
10 
11         %26lt;/binding%26gt;
12 
13 %26lt;/basicHttpBinding%26gt;
14 
15  
16 
17 %26lt;endpoint address=""
18 
19                   binding="basicHttpBinding"
20 
21                   contract="WindowsAuthTestService.IService1"
22 
23                   bindingConfiguration="basicN"
24 
25                   /%26gt;

%26nbsp;

%26nbsp;

Client %26ndash; app.config

%26nbsp;

 1 %26lt;bindings%26gt;
 2 
 3             %26lt;basicHttpBinding%26gt;
 4 
 5                 %26lt;binding name="BasicHttpBinding_IService1"%26gt;
 6 
 7                     %26lt;security mode="TransportCredentialOnly"%26gt;
 8 
 9                         %26lt;transport clientCredentialType="Windows" /%26gt;
10 
11                     %26lt;/security%26gt;
12 
13                 %26lt;/binding%26gt;
14 
15             %26lt;/basicHttpBinding%26gt;
16 
17         %26lt;/bindings%26gt;
18 
19         %26lt;client%26gt;
20 
21             %26lt;endpoint address="http://localhost/WindowsAuthTestService/Service1.svc"
22 
23                 binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
24 
25                 contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" /%26gt;
26 
27         %26lt;/client%26gt;

%26nbsp;

%26nbsp;

%26nbsp;

l%26nbsp;%26nbsp; BasicHttp %26ndash; TransportCredentialOnly %26ndash; Ntlm

Service %26ndash; web.config

%26nbsp;

 1 %26lt;basicHttpBinding%26gt;
 2 
 3         %26lt;binding name="basicN"%26gt;
 4 
 5           %26lt;security mode="TransportCredentialOnly"%26gt;
 6 
 7             %26lt;transport clientCredentialType="Ntlm"/%26gt;
 8 
 9           %26lt;/security%26gt;
10 
11         %26lt;/binding%26gt;
12 
13 %26lt;/basicHttpBinding%26gt;
14 
15  
16 
17 %26lt;endpoint address=""
18 
19                   binding="basicHttpBinding"
20 
21                   contract="WindowsAuthTestService.IService1"
22 
23                   bindingConfiguration="basicN"
24 
25                   /%26gt;

%26nbsp;

%26nbsp;

Client %26ndash; app.config

%26nbsp;

 1 %26lt;bindings%26gt;
 2 
 3             %26lt;basicHttpBinding%26gt;
 4 
 5                 %26lt;binding name="BasicHttpBinding_IService1"%26gt;
 6 
 7                     %26lt;security mode="TransportCredentialOnly"%26gt;
 8 
 9                         %26lt;transport clientCredentialType="Ntlm" /%26gt;
10 
11                     %26lt;/security%26gt;
12 
13                 %26lt;/binding%26gt;
14 
15             %26lt;/basicHttpBinding%26gt;
16 
17         %26lt;/bindings%26gt;
18 
19         %26lt;client%26gt;
20 
21             %26lt;endpoint address="http://pupanda-win8.fareast.corp.microsoft.com/WindowsAuthTestService/Service1.svc"
22 
23                 binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
24 
25                 contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" /%26gt;
26 
27         %26lt;/client%26gt;

%26nbsp;

%26nbsp;

l%26nbsp;%26nbsp; BasicHttp %26ndash; TransportWithMessageCredential %26ndash; UserName

Service %26ndash; web.config

%26nbsp;

 1 %26lt;bindings%26gt;
 2 
 3       %26lt;basicHttpBinding%26gt;
 4 
 5         %26lt;binding name="b0"%26gt;
 6 
 7           %26lt;security mode="TransportWithMessageCredential"%26gt;
 8 
 9             %26lt;message clientCredentialType="UserName"/%26gt;
10 
11           %26lt;/security%26gt;
12 
13         %26lt;/binding%26gt;
14 
15       %26lt;/basicHttpBinding%26gt;
16 
17     %26lt;/bindings%26gt;
18 
19  
20 
21 %26lt;serviceBehaviors%26gt;
22 
23         %26lt;behavior name="sb"%26gt;
24 
25           %26lt;serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/%26gt;
26 
27           %26lt;serviceDebug includeExceptionDetailInFaults="true"/%26gt;
28 
29           %26lt;serviceCredentials%26gt;
30 
31             %26lt;userNameAuthentication userNamePasswordValidationMode="Windows" /%26gt;
32 
33             %26lt;serviceCertificate findValue="11 12 32 12"
34 
35                   storeLocation="LocalMachine"
36 
37                   storeName="My"
38 
39                   x509FindType="FindBySerialNumber"/%26gt;
40 
41           %26lt;/serviceCredentials%26gt;
42 
43         %26lt;/behavior%26gt;
44 
45       %26lt;/serviceBehaviors%26gt;

%26nbsp;

%26nbsp;

Client %26ndash; app.config

%26nbsp;

 1 %26lt;bindings%26gt;
 2 
 3             %26lt;basicHttpBinding%26gt;
 4 
 5                 %26lt;binding name="BasicHttpBinding_IService1"%26gt;
 6 
 7                     %26lt;security mode="TransportWithMessageCredential" /%26gt;
 8 
 9                 %26lt;/binding%26gt;
10 
11             %26lt;/basicHttpBinding%26gt;
12 
13         %26lt;/bindings%26gt;
14 
15         %26lt;client%26gt;
16 
17             %26lt;endpoint address="https://server/TransportMessageService/Service1.svc"
18 
19                 binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
20 
21                 contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" /%26gt;
22 
23         %26lt;/client%26gt;

%26nbsp;

BasicHttp %26ndash; TransportWithMessageCredential %26ndash; Certificate

Service %26ndash; web.config

%26nbsp;

 1 %26lt;basicHttpBinding%26gt;
 2 
 3         %26lt;binding name="b0"%26gt;
 4 
 5           %26lt;security mode="TransportWithMessageCredential"%26gt;
 6 
 7             %26lt;message clientCredentialType="Certificate"/%26gt;
 8 
 9           %26lt;/security%26gt;
10 
11         %26lt;/binding%26gt;

%26nbsp;

%26nbsp;

Client %26ndash; app.config

%26nbsp;

 1 %26lt;bindings%26gt;
 2 
 3             %26lt;basicHttpBinding%26gt;
 4 
 5                 %26lt;binding name="BasicHttpBinding_IService1"%26gt;
 6 
 7                     %26lt;security mode="TransportWithMessageCredential"%26gt;
 8 
 9                       %26lt;message clientCredentialType="Certificate"/%26gt;
10 
11                     %26lt;/security%26gt;
12 
13                 %26lt;/binding%26gt;
14 
15             %26lt;/basicHttpBinding%26gt;
16 
17         %26lt;/bindings%26gt;
18 
19         %26lt;client%26gt;
20 
21             %26lt;endpoint address="https://server2/TransportMessageService/Service1.svc"
22 
23                 binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1" behaviorConfiguration="cl"
24 
25                 contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" /%26gt;
26 
27         %26lt;/client%26gt;
28 
29       %26lt;behaviors%26gt;
30 
31         %26lt;endpointBehaviors%26gt;
32 
33           %26lt;behavior name="cl"%26gt;
34 
35             %26lt;clientCredentials%26gt;
36 
37               %26lt;clientCertificate findValue="31 7c d9 40 b5 ac b0 8e 99 99 00 00 12"
38 
39                   storeLocation="LocalMachine"
40 
41                   storeName="My"
42 
43                   x509FindType="FindBySerialNumber"/%26gt;
44 
45             %26lt;/clientCredentials%26gt;
46 
47  
48 
49           %26lt;/behavior%26gt;
50 
51         %26lt;/endpointBehaviors%26gt;
52 
53       %26lt;/behaviors%26gt;

%26nbsp;

%26nbsp;

l%26nbsp;%26nbsp; wsHttpBinding %26ndash; Transport %26ndash; Ntlm

%26nbsp;

Service %26ndash; web.config

%26nbsp;

 1 %26lt;wsHttpBinding%26gt;
 2 
 3                 %26lt;binding name="wsTransportBinding"%26gt;
 4 
 5                     %26lt;security mode="Transport"%26gt;
 6 
 7                         %26lt;transport clientCredentialType="Ntlm" /%26gt;
 8 
 9                     %26lt;/security%26gt;
10 
11                 %26lt;/binding%26gt;
12 
13             %26lt;/wsHttpBinding%26gt;
14 
15  
16 
17 Client %26ndash; app.config
18 
19  
20 
21 %26lt;bindings%26gt;
22 
23             %26lt;wsHttpBinding%26gt;
24 
25                 %26lt;binding name="WSHttpBinding_IService1"%26gt;
26 
27                     %26lt;security mode="Transport"%26gt;
28 
29                         %26lt;transport clientCredentialType="Ntlm" /%26gt;
30 
31                     %26lt;/security%26gt;
32 
33                 %26lt;/binding%26gt;
34 
35             %26lt;/wsHttpBinding%26gt;
36 
37         %26lt;/bindings%26gt;
38 
39         %26lt;client%26gt;
40 
41             %26lt;endpoint address="https://server/TransportMessageService/Service1.svc"
42 
43                 binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService1"
44 
45                 contract="ServiceReference1.IService1" name="WSHttpBinding_IService1"%26gt;
46 
47                 %26lt;identity%26gt;
48 
49                     %26lt;servicePrincipalName value="host/pupanda-server.fareast.corp.microsoft.com" /%26gt;
50 
51                 %26lt;/identity%26gt;
52 
53             %26lt;/endpoint%26gt;
54 
55         %26lt;/client%26gt;

%26nbsp;

%26nbsp;

%26nbsp;

参考文档 :

%26nbsp;

http://msdn.microsoft.com/en-us/library/vstudio/hh273122(v=vs.100).aspx

http://blogs.msdn.com/b/socaldevgal/archive/2007/08/15/why-is-wshttpbinding-secure-by-default-how-does-it-work.aspx

http://stackoverflow.com/questions/1683724/what-are-the-impacts-of-setting-establishsecuritycontext-false-if-i-use-https

http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512/ws-secureconversation-1.3-os.html

PLUS模型土地利用变化模拟使用简介 因子包括自然因子如社会因子,通过计算整理得到新图层,并以tif文件输出到驱动因子的文件夹里,驱动因子文件夹里存放的是tif文件格式。线性回归使用提供的所有的LULC资源数据,可以选择往后预测的年数,选择好数据之后,可以得出预测的每一年的每一用地类型面积数据。在此过程之后,可以继续使用此CARS输入的数据继续模拟,也可返回二(3)中CARS模块,重新输入不同的年份预测。在此过程之后,可以继续使用此CARS输入的数据继续模拟,也可返回二(3)中CARS模块,重新输入不同的年份预测。 阅读详情

相关推荐

Mac上安装Label Studio

以上步骤详细说明了如何在Mac上通过Anaconda安装Label Studio。记得根据你的具体需求选择是否创建新的环境,并使用conda或pip进行安装。安装完成后,务必验证Label Studio是否成功运行。

g2526的博客 1959

WCF源码(绑定)

WCF中指定了通信细节,主要包含协议、编码、传输 1、BasicHttpBinding 这种绑定适用于与符合 WS-Basic Profile 的 Web 服务(例如基于 ASP.NET Web 服务 (ASMX) 的服务)进行的通信。此绑定使用 HTTP 作为传输协议,并使用文本/XML 作为默认的消息编码。 basicHttpBinding的默认安全模式是None,即没有任何

wyxhd2008的专栏 854

如何利用GMS构建地下水数值模拟模型?

第一步:点图中三维网格的图标然后点Grid→Create Grid这个界面是用于创建一个有限差分网格的设置窗口。它允许你定义网格在三维空间中的范围、分辨率以及其他相关属性。这个界面提供了一个直观的方式来定义一个三维的有限差分网格,你需要指定每个维度上的范围、划分的单元格数量,以及一些控制单元格大小分布和网格方向的参数。这个网格通常会被用于数值模拟,例如地下水流模拟。在点击 "OK" 之前,请务必仔细检查所有参数是否符合你的建模需求。1. X-Dimension (X 轴维度)2. Y-Dimension (

weixin_44259522的博客 2096

webservice之WSDL文件详解

   WSDL:  Web Services Description Language  网页服务描述语言   详解WSDL文档元素: 文件是以XML格式定义的,内容分成了5大元素: 1、<types>:webservice使用的数据类型,它是独立以机器和语言的类型定义,这些数据类型被<message>标签所使用。 2、<message>:webse...

zengjz888的专栏 1163

Swift Package Manager (SPM) 创建并集成本地库

Swift Package Manager (SPM) 在macOS 项目中创建并集成的完整步骤

征战无悔人生 1427

Zemax操作41--公差分析(一)

zemax公差

lzy750750的博客 5975

使用wsHttpBinding构建Message安全模式和UserName授权

http://www.cnblogs.com/artech/archive/2011/05/22/authentication_01.html https://www.cnblogs.com/Frank-yafeya/p/3283699.html https://www.cnblogs.com/jfzhu/p/4067873.html https://www.cnblogs.com/niao...

weixin_30951231的博客 376

ADRC自抗扰控制:工程抗扰“黑科技”,附C代码实战!

自抗扰控制(ADRC)是一种革新性的强鲁棒控制策略,通过主动估计和补偿系统扰动,无需精确数学模型即可实现优异控制性能。本文详细解析ADRC三大核心组件:跟踪微分器(TD)实现指令柔化,扩张状态观测器(ESO)实时估计总扰动,非线性状态反馈(NLSEF)完成动态补偿。针对二阶系统,文章提供完整的参数设计方法和C语言实现框架,包括关键函数fhan和fal的代码实现。ADRC将复杂对象"线性化"为积分器串联系统,显著提升抗扰能力,特别适用于电机控制、飞行器姿态等存在模型不确定性和强干扰的场景。

技术工作者 1738

什么是 Web Service 的 Service Binding

Web Service 的 Service Binding 是 Web 服务架构中的一个关键概念,它定义了服务接口(Service Interface)和具体的传输协议(如 HTTP、SMTP 等)以及消息格式(如 SOAP、XML 等)之间的关系。这一概念在 Web 服务的实现过程中至关重要,因为它确定了服务如何在网络上发布和访问。

孔乙己的博客 765

zemax 如何编译用户自定义DLL(含VS下载教程)

zemax 如何编译用户自定义DLL(含VS下载教程)

weixin_72050316的博客 493

NLP高频面试题(三十一)——多模态预训练模型的主要结构、特征对齐与融合方法及对比损失函数详解

多模态预训练模型通过创新的架构设计和训练策略,在跨模态理解和表示学习上取得了显著进展。从单塔到双塔,从编码器-解码器混合到图结构模型,研究者们探索了不同的模态融合途径;配合显式与隐式对齐手段以及有效的对比学习损失,当前的多模态模型已经能够在图文检索、视觉问答、图像描述生成等任务上接近甚至超越专门的有监督模型。可以说,多模态预训练成为了继NLP和CV单模态预训练之后的又一个AI热点领域。模型规模与泛化:与单模态的大型预训练模型类似,多模态模型的参数规模和训练数据规模在迅速增长。

WeLearnNLP 2925

xfire 404

org.codehaus.xfire.fault.XFireFault: Server returned error code = 404 for URI : http://…………. Check server logs for details 地址错误 查询一下对应的wsdl: location对应的请求地址是否正确

站在技术的边缘,遥望你 1597

大模型——AI对话四象限

{ "摘要": "文章揭示了90%的人不会有效与AI沟通的问题,指出简单粗暴的提问只能得到标准答案。作者提出'AI对话四象限'模型:1)双方都懂时提效;2)AI懂但需学会分层提问;3)共同探索未知领域;4)向AI传授独家知识。强调沟通技巧的重要性,认为会提问的人不会被AI替代。最后呼吁读者尝试四象限思维,与AI碰撞火花。" }

312

【新手实战】从Ehole扫描到SOAP服务分析:我的第一次资产测绘复盘

查阅资料:搜索 “Message HTTP Binding Service”,了解到这是 SOAP (Simple Object Access Protocol) 服务的典型特征,常用于企业级应用的服务间通信。知识盲区就是成长点:以前不懂 SOAP,通过这次“懵逼 - 查证 - 理解”的过程,我反而记得更牢了。费曼总结:真正的安全能力,不是记住所有漏洞编号,而是面对未知服务时,有能力去分析它、理解它、评估它。工具只是起点:Ehole 能告诉我“这是什么”,但不能告诉我“这有没有危险”。

LanSang00的博客 303

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

[WCF安全系列]绑定、安全模式与客户端凭证类型:BasicHttpBinding

整个安全传输是在WCF的信道层进行的,而绑定是信道层的缔造者,所以终结点采用哪种类型的绑定以及对绑定的属性进行怎样的设置决定了信道层最终采用何种机制实现消息的安全传输。具体来说,我们可以通过绑定设置最终采用的安全模式,以及基于相应安全模式下进行认证和消息保护的行为。 一、Binding安全相关的应用编程接口 不同的绑定类型由于其采用的传输协议不同,应用的场景也各有侧重,很难提供一种统一的应用编...

weixin_34062329的博客 222

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

认识一下HttpMessageHandler处理管道

对于由IHttpClientFactory工厂创建的HttpClient来说,它的处理器管道总是包含两个与日志相关的处理器,对应的类型分别是LoggingScopeHttpMessageHandler和LoggingHttpMessageHandler,它们会在不同的边界或范围输出相应的跟踪诊断日志。第2条和第3条日志是LoggingHttpMessageHandler对象输出的,它们写入的时机分别是发送请求前和接收到请求后,最后一条还是输出两者之间的时间间隔,也就是面向网络传输的耗时。

chengxuyuanlaow的博客 1200

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

BindService ---使用Messenger服务端与客户端双向消息传递

1, Messenge方式进行进程间通信的原理图: 2,实现一个简单服务端与客户端双向消息传递的简单例子。 【1】创建一个服务类MessengerService继承自Service package com.ipctest.messenger; import android.app.Service; import android.content.Intent; import andr...

Cricket_7的博客 696

接口开发笔记-WebService

简单介绍了webservices的开发流程

weixin_63658665的博客 3573

我的WCF项目系列之六----WCF 宿主系统服务的异常退出

在很长一段时间里,我把系统服务作为WCF的宿主正式发布后,工作都很正常。知道一个比较单个功能函数耗时较多的服务发布后,经常会异常退出。很长一段时间里,我都认为是相应时间设置太短,一直客户端接受到异常。我好久时间里,都关注和改进这个函数的执行效率,以便于在更短时间内处理完毕。 一直到我看到了系统服务“事件日志”,有报错信息,才正确分析并找到错误点。因为我在调试的过程中,好长一段时间都是还...

diechiqiang6924的博客 375

Web Service渗透测试——介绍+实例演示

一、API 接口介绍 1.1 RPC(远程过程调用) 远程过程调用(英语:Remote Procedure Call,缩写为 RPC)是一个计算机通信协议。该协议允许运行于一台计算机的程序调用另一台计算机的子程序,而程序员无需额外地为这个交互作用编程。如果涉及的软件采用面向对象编程,那么远程过程调用亦可称作远程调用或远程方法调用,例:Java RMI。RPC 一般直接使用 TCP 协议进行通信,通常不涉及到 HTTP。HTTP 下面有2种技术: XML-RPC JSON-RPC Web se...

yggcwhat 4146

关于WCF远程服务器返回错误: (415)

远程服务器返回错误: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'.。 原因在于WCF服务配置文件终结点中binding元素与客户端配置文件终结点中...

ICElike的博客 4967

调用 SSPI 失败,请参见内部异常,System.Net.Security.SslState.StartSendAuthResetSignal 异常解法

调用 SSPI 失败,请参见内部异常,System.Net.Security.SslState.StartSendAuthResetSignal 异常解法

diaya的专栏 7618

Web Service漏洞挖掘

00×01 什么是Web Service Web Service是一个平台独立的,低耦合的,自包含的、基于可编程的web的应用程序,可使用开放的XML(标准通用标记语言下的一个子集)标准来描述、发布、发现、协调和配置这些应用程序,用于开发分布式的交互操作的应用程序。 Web Service技术, 能使得运行在不同机器上的不同应用无须借助附加的、专门的第三方软件或硬件, 就可相互交换数据或集成。依据Web Service规范实施的应用之间, 无论它们所使用的语言、 平台或内部协议是什么, 都可以相互交换数

yggcwhat 7690

史上最全网络端口号大全,网络工程师必备!

一、端口概念 在网络技术中,端口(Port)大致有两种意思: 一是物理意义上的端口,比如,ADSL Modem、集线器、交换机、路由器用于连接其他网络设备的接口,如RJ-45端口、SC端口等等。 二是逻辑意义上的端口,一般是指TCP/IP协议中的端口,端口号的范围从0到65535,比如用于浏览网页服务的80端口,用于FTP服务的21端口等等。 二、网络端口的分类 按端口号可分为3大类: (1)公认端口(Well-KnownPorts):范围从0到1023 (2)动态端口(Dynamic Port

TianYao 9893
上一篇: NGUI 学习总结
下一篇: c++分布式计算类库
lin91o7c
博客等级 码龄12年 1粉丝 26原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值