2012-01-29 3 views
1

잘 작동하는 IIS (7.5)에 wcf 서비스를 호스트했습니다. 이제 사용자 이름 인증을 추가하고 몇 가지 문제가 발생합니다.WCF 문제 - 사용자 이름 인증 및 전송 WithMessageCredentials를 사용하는 wsHttpBinding

  1. 1) makecert -n "CN = RootCATest"-r -sv RootCATest : 내가이 (MSDN에서 영감) 다음 한 인증서에 대해서는

    <system.serviceModel> 
        <services> 
         <service behaviorConfiguration="warServBehavior" name="WcfServiceLibrary.WarcraftService"> 
         <endpoint address="" binding="wsHttpBinding" contract="WcfServiceLibrary.IWarcraftService" bindingConfiguration="warWsHttpBinding" /> 
         <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" /> 
         </service> 
        </services> 
        <bindings> 
         <wsHttpBinding> 
         <binding name="warWsHttpBinding"> 
          <security mode="TransportWithMessageCredential"> 
          <transport clientCredentialType="None"/> 
          <message clientCredentialType="UserName"/> 
          </security> 
         </binding> 
         </wsHttpBinding> 
        </bindings> 
        <behaviors> 
         <serviceBehaviors> 
         <behavior name="warServBehavior"> 
          <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" /> 
          <serviceDebug includeExceptionDetailInFaults="true"/> 
          <serviceCredentials> 
          <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="BogusValidator, App_Code"/> 
          </serviceCredentials> 
         </behavior> 
         </serviceBehaviors> 
        </behaviors> 
        </system.serviceModel> 
    

    : 구성 파일이 있습니다. PVK RootCATest.cer는

  2. 2) 신뢰할 수있는 루트 인증 기관

  3. 3) makecert -sk CertTest -iv RootCATest.pvk -n "CN = 가짜"-ic RootCATest.cer에 추가 enter image description here

    내가 https://localhost/WarcraftServiceSite/WarService.svc는 svcutil 실행하면 나는이 예외가 내 -sky 교환 -ss -SR localmachine은 -pe IIS에서

은 내가 HTTPS과 내가이 문제를 가지고있는 서버 인증서 바인딩 추가 : "There was an error downloading https://localhost/WarcraftServiceSite/WarService.svc. The underlying connection was closed.Could not establish trust relationship for the SSL/TLS secure channel. The remote certificate is invalid according to the validation procedure."

나중에 편집 :는 svcutil를 호출하는 올바른 방법은 http 것 같다 https 아님 내가 가진 경우에도이 <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />

답변

2

때문에 테스트 인증서 일 뿐이므로 클라이언트에 다음을 추가하여 작동시킬 수 있습니다. Verisign 등에서 프로덕션 인증서를 받으면 필요하지 않습니다. 다음에 대한 참조 및 추가 - System.Net, System.Net.Security, System.Security.Cryptography.X509Certificates;

사용 ServicePointManager 클래스와 프록시를 사용하기 전에 어딘가 와이어

private static bool RemoteCertificateValidate(
    object sender, X509Certificate cert, 
    X509Chain chain, SslPolicyErrors error) 
{ 
    // trust any certificate 
    return true; 
} 

IMPL 그런 다음 ServerCertificateValidationCallback

ServicePointManager.ServerCertificateValidationCallback 
       += RemoteCertificateValidate; 

핸들러에 핸들러를 핸들러를 추가합니다. makecert의이 코드와 certs는 테스트 용으로 만 사용해야합니다.

관련 문제