WCF가 보안되지 않거나 잘못 보안 된 오류 오류를 제공함
원격 서비스 웹 서비스를 사용하려고합니다. 를 사용하여 프록시 클래스를 만든 svcutil.exe후 해당 클래스를 콘솔 응용 프로그램에 추가했지만 오류가 발생합니다.
다른 당사자로부터 보안되지 않은 오류 또는 잘못 보안 된 오류가 수신되었습니다. 결함 코드 및 세부 사항은 내부 결함 예외를 참조하십시오.
System.ServiceModel.FaultException : 메시지에 대한 보안을 확인할 때 오류가 발생했습니다.
나는 WCF 측을 만들지 않았으며 원격 서비스입니다. 도와주세요.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="EloquaDataTransferService" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Mtom" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="TransportWithMessageCredential">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="https://secure.eloqua.com/API/1.2/DataTransferService.svc"
                binding="basicHttpBinding" bindingConfiguration="EloquaDataTransferService"
                contract="DataTransferService" name="EloquaDataTransferService" />
        </client>
    </system.serviceModel>
</configuration>
 
이것은 내 app.config파일입니다. 다음을 consoleApp.cs사용하여 파일 에 사용자 이름과 비밀번호를 제공 obj.ServiceCredentials.UserName.UserName="xxxxxx"하고 있습니다..Password="xxxXx"
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <system.serviceModel>
      <bindings>
         <basicHttpBinding>
            <binding name="EloquaDataTransferService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Mtom" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
               <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
               <security mode="TransportWithMessageCredential">
                  <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
                  <message clientCredentialType="UserName" algorithmSuite="Default" />
               </security>
            </binding>
         </basicHttpBinding>
      </bindings>
      <client>
         <endpoint address="https://secure.eloqua.com/API/1.2/DataTransferService.svc" binding="basicHttpBinding" bindingConfiguration="EloquaDataTransferService" contract="DataTransferService" name="EloquaDataTransferService" />
      </client>
   </system.serviceModel>
</configuration>
이것은 WCF 서비스에서 발생하는 매우 모호한 오류입니다. 문제는 WCF가 서비스에 전달 된 메시지의 보안을 확인할 수 없다는 것입니다.
이것은 거의 항상 서버 시간차 때문입니다. 원격 서버와 클라이언트의 시스템 시간은 (일반적으로) 서로 10 분 이내 여야합니다. 그렇지 않으면 보안 유효성 검사가 실패합니다.
나는 eloqua.com에 전화를 걸어 그들의 서버 시간이 무엇인지 알아 내고 그것을 서버 시간과 비교할 것입니다.
위의 솔루션 중 하나로 문제가 해결되었지만 다른 사람의 이익을 위해 여기에 또 다른 옵션이 있습니다.
사용자 이름 메시지 자격 증명을 그대로 사용하는 기본 엔드 포인트 (SOAP 1.1)에 잘못된 자격 증명이 전달 된 경우에도이 예외가 발생할 수 있습니다. 예를 들어 코드에서 서비스를 호출하고 다음과 같은 작업을 수행하는 경우 :
var service = new TestService();
service.ClientCredentials.UserName.UserName = "InvalidUser";
service.ClientCredentials.UserName.Password = "InvalidPass";
 
이는 AccessDeniedException유효하지 않은 신임 정보가 전달 될 때 발생 하는 WSHTTP 엔드 포인트 (SOAP 1.2)와 다릅니다 . 개인적으로 여기에 포함 된 메시지가 약간 오해의 소지가 있음을 발견했습니다 (이러한 이유로 처음 접했을 때 확실히 몇 분이 소요됨). WCF 진단 추적 로그를 참조하면 근본적인 원인이 분명해졌습니다.
WCF 보안 하위 시스템에 분명히 문제가 있습니다. 어떤 바인딩을 사용하고 있습니까? 어떤 인증? 암호화? 서명? 도메인 경계를 넘어야합니까?
일부 보안 스키마가 동기화 된 시계에 의존하기 때문에 클라이언트와 서버의 시계가 동기화되지 않은 경우 (약 5 분 이상) 다른 사용자가이 오류를 경험하고 있음을 조금 더 자세히 알 수 있습니다.
내 클라이언트 응용 프로그램이 직면하고있는이 문제는 WinForms 응용 프로그램 C # 4.0입니다.
여기에서 솔루션을 읽을 때 클라이언트 컴퓨터의 날짜 및 시간을 확인했지만 맞았고 현재 시간이 표시되었지만 여전히 이러한 문제에 직면했습니다.
몇 가지 해결 방법을 통해 잘못된 시간대를 선택하고 인도에 있고 시간대가 캐나다에 있고 호스트 서버는 쿠웨이트에 있습니다.
나는 시스템이 시간을 표준시로 변환한다는 것을 발견했습니다.
시간대를 인도 시간대로 변경했을 때 문제가 단독으로 발생했습니다.
클라이언트에서 사용자 자격 증명을 전달하는 경우 (아래 코드 블록에 따라) 서버의 사용자 이름 / 암호와 일치해야합니다. 그렇지 않으면이 오류가 발생합니다.
참고로, 제 경우에는 "TransportWithMessageCredential"보안 모드와 함께 "basicHTTPAuthentication"을 사용하고 있습니다. WCF 서비스는 https의 IIS에서 호스팅됩니다.
var service = new TestService();
service.ClientCredentials.UserName.UserName = "InvalidUser";
service.ClientCredentials.UserName.Password = "InvalidPass";
 
이것이 누군가에게 도움이되기를 바랍니다 ... :)
보안 모드를 "전송"으로 변경해보십시오.
보안 태그와 전송 태그가 일치하지 않습니다.
그만한 가치가 있습니다-또한이 오류가 있었고 웹 서비스 web.config의 연결 문자열이 잘못된 시스템에 연결하도록 설정되어 있다는 것을 알았습니다.
필자의 경우에는 certificateValidationMode가 "PeerTrust"로 설정된 인증을 위해 인증서를 사용하고 있었는데 Windows 저장소 (LocalMachine \ TrustedPeople)에 클라이언트 인증서를 설치하여 서버에서 수락하는 것을 잊었습니다.
제 경우에는 wshttpbinding프로토콜을에서 https로 변경했을 때 http작동하기 시작했습니다.
대부분이 예외는 서버에 오류가있을 때 발생하며 가장 일반적인 것은 인증 데이터베이스의 잘못된 구성 또는 인증입니다. 제 경우에는 다른 시계 동기화가 있었는데 클라이언트와 서버가 동일한 설정을 가지고 있는지 확인하십시오
오른쪽 하단에서 시간-> "날짜 시간 설정 변경 ..."-> "인터넷 시간"탭-> 설정 변경 ...-> "인터넷 시간 서버와 동기화"옵션을 선택하십시오. 선택 취소-> 서버 드롭 다운에서 "times.windows.com"선택-> 지금 업데이트-> 확인
또한 동일한 컴퓨터의 서버 및 클라이언트에서도 오래된 서비스 참조 에서이 문제가 발생했습니다. 이것이 문제인 경우 일반적으로 '서비스 참조 업데이트'를 실행하면 문제가 해결됩니다.
제 경우에는 테스트 클라이언트-서버 애플리케이션에서 동일한 시스템에서이 오류가 발생했습니다. 그러나이 문제는 "Update Service Reference"로 해결되었습니다.
- 투 샤르 G. 왈라 발 카르
 
Just for the sake of sharing... I had a rare case that got me scratching the back of my head for a few minutes. Even tho the time skew solution was very accurate, and I had that problem solved before, this time was different. I was on a new Win8.1 machine which I remember having a timezone issue and I had manually adjusted the time. Well, I kept getting the error, despite the time displayed in both server and client had only a diference in seconds. What I did is activate "summer saving option" (note that I am indeed under summer saving time, but had the time setup manually) in "date and time setup" then went to the internet time section and refreshed... the time in my pc kept exactly the same, but the error dissapeared.
Hope this is useful to anybody!
In my case, there are two problems that will throw this exception.
Note that, my environment uses Single Sign On (or STS if you prefer) to authenticate a user through ASP.NET MVC site. MVC site in turn makes a service call to my service endpoint by passing bearer token which it requested from STS server with Bootstrap token previously. The error I got was when I made a service call from MVC site.
The WCF service wasn't configured as a relying party in my SSO (or STS if you prefer).
Service's configuration wasn't configured properly. Particularly on audienceUris node of system.identityModel. It must exactly match the service endpoint url.
<system.identityModel> <identityConfiguration> <audienceUris> <add value="https://localhost/IdpExample.YService/YService.svc" /> </audienceUris> .... </identityConfiguration> </system.identityModel>
Make sure your SendTimeout hasn't elapsed after opening the client. 
I was getting this error due to the BasicHttpBinding not sending a compatible messageVersion to the service i was calling. My solution was to use a custom binding like below
 <bindings>
  <customBinding>
    <binding name="Soap11UserNameOverTransport" openTimeout="00:01:00" receiveTimeout="00:1:00" >
      <security authenticationMode="UserNameOverTransport">
      </security>          
      <textMessageEncoding messageVersion="Soap11WSAddressing10" writeEncoding="utf-8" />
      <httpsTransport></httpsTransport>
    </binding>
  </customBinding>      
</bindings>
Try with this:
catch (System.Reflection.TargetInvocationException e1)  
      String excType   
      excType = e1.InnerException.GetType().ToString()  
      choose case excType  
                case "System.ServiceModel.FaultException"  
                          System.ServiceModel.FaultException e2  
                          e2 = e1.InnerException  
                          System.ServiceModel.Channels.MessageFault fault  
                          fault = e2.CreateMessageFault()  
                          ls_message = "Class: uo_bcfeWS, Method: registraUnilateral ~r~n" + "Exception(1): " + fault.Reason.ToString()   
                          if (fault.HasDetail) then  
                                    System.Xml.XmlReader reader  
                                    reader = fault.GetReaderAtDetailContents()  
                                    ls_message += " " + reader.Value  
                                    do while reader.Read()  
                                              ls_message += reader.Value  
                                    loop  
                          end if  
                case "System.Text.DecoderFallbackException"  
                          System.Text.DecoderFallbackException e3  
                          e3 = e1.InnerException  
                          ls_message = "Class: uo_bcfeWS, Method: registraUnilateral ~r~n" + "Exception(1): " + e3.Message   
                case else  
                          ls_message = "Class: uo_bcfeWS, Method: registraUnilateral ~r~n" + "Exception(1): " + e1.Message  
      end choose  
      MessageBox ( "Error", ls_message )  
      //logError(ls_message)  
      return false  
<wsHttpBinding>
        <binding name="ISG_Binding_Configuration" bypassProxyOnLocal="true" useDefaultWebProxy="false" hostNameComparisonMode="WeakWildcard" sendTimeout="00:30:00" receiveTimeout="00:30:00" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647">
          <readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" />
          <security mode="None">
            <message establishSecurityContext="false" clientCredentialType="UserName"/>
          </security>
        </binding>
      </wsHttpBinding> 
 I had to change the SecurityMode to Message (WSHttpBinding), before it worked. i.e.
_wcf = new ServiceRequestClient(new WSHttpBinding(SecurityMode.Message),                     
       new EndpointAddress(_wcfRequestServerAddress));
In my case, it was a setting on the IIS application pool.
Select the application pool --> Advanced Settings --> Set 'Enable 32 Bit Applications' to True.
Then recycle the application pool.
In my case the server time was not correct. So I changed the server Datetime settings to Set time automatically and it resolved the issue.
'Nice programing' 카테고리의 다른 글
| Linq to SQL은 요점을 놓치지 않습니까? (0) | 2020.11.06 | 
|---|---|
| svn의 마지막 변경 사항보기 (0) | 2020.11.06 | 
| LINQ를 사용하여 문자열에 숫자가 하나 이상 있는지 확인 (0) | 2020.11.06 | 
| NSString에서 영숫자가 아닌 문자 제거 (0) | 2020.11.06 | 
| 하나의 UITableView 셀 / 행만 다시로드하고 애니메이션하는 방법은 무엇입니까? (0) | 2020.11.06 |