2011-01-10 7 views
1

IIS에서 WCF 서비스를 호스팅했습니다. 설정 파일은 다음과 같습니다. 나는 클라이언트 응용 프로그램에서 서비스에 액세스하려고 할 때IIS 6.0에서 호스팅되는 WCF 서비스의 SecurityNegotiationException

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.serviceModel> 
     <bindings> 
      <wsHttpBinding> 
       <binding name="WSHttpBinding_IService1" closeTimeout="00:01:00" 
        openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
        bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
        maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
        messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" 
        allowCookies="false"> 
        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
         maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
        <reliableSession ordered="true" inactivityTimeout="00:10:00" 
         enabled="false" /> 
        <security mode="Message"> 
         <transport clientCredentialType="Windows" proxyCredentialType="None" 
          realm="" /> 
         <message clientCredentialType="Windows" negotiateServiceCredential="true" 
          algorithmSuite="Default" establishSecurityContext="true" /> 
        </security> 
       </binding> 
      </wsHttpBinding> 
     </bindings> 
     <client> 
      <endpoint address="http://yyy.zzz.xxx.net/IISTest2/Service1.svc" 
       binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService1" 
       contract="ServTest.IService1" name="WSHttpBinding_IService1"> 
       <identity> 
        <dns value="localhost" /> 
       </identity> 
      </endpoint> 
     </client> 
    </system.serviceModel> 
</configuration> 

을 다음과 같이

<?xml version="1.0"?> 
<!-- 
    Note: As an alternative to hand editing this file you can use the 
    web admin tool to configure settings for your application. Use 
    the Website->Asp.Net Configuration option in Visual Studio. 
    A full list of settings and comments can be found in 
    machine.config.comments usually located in 
    \Windows\Microsoft.Net\Framework\v2.x\Config 
--> 
<configuration> 


    <configSections> 
     <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> 
     <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> 
      <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/> 
      <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> 
      <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" /> 
      <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" /> 
      <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" /> 
      <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" /> 
      </sectionGroup> 
     </sectionGroup> 
     </sectionGroup> 
    </configSections> 


    <appSettings/> 
    <connectionStrings/> 

    <system.web> 
     <!-- 
      Set compilation debug="true" to insert debugging 
      symbols into the compiled page. Because this 
      affects performance, set this value to true only 
      during development. 
     --> 
     <compilation debug="false"> 

      <assemblies> 
      <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> 
      <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
      </assemblies> 

     </compilation> 
     <!-- 
      The <authentication> section enables configuration 
      of the security authentication mode used by 
      ASP.NET to identify an incoming user. 
     --> 
     <authentication mode="Windows" /> 
     <!-- 
      The <customErrors> section enables configuration 
      of what to do if/when an unhandled error occurs 
      during the execution of a request. Specifically, 
      it enables developers to configure html error pages 
      to be displayed in place of a error stack trace. 

     <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm"> 
      <error statusCode="403" redirect="NoAccess.htm" /> 
      <error statusCode="404" redirect="FileNotFound.htm" /> 
     </customErrors> 
     --> 


     <pages> 
     <controls> 
      <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
     </controls> 
     </pages> 

     <httpHandlers> 
     <remove verb="*" path="*.asmx"/> 
     <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
     <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
     <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/> 
     </httpHandlers> 
     <httpModules> 
     <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
     </httpModules> 


    </system.web> 

    <system.codedom> 
     <compilers> 
     <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" 
        type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 
      <providerOption name="CompilerVersion" value="v3.5"/> 
      <providerOption name="WarnAsError" value="false"/> 
     </compiler> 
     </compilers> 
    </system.codedom> 

    <system.web.extensions> 
     <scripting> 
     <webServices> 
      <!-- 
       Uncomment this section to enable the authentication service. Include 
       requireSSL="true" if appropriate. 

      <authenticationService enabled="true" requireSSL = "true|false"/> 
      --> 
      <!-- 
       Uncomment these lines to enable the profile service, and to choose the 
       profile properties that can be retrieved and modified in ASP.NET AJAX 
       applications. 

      <profileService enabled="true" 
          readAccessProperties="propertyname1,propertyname2" 
          writeAccessProperties="propertyname1,propertyname2" /> 
      --> 
      <!-- 
       Uncomment this section to enable the role service. 

      <roleService enabled="true"/> 
      --> 
     </webServices> 
     <!-- 
     <scriptResourceHandler enableCompression="true" enableCaching="true" /> 
     --> 
     </scripting> 
    </system.web.extensions> 
    <!-- 
     The system.webServer section is required for running ASP.NET AJAX under Internet 
     Information Services 7.0. It is not necessary for previous version of IIS. 
    --> 
    <system.webServer> 
     <validation validateIntegratedModeConfiguration="false"/> 
     <modules> 
     <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
     </modules> 
     <handlers> 
     <remove name="WebServiceHandlerFactory-Integrated"/> 
     <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" 
      type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
     <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" 
      type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
     <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
     </handlers> 
    </system.webServer> 


    <system.serviceModel> 
    <services> 
     <service name="IISTest2.Service1" behaviorConfiguration="IISTest2.Service1Behavior"> 
     <!-- Service Endpoints --> 
     <endpoint address="" binding="wsHttpBinding" contract="IISTest2.IService1"> 
      <!-- 
       Upon deployment, the following identity element should be removed or replaced to reflect the 
       identity under which the deployed service runs. If removed, WCF will infer an appropriate identity 
       automatically. 
      --> 
      <identity> 
      <dns value="localhost"/> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="IISTest2.Service1Behavior"> 
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
      <serviceMetadata httpGetEnabled="true"/> 
      <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 
</configuration> 

클라이언트 구성 파일은 내가

SecurityNegotiationException

있어,하고 세부 사항은

원격 끝점과의 보안 협상이 실패하여보안 채널을 열 수 없습니다. 이 경우 은 이 지정되어 있으므로 채널을 만드는 데 사용 된 EndpointAddress에 EndpointIdentity가 지정되어있을 수 있습니다. EndpointAddress가 으로 지정되거나 암시 된 EndpointIdentity가 올바르게 지정되었는지 확인하십시오. 은 원격 종점을 식별합니다.

ASP.NET 개발 서버에서 서비스를 호스팅하는 경우 제대로 작동하지만 IIS에서 호스팅하면 위와 같은 오류가 발생합니다.

+0

IIS가 클라이언트와 동일한 컴퓨터에 설치되어 있습니까? –

+0

@ Ladislav Mrnka : 같은 컴퓨터에 설치되어 있습니다. 나는 또한 다른 IIS에서 서비스를 호스팅함으로써 결과를 얻었습니다. :(. – Ram

+0

당신의 사용자 권한은 무엇입니까? 관리자입니까? 디렉토리 보안 탭 -> 인증 방법에서 설정 한 사용자는 무엇입니까? – Rev

답변

0

새 테스트 응용 프로그램을 만들고 IIS에서 호스팅되는 서비스에 대한 서비스 참조를 추가하십시오. 완료되면 클라이언트 app.config에서 보안 구성을 확인하십시오. 그런 다음 원래 클라이언트 앱과의 차이점을 발견하는 것만으로 문제가됩니다.

일반적으로이 예외는 클라이언트와 서버간에 보안 구성이 다를 때 발생하며 WCF는 양 당사자를 모두 충족하는 공통된 보안 정책 집합을 찾을 수 없습니다.

+0

새 콘솔 앱을 원하십니까? 현재 클라이언트 앱은이 서비스를 테스트하기 위해 만든 winform 앱입니다. – Ram

1

클라이언트 코드의 clientCredentialType이 "windows"로 설정되어 있습니다. 이것은 기본 제공 Windows 인증을 사용하므로 클라이언트가 실행중인 사용자에게 서비스 호스트 컴퓨터에 대한 적절한 권한이없는 것일 수 있습니다.

그런 말을하면서, 나는 그것이 무엇이되어야하는지 확신 할 수는 없지만 탐구 할 가치가있는 길일지도 모릅니다.

0

당신의 IIS는 Active Directory 도메인의 구성원 인 경우, 유효한 서비스 사용자 이름 (SPN)이 (참조 : Setspn on Technet)가 있어야합니다 또한 예상 SPN을 지정하는 클라이언트 엔드 포인트 구성을 변경해야합니다

.

IIS 호스트 서비스에 대해 svcutil을 실행하여 새 클라이언트 구성 파일을 생성 해보십시오.

예는 :

svcutil.exe http://yyy.zzz.xxx.net/IISTest2/Service1.svc 나서 생성 된 엔드 포인트의 구역 <identity> 자리. <servicePrincipalName> 노드가 있어야합니다.이제이 설정 파일로 클라이언트를 시험해보십시오.

1

클라이언트 및 서버 구성에서 노드 <identity>을 제거해야한다고 생각합니다. 이것은 이미 작동하게 만들 수도 있습니다. 아직 작동하지 않는다면 클라이언트에서 서버 구성으로 wsHttpBinding을 복사합니다. 아직 뭔가 빠져있을 수 있지만 가까이 있어야합니다.

그러나 또 다른 문제가 있습니다. 나는 당신이 원하는 보안의 종류를 분명히해야한다고 생각합니다. 예를 들어 보안 모드 Transport을 구성했지만 보안 설정이인 경우 (this) 나는 Kerberos for WCF를 설정하는 데 도움을주었습니다. 모든 작업이 코드로 이루어졌지만 쉽게 확인할 수 있습니다. 구성은 같을 것이다.

0

바인딩 섹션은 서버에서 클라이언트에 정의 된 것이 아니라.

클라이언트에서 정의되고 서버에 사용되는 기본값이 문제의 원인이 될 수있는 것 사이의 차이를.

다른 문제는 부분 신뢰 문제입니다 .WCF의 보안은 모든 기능. 이 기능이 없으면 기능의 하위 집합 만 지원됩니다 (Partial Trust Feature Compatibility 참조).

관련 문제