TransportSecurityBindingElement セキュリティ要素を使用する WCF カスタム バインディングがありますが、クライアントと (サード パーティの) サーバーの両方で時間の精度に関する問題が継続的に発生しています。
タイムスタンプを分単位で正確にするために秒を削除するにはどうすればよいですか (サーバーはこれを受け入れると言われています)。
私が持っていた代替案は、すべてのリクエストの前にシステム時間を更新することですが、これはサーバー時間が正確であると(誤って)想定しています。また、タイムスタンプを完全に削除しようとしましたが (必須ではない可能性があります) System.InvalidOperationException
、Signing without primary signature requires timestamp.
セキュリティ要素を構築する .Net コード:
Dim msgSecVer As System.ServiceModel.MessageSecurityVersion = ServiceModel.MessageSecurityVersion.WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10
Dim tsbe As TransportSecurityBindingElement = SecurityBindingElement.CreateCertificateOverTransportBindingElement(msgSecVer)
tsbe.EnableUnsecuredResponse = True
tsbe.SetKeyDerivation(False)
tsbe.AllowInsecureTransport = True
tsbe.IncludeTimestamp = True
'adding clock skew doesn't seem to make any difference?
Dim clockSkew As TimeSpan = TimeSpan.FromMinutes(1)
tsbe.LocalClientSettings.MaxClockSkew = clockSkew
tsbe.LocalServiceSettings.MaxClockSkew = clockSkew
Return tsbe
メッセージ ヘッダー、タイムスタンプの精度 (過剰な可能性あり) に注意:
POST http://wwwqa.xxxx.com/services/
Content-Type: text/xml; charset=utf-8
VsDebuggerCausalityData: xxxx
SOAPAction: ""
Host: wwwqa.xxxx.com
Content-Length: 2400
Expect: 100-continue
Connection: Keep-Alive
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<u:Timestamp u:Id="_0">
<u:Created>2013-12-04T10:53:13.568Z</u:Created>
<u:Expires>2013-12-04T10:58:13.568Z</u:Expires>
</u:Timestamp>
<o:BinarySecurityToken u:Id="uuid-bc441202-xxxx-xxxx-a176-02f2a61a6002-1" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3">....xxxx....</o:BinarySecurityToken>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<Reference URI="#_0">
<Transforms>
<Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<DigestValue>xxxx</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>xxxx</SignatureValue>
<KeyInfo>
<o:SecurityTokenReference><o:Reference URI="#uuid-bc441202-xxxx-xxxx-a176-02f2a61a6002-1"/></o:SecurityTokenReference>
</KeyInfo>
</Signature>
</o:Security>
</s:Header>