WCF : 인증이 실패했기 때문에 보안 토큰에 대한 요청은 만족할 수 없습니다.

StackOverflow https://stackoverflow.com/questions/1639035

문제

같은 기계에 두 개의 WCF 서비스가 있습니다. 하나는 출판사이고 하나는 청취자입니다.

게시자는 엔드 포인트를 기반으로 프록시를 동적으로 생성하고 있습니다. 다음과 같은 코드에서 프록시를 구성하고 있습니다.

            WSHttpBinding binding = new WSHttpBinding(SecurityMode.Message, true);
            binding.Security.Message.NegotiateServiceCredential = true;
            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
            binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
            binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
            binding.Security.Message.EstablishSecurityContext = true;
            binding.ReliableSession.Enabled = true;
            binding.TransactionFlow = true;
            return binding;

그리고...

            Binding binding = GetBindingFromAddress(address);

            ChannelFactory<T> factory = new ChannelFactory<T>(binding);
            factory.Credentials.UserName.UserName = "an account on the machine";
            factory.Credentials.UserName.Password = "a password for that account";

            T proxy = factory.CreateChannel(new EndpointAddress(address));

전화를 걸면 위의 오류를받습니다. 여기 내 리스너 구성 파일은 다음과 같습니다.

   <service behaviorConfiguration="MEX Enabled" name="InvoiceSubscriber">
<endpoint binding="wsHttpBinding"
          bindingConfiguration="ReliableTransactionalHTTP"
          contract="AtlanticBT.SubscriptionService.Contracts.v1.IAtlanticEvents">
 <identity>
  <dns value="localhost" />
 </identity>
</endpoint>

        <bindings>
        <wsHttpBinding>
            <binding name="ReliableTransactionalHTTP" transactionFlow="true">
                <reliableSession enabled="true"/>
      <security mode="Message">
        <transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/>
        <message clientCredentialType="Windows" negotiateServiceCredential="true" 
                 algorithmSuite="Default" establishSecurityContext="true"/>
      </security>
            </binding>
  </wsHttpBinding>
    </bindings>

서비스를 호스팅하는 디렉토리에서 모든 ACL을 확인했으며 정확한 것으로 보입니다. IIS 보안은 익명 액세스 및 Windows 인증으로 설정됩니다.

따라서 코드에서 자격 증명을 명시 적으로 설정하고 있다면 왜 내 리스너가 인증 할 수 없습니까?

도움이 되었습니까?

해결책

첫째,이 메시지는 일반적으로 기계가 동일한 도메인에 있지 않으므로 Windows 보안을 사용하여 통신 할 수 없다는 것을 의미합니다. 두 서버가 같은 도메인에 있습니까?

둘째, Windows 보안을 사용하도록 엔드 포인트를 구성했습니다. 메시지 수준뿐만 아니라 전송 수준에서 Windows 보안을 사용합니다. 둘 다 과잉처럼 보이고 아마도 운송을하고 싶을 것입니다.

셋째, 구성 한 모든 내용은 "Windows 인증을 사용하고 싶다"고 말하지만 ClientCredentials의 usernameclientCredentials 속성을 설정하고 있습니다. 이러한 속성은 Windows가 아닌 사용자 이름 토큰 보안에만 사용됩니다. Windows 보안은 현재 스레드의 ID를 취해 전달할 것입니다.

의도가 Windows 보안을 사용한다고 가정하면 다음과 같습니다.

  1. 구독자와 통신하기를 원하는 단일 Windows ID에서 게시자 프로세스를 실행하십시오.
  2. 게시자 프로세스 내에서 가장하는 사람을 사용하여 각 통화의 보안 컨텍스트를 변경하십시오 (조사를 살펴보십시오. windowsidentity 더 많은 정보를 위해서)

지금은 사용자 이름/비밀번호 속성을 무시하고 있기 때문에 #2를하고 있다고 생각하더라도 기술적으로 #1을하고 있습니다.

마지막으로, 다양한 종류의 Windows 인증 시나리오에 대한 바인딩을 설정하는 방법에 대한 좋은 설명서가 있습니다.


이 외에도, 나는 당신의 더 많은 정보없이 무엇을 줄 수 있는지 잘 모르겠습니다. 더 많은 정보를 제공하기 위해 질문을 수정/내 질문 중 일부를 답변하면 기꺼이 내 답변을 수정하여 희망적으로 더 유용하게 만들 것입니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top