성태의 닷넷 이야기
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[정성태] Detecting blocking calls using asyn...
[정성태] 아쉽게도, 커뮤니티는 아니고 개인 블로그입니다. ^^
[정성태] 질문이 잘 이해가 안 됩니다. 우선, 해당 소스코드에서 ILis...
[양승조
] var대신 dinamic으로 선언해서 해결은 했습니다. 맞는 해...
[양승조
] 또 막혔습니다. ㅠㅠ var list = props[i].Ge...
[양승조
] 아. 감사합니다. 어제는 안됐던것 같은데....정신을 차려야겠네...
[정성태] "props[i].GetValue(props[i])" 코드에서 ...
[정성태] 저렇게 조각 코드 말고, 실제로 재현이 되는 예제 프로젝트를 압...
[정성태] Modules 창(Ctrl+Shift+U)을 띄워서, 해당 Op...
[정성태] 만드실 수 있습니다. 단지, Unity 엔진 내의 스크립트와 W...
글쓰기
제목
이름
암호
전자우편
HTML
홈페이지
유형
제니퍼 .NET
닷넷
COM 개체 관련
스크립트
VC++
VS.NET IDE
Windows
Team Foundation Server
디버깅 기술
오류 유형
개발 환경 구성
웹
기타
Linux
Java
DDK
Math
Phone
Graphics
사물인터넷
부모글 보이기/감추기
내용
<div style='display: inline'> <div style='font-family: 맑은 고딕, Consolas; font-size: 20pt; color: #006699; text-align: center; font-weight: bold'>System.ServiceModel.Security.SecurityNegotiationException</div> <br /> 매번 WCF 응용 프로그램(예제도 참 많이 만들어보지만.)을 실행할 때마다 뭔가 하나씩 빼먹는 바람에 예외가 발생해서 고생을 하게 되는데요. 그런 연유로 인해, 다양한 예외 유형 정리는 나중에 다시 해당 프로그래밍을 할 때 도움이 됩니다. 그래서 아래와 같이 정리를 해놓고는 하지요. ^^<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; width: 800px; background-color: #fbedbb; overflow-x: scroll; font-family: Consolas, Verdana;' > WCF 인증서 설정 관련 오류 정리 ; <a target='_tab' href='http://www.sysnet.pe.kr/2/0/869'>http://www.sysnet.pe.kr/2/0/869</a> </pre> <br /> 이번엔 SecurityNegotiationException 예외 관련해서 기록을 남깁니다.<br /> <br /> <hr style='width: 50%' /><br /> <br /> 특히나, 예제를 만들때 주로 WCF 서비스 쪽 설정을 다음과 같이 보안을 꺼버리게 되는데요.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; width: 800px; background-color: #fbedbb; overflow-x: scroll; font-family: Consolas, Verdana;' > <bindings> <basicHttpBinding> <binding name="basicHttpBindingConfig"> <security mode="None" /> </binding> </basicHttpBinding> <wsHttpBinding> <binding name="wsHttpBindingConfig"> <security mode="None"/> </binding> </wsHttpBinding> <netTcpBinding> <binding name="netTcpBindingConfig"> <security mode="None"/> </binding> </netTcpBinding> </bindings> </pre> <br /> 거의 고정적으로 위의 설정은 web.config(또는 app.config)에 복사하고, BasicHttpBinding만으로 클라이언트 호출을 하다가! WSHttpBinding, NetTcpBinding 쪽의 바인딩을 사용하는 코드를 다음과 같이 사용을 했습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; width: 800px; background-color: #fbedbb; overflow-x: scroll; font-family: Consolas, Verdana;' > WSHttpBinding wsHttpBinding = new WSHttpBinding(); using (ChannelFactory<IHelloWorld> factory = new ChannelFactory<IHelloWorld>(wsHttpBinding, new EndpointAddress(wsBindingAddress))) { IHelloWorld world = factory.CreateChannel(); ICommunicationObject comm = world as ICommunicationObject; try { world.Echo(); comm.Close(); } catch { comm.Abort(); } } </pre> <br /> 그래서, 다음과 같은 예외가 발생합니다. ^^<br /> <br /> <span style='BACKGROUND-COLOR: #ccffcc; FONT-STYLE: italic; MARGIN: 10px 0px 10px 10px; WIDTH: 800px; FONT-FAMILY: 맑은 고딕, Consolas, Verdana; COLOR: #005555'> A first chance exception of type '<b style='COLOR: blue'>System.ServiceModel.Security.SecurityNegotiationException</b>' occurred in Unknown Module.<br /> <br /> Additional information: Secure channel cannot be opened because security negotiation with the remote endpoint has failed. This may be due to absent or incorrectly specified EndpointIdentity in the EndpointAddress used to create the channel. Please verify the EndpointIdentity specified or implied by the EndpointAddress correctly identifies the remote endpoint. <br /> <br /> Unhandled Exception: System.ServiceModel.Security.SecurityNegotiationException:<br /> Secure channel cannot be opened because security negotiation with the remote endpoint has failed. This may be due to absent or incorrectly specified EndpointIdentity in the EndpointAddress used to create the channel. Please verify the EndpointIdentity specified or implied by the EndpointAddress correctly identifies the remote endpoint. ---> System.ServiceModel.FaultException: The message with Action '<a target='_tab' href='http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue'>http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</a>' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding<br /> (including security requirements, e.g. Message, Transport, None).<br /> at System.ServiceModel.Security.SecurityUtils.ThrowIfNegotiationFault(Message message, EndpointAddress target)<br /> at System.ServiceModel.Security.SspiNegotiationTokenProvider.GetNextOutgoingMessageBody(Message incomingMessage, SspiNegotiationTokenProviderState sspiState)<br /> <br /> --- End of inner exception stack trace ---<br /> <br /> Server stack trace:<br /> at System.ServiceModel.Security.IssuanceTokenProviderBase`1.DoNegotiation(TimeSpan timeout)<br /> at System.ServiceModel.Security.SspiNegotiationTokenProvider.OnOpen(TimeSpantimeout)<br /> ...[생략]...<br /> at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)<br /> <br /> Exception rethrown at [0]:<br /> at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)<br /> at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)<br /> at ConsoleApplication1.IHelloWorld.Echo()<br /> at ConsoleApplication1.Program.Main(String[] args) in D:\...\ConsoleApplication1\ConsoleApplication1\Program.cs:line 24<br /> </span><br /><br /> <br /> 아시는 것처럼, WSHttpBinding은 보안 채널 기본값이 Message이기 때문입니다. 서버 측을 꺼버렸으니 클라이언트 측도 다음과 같이 보안을 해제해 주어야 합니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; width: 800px; background-color: #fbedbb; overflow-x: scroll; font-family: Consolas, Verdana;' > WSHttpBinding wsHttpBinding = new WSHttpBinding(); <b style='COLOR: blue'>wsHttpBinding.Security.Mode = SecurityMode.None;</b> using (ChannelFactory<IHelloWorld> factory = new ChannelFactory<IHelloWorld>(wsHttpBinding, new EndpointAddress(wsBindingAddress))) </pre> <br /> 재미있는 것은, WSHttpBinding과 NetTcpBinding과의 예외 메시지가 틀리다는 점입니다. NetTcpBinding의 경우에는 다음과 같이 ProtocolException이 발생합니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; width: 800px; background-color: #fbedbb; overflow-x: scroll; font-family: Consolas, Verdana;' > <b style='COLOR: blue'>System.ServiceModel.ProtocolException</b> was unhandled Message=The requested upgrade is not supported by 'net.tcp://localhost:9001/addrNetTcpBinding'. This could be due to mismatched bindings (for example security enabled on the client and not on the server). Source=mscorlib StackTrace: Server stack trace: at System.ServiceModel.Channels.ConnectionUpgradeHelper.DecodeFramingFault(ClientFramingDecoder decoder, IConnection connection, Uri via, String contentType, TimeoutHelper& timeoutHelper) at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.SendPreamble(IConnection connection, ArraySegment`1 preamble, TimeoutHelper& timeoutHelper) ... [생략] ... at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at ConsoleApplication1.IHelloWorld.Echo() at ConsoleApplication1.Program.Main(String[] args) in D:\...\ConsoleApplication1\ConsoleApplication1\Program.cs:line 97 ... [생략] ... </pre> <br /> <br /><br /><hr /><span style='color: Maroon'>[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]</span> </div>
첨부파일
스팸 방지용 인증 번호
4562
(왼쪽의 숫자를 입력해야 합니다.)