2016-04-07 39 views
0

openssl kullanarak özel Sertifika Yetkilisi (CA) oluşturdum. Sonra bir öncekini kullanarak ve IIS'den gelen isteği kullanarak sertifikalı oluşturdum. Yani şimdi sertifika zincirim var. Sonra ikincisini WCF servisime bağladım ve her şey iyi. Daha sonra istemcide, özel sertifikamı tanıması için CA sertifikamı Güvenilir Kök Sertifika Yetkilisi'ne kurdum. WCF servisim şu anda basit http bağlantısında çalışıyor. Sunucu tarafı:WCF servisi ve özel CA

<system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior name="SyncWcfServices.MainServiceBehavior"> 
       <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /> 
       <serviceDebug includeExceptionDetailInFaults="true" /> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <bindings> 
     <wsHttpBinding> 
      <binding name="ExtendedMaxSize" maxReceivedMessageSize="2147483647"> 
       <security mode="None"> 
        <transport clientCredentialType="None"></transport> 
       </security> 
      </binding> 
     </wsHttpBinding> 
    </bindings> 
    <services> 
     <service name="SyncWcfServices.MainService" behaviorConfiguration="SyncWcfServices.MainServiceBehavior"> 
      <endpoint address="/syncService.svc" binding="wsHttpBinding" bindingConfiguration="ExtendedMaxSize" contract="SyncWcfServices.IMainService"></endpoint> 
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint> 
     </service> 
    </services> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 
</system.serviceModel> 

İstemci tarafı:

<system.serviceModel> 
    <bindings> 
     <wsHttpBinding> 
      <binding name="WSHttpBinding_IMainService" maxReceivedMessageSize="2147483647" sendTimeout="00:10:00"> 
       <security mode="None" /> 
      </binding> 
     </wsHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost/SyncService/SyncService.svc" 
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMainService" 
contract="SyncServiceReference.IMainService" name="WSHttpBinding_IMainService" /> 
    </client> 
</system.serviceModel> 

Yani, SSL bağlantısı desteklemek için bu ayarları değiştirmeniz gerekir. Nasıl yapılacağı konusunda pek çok yazı okudum, ancak her zaman sunucunun istemci sertifikasını kontrol etmesi ve istemci tarafından sunucu sertifikasını kontrol etmesi gerektiği anlamına gelen 2 yollu sertifikasyon denetimi kullanılıyor. Ancak istemcinin yalnızca kurduğum CA'yı kullanarak sunucu sertifikasını kontrol etmesini istiyorum. Ve sunucu, daha önce olduğu gibi sıradan kimlik bilgileri (kullanıcı adı, şifre) ile kontrol edecektir. Güvenlik modunu her iki tarafta Aktarım'a ve mexHttpsBinding için sunucu mex uç noktasını değiştirmem gerektiğini düşünüyorum, ama sonra ne yapmalıyım? Lütfen çözüme yardımcı olun. Hepinize teşekkürler!

cevap

0

Son olarak doğru yolu buldum! Yani sunucu tarafı:

<system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior name="SyncWcfServices.MainServiceBehavior"> 
       <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /> 
       <serviceDebug includeExceptionDetailInFaults="true" /> 
       <serviceCredentials> 
       <serviceCertificate 
        findValue = "*.mydomain.com" 
        storeLocation = "LocalMachine" 
        storeName = "My" 
        x509FindType = "FindBySubjectName" 
        /> 
       </serviceCredentials> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <bindings> 
     <wsHttpBinding> 
      <binding name="ExtendedMaxSize" maxReceivedMessageSize="2147483647"> 
       <security mode="Transport"> 
        <transport clientCredentialType="None"></transport> 
       </security> 
      </binding> 
     </wsHttpBinding> 
    </bindings> 
    <services> 
     <service name="SyncWcfServices.MainService" behaviorConfiguration="SyncWcfServices.MainServiceBehavior"> 
      <endpoint address="" binding="wsHttpBinding" bindingConfiguration="ExtendedMaxSize" contract="SyncWcfServices.IMainService"></endpoint> 
      <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"></endpoint> 
      <host> 
       <baseAddresses> 
        <add baseAddress="http://localhost:8095/Design_Time_Addresses/SyncWcfServices/MainService/" /> 
       </baseAddresses> 
      </host> 
     </service> 
    </services> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 
</system.serviceModel> 

İstemci Tarafı:

<system.serviceModel> 
    <behaviors> 
     <endpointBehaviors> 
      <behavior name = "ServiceCertificate"> 
       <clientCredentials> 
        <serviceCertificate> 
         <authentication certificateValidationMode = "ChainTrust"/> 
        </serviceCertificate> 
       </clientCredentials> 
      </behavior> 
     </endpointBehaviors> 
    </behaviors> 
    <bindings> 
     <wsHttpBinding> 
      <binding name="ExtendedMaxSize" maxReceivedMessageSize="2147483647"> 
       <security mode="Transport"> 
        <transport clientCredentialType="None"></transport> 
       </security> 
      </binding> 
     </wsHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="https://localhost/SyncService/SyncService.svc" 
     binding="wsHttpBinding" bindingConfiguration="ExtendedMaxSize" 
     behaviorConfiguration = "ServiceCertificate" 
     contract="SyncServiceReference.IMainService" name="WSHttpBinding_IMainService"> 
     </endpoint>    
    </client> 
</system.serviceModel> 

Birini yardımcı olacaktır Umut! Ayrıca lütfen "WCF Hizmetlerini Programlama" (4. baskı) kitabına bakınız: Juval Lowy & Michael Montgomery. Bu harika bir kitap!

İlgili konular