2014-06-16 3 views
2

내 컴퓨터에서 WCF restfull 서비스를 개발 중이며 HTTP 서비스 끝점에 도달하면 서비스가 예상대로 응답했습니다. 그러나 HTTPS 끝점을 클릭하면 404 찾을 수 없습니다.webHttpBinding WCF 서비스가 HTTPS는 응답하지만 HTTPS는 응답하지 않습니다.

에서 HTTPS 호출이 작동하지 않는 이유 serviceAuthorizationManagerType

어떤 생각으로 구현 된 CustomAuthorizationManager을 발생하지 않습니다 ? 기본 주소가 HTTPS 일 때 HTTP 트래픽을 허용하는 이유는 무엇입니까?

HTTP 응답 enter image description here

HTTPS 응답

enter image description here

의 Web.config

<system.serviceModel> 
    <bindings> 
     <webHttpBinding> 
     <binding name="webHttpTransportSecurity"> 
      <security mode="TransportCredentialOnly"> 
      <!--Basic authentication is NOT supported when running webHttpBinding through IIS 
      see - http://blogs.msdn.com/b/phenning/archive/2008/01/11/custom-usernamepassword-validators-in-net-framework-3-5.aspx 
      and a resolution - http://allen-conway-dotnet.blogspot.co.uk/2012/07/using-basic-authentication-in-rest.html--> 
      <transport clientCredentialType="None"/> 
      </security> 
     </binding> 
     </webHttpBinding> 
    </bindings> 
    <services> 
     <service behaviorConfiguration="restfulBehavior" name="Chubb.SurveyRecommendations.Service.SurveyRecommendationsService"> 
     <!--webHttpBinding allows exposing service methods in a RESTful manner--> 
     <endpoint address="" binding="webHttpBinding" bindingConfiguration="webHttpTransportSecurity" behaviorConfiguration="webHttpBehavior" contract="Chubb.SurveyRecommendations.Service.ISurveyRecommendations"/> 
     <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/> 
     <host> 
      <baseAddresses> 
      <add baseAddress="https://localhost:44300/"/> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="restfulBehavior"> 
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
      <serviceAuthorization serviceAuthorizationManagerType="Chubb.SurveyRecommendations.Service.Security.CustomAuthorizationManager, Chubb.SurveyRecommendations.Service"/> 
     </behavior> 
     </serviceBehaviors> 
     <!--Required default endpoint behavior when using webHttpBinding--> 
     <endpointBehaviors> 
     <behavior name="webHttpBehavior"> 
      <webHttp/> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 
    </system.serviceModel> 

계약

[OperationContract] 
    [WebGet(UriTemplate = "Echo/{value}", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml)] 
    string Echo(string value); 

서비스

public class SurveyRecommendationsService : ISurveyRecommendations 
{ 
    public string Echo(string value) 
    { 
     if (string.IsNullOrWhiteSpace(value)) 
      return string.Empty; 

     return value; 
    } 
} 

답변

3

OK, 문제는 바인딩이었다.

security mode="TransportCredentialOnly"은 전체 전송 (HTTPS) secuirty를 제공하지 않습니다.

값을 security mode="Transport"으로 다시 변경했으며 예상대로 작동했습니다.

세부 this MSDN article

없음에서 찾을 수 있습니다 - 어떤 보안 HTTP 요청과 함께 사용되지 않습니다 나타냅니다.

전송 - 전송 수준 보안이 HTTP 요청과 함께 사용됨을 나타냅니다.

TransportCredentialOnly - HTTP 기반 클라이언트 인 인증 만 제공됨을 나타냅니다.