9

署名されたタイムスタンプを使用してsoapメッセージを送信するサードパーティにサービスを提供する必要があります。

これをサポートするようにサービスを構成するにはどうすればよいですか?

更新 私は私たちが求めているSoapメッセージの形式に近づくことができましたが、WCFはユーザー名とタイムスタンプトークンの両方に署名することを主張しています。タイムスタンプのみに署名するようにバインディングを変更する方法はありますか?


さらなる更新 ここに私たちの要件があります:

  • タイムスタンプ要素は署名する必要があります。
  • 署名に使用される証明書のCN名は、UsernameToken要素で指定されたユーザー名と一致する必要があります。
  • 署名に使用される証明書は、BinarySecurityToken要素で送信する必要があります。
  • KeyInfo要素には、BinarySecurityTokenを参照するために使用する必要があるSecurityTokenReference要素のみが含まれている必要があります。
  • 正規化アルゴリズムを指定する必要があります。
  • SignatureMethodを指定する必要があり、SHA-1またはSHA-2アルゴリズムである必要があります。
  • 分離された署名を使用する必要があります。

助言がありますか?

現在の構成

クライアントバインディング

<bindings>
  <wsHttpBinding>
    <binding name="WSBC">
      <security mode="TransportWithMessageCredential">
        <transport clientCredentialType="Certificate" proxyCredentialType="None"></transport>
        <message clientCredentialType="UserName" negotiateServiceCredential="false" establishSecurityContext="false" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>

クライアントエンドポイント

<client>
  <endpoint address="https://localhost/WcfTestService/Service2.svc"
  behaviorConfiguration="CCB" binding="wsHttpBinding"
  bindingConfiguration="WSBC"
  contract="ServiceReference2.IService2"
  name="wsHttpBinding_IService2" />
</client>

クライアントの行動

<behaviors>
  <endpointBehaviors>
    <behavior name="MBB">
      <clientCredentials>
        <clientCertificate  findValue="03 58 d3 bf 4b e7 67 2e 57 05 47 dc e6 3b 52 7f f8 66 d5 2a"
                            storeLocation="LocalMachine"
                            storeName="My"
                            x509FindType="FindByThumbprint" />
        <serviceCertificate>
          <defaultCertificate findValue="03 58 d3 bf 4b e7 67 2e 57 05 47 dc e6 3b 52 7f f8 66 d5 2a"
                              storeLocation="LocalMachine"
                              storeName="My"
                              x509FindType="FindByThumbprint"  />
        </serviceCertificate>
      </clientCredentials>
    </behavior>
  </endpointBehaviors>
</behaviors>

サービスバインディング

<bindings>
  <wsHttpBinding>
    <binding name="ICB">
      <security mode="TransportWithMessageCredential">
        <transport clientCredentialType="Certificate" proxyCredentialType="None"></transport>
        <message    clientCredentialType="UserName" 
                    negotiateServiceCredential="false"
                    establishSecurityContext="false" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>

Sericeエンドポイント

<service name="WcfTestService.Service2" behaviorConfiguration="SCB">
    <endpoint     address="" binding="wsHttpBinding" contract="WcfTestService.IService2"
    bindingConfiguration="ICB" name="MS" />
</service>

サービスの動作

<behaviors>
  <serviceBehaviors>
    <behavior name="SCB">
      <serviceCredentials>
        <serviceCertificate     findValue="4d a9 d8 f2 fb 4e 74 bd a7 36 d7 20 a8 51 e2 e6 ea 7d 30 08"
                                storeLocation="LocalMachine"
                                storeName="TrustedPeople"   
                                x509FindType="FindByThumbprint" />
        <userNameAuthentication 
            userNamePasswordValidationMode="Custom" 
            customUserNamePasswordValidatorType="WcfTestService.UsernameValidator, WcfTestService" />
        <clientCertificate>
          <authentication certificateValidationMode="None" revocationMode="NoCheck" />
        </clientCertificate>
      </serviceCredentials>
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>
4

4 に答える 4

3

WCF のデフォルトではなく、必要な方法でセキュリティを実装するカスタム セキュリティ バインディング クラスを検討することをお勧めします。

これらの MSDN リンクでは、カスタム バインディングと SecurityBindingElement 抽象基本クラスについて説明しています。

http://msdn.microsoft.com/en-us/library/ms730305.aspx

http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.securitybindingelement.aspx

于 2011-02-23T16:16:30.980 に答える
1

WCF では、タイムスタンプへの署名はネイティブに許可されていませんが、ユーザー名への署名は許可されていません。まず、これはあなたが直面している問題とは関係がないと確信しています。サーバーは両方のケースを処理できるはずです。必要な場合は、セキュリティでユーザー名をまったく使用しないことをお勧めします (たとえば、"anonymousForCertificate" のセキュリティ モード)。カスタム メッセージ エンコーダーを実装して、ユーザー名/パスワード タグを適切な場所のヘッダーに手動でプッシュします (取るメッセージの署名部分、主にタイムスタンプを変更しないように注意してください)。

于 2013-08-14T15:11:25.843 に答える
0

メッセージ コントラクトを使用してこれを行うことができます

上記のリンクの例を次に示します。

[MessageContract]
public class PatientRecord 
{
   [MessageHeader(ProtectionLevel=None)] public int recordID;
   [MessageHeader(ProtectionLevel=Sign)] public string patientName;
   [MessageHeader(ProtectionLevel=EncryptAndSign)] public string SSN;
   [MessageBodyMember(ProtectionLevel=None)] public string comments;
   [MessageBodyMember(ProtectionLevel=Sign)] public string diagnosis;
   [MessageBodyMember(ProtectionLevel=EncryptAndSign)] public string medicalHistory;
}

保護レベル None、Sign、EncryptAndSign に注意してください

于 2011-02-24T15:01:35.030 に答える