WIF で実装されたカスタム STS があります。私の WS-Trust サービスは次の構成を使用しています。
<behavior name="WSTrustServiceBehaviour">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" />
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="ChainTrust"
revocationMode="NoCheck"
trustedStoreLocation="LocalMachine"/>
</clientCertificate>
<serviceCertificate storeLocation="LocalMachine"
storeName="TrustedPeople"
x509FindType="FindByThumbprint"
findValue="5BF081CCC2E20094D0648F0A3F3C6A598155D606"/>
</serviceCredentials>
</behavior>
<ws2007HttpBinding>
<binding name="WSTrustHttpBinding">
<security>
<message clientCredentialType="Certificate"
negotiateServiceCredential="false"
establishSecurityContext="false"/>
</security>
</binding>
</ws2007HttpBinding>
<service name="System.ServiceModel.Security.WSTrustServiceContract"
behaviorConfiguration="WSTrustServiceBehaviour">
<endpoint name="WSTrust13HttpEndpoint"
address="http/v13"
binding="ws2007HttpBinding"
bindingConfiguration="WSTrustHttpBinding"
contract="System.ServiceModel.Security.IWSTrust13AsyncContract"/>
<endpoint name="WSTrustFeb05HttpEndpoint"
address="http/feb05"
binding="ws2007HttpBinding"
bindingConfiguration="WSTrustHttpBinding"
contract="System.ServiceModel.Security.IWSTrustFeb2005AsyncContract" />
<endpoint name="WSTrustMexHttpEndpoint"
binding="mexHttpBinding"
bindingConfiguration=""
address="http/mex"
contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://services.example.com" />
</baseAddresses>
</host>
</service>
これで、WCF サービスを呼び出す必要がある 1 つの Web アプリケーションができました。Web アプリケーションと WCF サービスはどちらも、カスタム STS の依拠当事者です。私の Web アプリケーションの web.config には、次のものがあります。
<ws2007FederationHttpBinding>
<binding name="MyWCFServiceWS2007FederationHttpBinding"
useDefaultWebProxy="false"
messageEncoding="Mtom">
<security mode="Message">
<message>
<issuer address="http://sts.example.com/WSTrust.svc/http/feb05"
binding="ws2007HttpBinding"
bindingConfiguration="WSTrustHttpBinding"/>
<issuerMetadata address="http://sts.example.com/Bus/WSTrust.svc/http/mex"/>
</message>
</security>
</binding>
</ws2007FederationHttpBinding>
<endpointBehaviors>
<behavior name="MyWCFServiceWS2007HttpEndpointBehavior">
<clientCredentials supportInteractive="false"
useIdentityConfiguration="true">
<serviceCertificate>
<authentication certificateValidationMode="ChainTrust"
revocationMode="NoCheck"/>
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
<client>
<endpoint name="MyWCFServiceWS2007FederationHttpEndpoint"
address="http://services.example.com/MyWCFService.svc/..."
binding="ws2007FederationHttpBinding"
bindingConfiguration="MyWCFServiceWS2007FederationHttpBinding"
contract="..."
behaviorConfiguration="IdentityWS2007HttpEndpointBehavior"/>
</client>
問題は、クライアント エンドポイントを使用して My WCF サービスを呼び出そうとすると、WCF が最初に STS WS-Trust エンドポイントに接続してトークンを取得することです。
しかし、WS-Trust サービスは、クライアントが自身を認証するために証明書を提示することを期待しています。これらの資格情報を web.config で指定するにはどうすればよいですか?
私はコードで次のようなことをすると思います:
var trustChannelFactory = new WSTrustChannelFactory(..., ...);
trustChannelFactory.TrustVersion = System.ServiceModel.Security.TrustVersion.WSTrust13;
trustChannelFactory.Credentials.SupportInteractive = false;
// Set the credentials here:
trustChannelFactory.Credentials ...
何か案は?
ありがとう。