WCFサービスでクライアント証明書をチェックしたいとします。WCFサービスでのカスタム証明書の検証
私の目標は、特定の拇印の証明書を持つクライアントだけが自分のサービスと通信できるようにすることです。
私のWCFサービスはIISでホストされています。私はbasicHttpBindingとsecurity mode = "transport"を資格情報タイプ "Certificate"で使用しています。 IISでは、サービスとの通信にクライアント証明書が必要です。
ご協力いただきありがとうございます。
UPDATE: 私の設定:
<basicHttpBinding>
<binding
name="testBinding"
maxReceivedMessageSize="2147483647">
<readerQuotas
maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="Transport">
<transport clientCredentialType="Certificate"/>
</security>
</binding>
</basicHttpBinding>
行動:
<serviceBehaviors>
<behavior name="SomeServiceBehavior">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="Custom" customCertificateValidatorType="SomeService.CustomCertificateValidator,SomeService" />
</clientCertificate>
</serviceCredentials>
</behavior>
</serviceBehaviors>
サービスの設定:
<service
behaviorConfiguration="SomeServiceBehavior"
name="SomeService">
<endpoint
address=""
binding="basicHttpBinding"
bindingConfiguration="testBinding"
contract="ISomeService">
</endpoint>
</service>
とテスト目的のために、私はこの方法でバリデータを実装:
public class CustomCertificateValidator : X509CertificateValidator
{
public override void Validate(System.Security.Cryptography.X509Certificates.X509Certificate2 certificate)
{
throw new SecurityTokenValidationException("TEST Certificate was not issued by a trusted issuer TEST");
}
}
これは機能しません。私は有効な証明書で私のサービスに接続することができます。
clientCertificateにカスタムバリデータを追加しようとしましたが、動作しません。サービスがデュプレックスモードで使用するクライアント証明書を検証するように設計されているようです。受信証明書(クライアントが送信している証明書)を検証する必要があります。このシナリオでこのオプションを試しましたか? – empi
これは、クライアント側またはサービス側で動作し、着信メッセージ証明書の検証に使用されます。 – Maurice
これをに追加して、目的のサービスでクライアントを検証してください。 は、サービスを検証するためにクライアント上でのみ使用されます。 –
Maurice