WCF X.509検証
8132 ワード
1.証明書の作成
注意:証明書の作成後、対応する証明書の読み取り権限も構成します.
WCFはX.509証明書を使用し、サービス側とクライアントは相応の修正をしなければならない.
2.サービス側の修正
behaviorノード:
bindingノード
サービスノード
3.クライアントの変更
Client-endpointノード
bindingsノード
behaviorノード
behaviorノード、wsHttpBindings、basicHttpBindingsのバインド内容は異なります.BasicHttpBindings複数defaultCertificateの構成
basicHttpBindings
wsHttpBindings
参照先:
WCF開発フレームワーク形成の旅--X 509証明書の暗号化を実現する方法
Invoke WCFサービスfrom Java Client with Authentication(X.509 Certificate)JavaクライアントがWCFサービスを呼び出すにはセキュリティ検証が必要です
makecert.exe -sr LocalMachine -ss My -a sha1 -n CN=ParkingServer -sky exchange -pe
makecert.exe -sr LocalMachine -ss My -a sha1 -n CN=ParkingClient -sky exchange -pe
注意:証明書の作成後、対応する証明書の読み取り権限も構成します.
WCFはX.509証明書を使用し、サービス側とクライアントは相応の修正をしなければならない.
2.サービス側の修正
behaviorノード:
<behavior name="CustomBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="None" />
</clientCertificate>
<serviceCertificate findValue="ParkingServer" storeLocation="LocalMachine"
storeName="My" x509FindType="FindBySubjectName" />
</serviceCredentials>
</behavior>
bindingノード
<wsHttpBinding>
<binding name="CustomWsHttpBinding">
<security mode="Message">
<message clientCredentialType="Certificate"/>
</security>
</binding>
</wsHttpBinding>
サービスノード
<service name="WcfService1.Service1" behaviorConfiguration="CustomBehavior">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="CustomWsHttpBinding"
contract="WcfService1.IService1">
<identity>
<dns value="ParkingServer" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
3.クライアントの変更
Client-endpointノード
<endpoint address="http://localhost:60909/Service2.svc" binding="basicHttpBinding" behaviorConfiguration="CustomBehavior2"
bindingConfiguration="BasicHttpBinding_IService2" contract="ServiceReference2.IService2"
name="BasicHttpBinding_IService2">
<identity>
<dns value="ParkingServer" />
</identity>
</endpoint>
bindingsノード
<basicHttpBinding>
<binding name="BasicHttpBinding_IService2">
<security mode="Message">
<message clientCredentialType="Certificate" />
</security>
</binding>
</basicHttpBinding>
behaviorノード
behaviorノード、wsHttpBindings、basicHttpBindingsのバインド内容は異なります.BasicHttpBindings複数defaultCertificateの構成
basicHttpBindings
<behavior name="CustomBehavior2">
<clientCredentials>
<clientCertificate findValue="zoesoft"
x509FindType="FindBySubjectName"
storeLocation="LocalMachine"
storeName="My"/>
<serviceCertificate>
<authentication certificateValidationMode="None"/>
<defaultCertificate findValue="ParkingServer" storeName="My" storeLocation="LocalMachine" x509FindType="FindBySubjectName"/>
</serviceCertificate>
</clientCredentials>
</behavior>
wsHttpBindings
<behavior name="CustomBehavior">
<clientCredentials>
<clientCertificate findValue="zoesoft"
x509FindType="FindBySubjectName"
storeLocation="LocalMachine"
storeName="My"/>
<serviceCertificate>
<authentication certificateValidationMode="None"/>
</serviceCertificate>
</clientCredentials>
</behavior>
参照先:
WCF開発フレームワーク形成の旅--X 509証明書の暗号化を実現する方法
Invoke WCFサービスfrom Java Client with Authentication(X.509 Certificate)JavaクライアントがWCFサービスを呼び出すにはセキュリティ検証が必要です