代码之家  ›  专栏  ›  技术社区  ›  martijn_himself

使用消息安全时的WS-Security开销

  •  2
  • martijn_himself  · 技术社区  · 15 年前

    以下是记录在Microsoft服务跟踪查看器中的消息。我相信它表示对一个无参数方法的单个调用,该方法在WCF服务上有一个整数返回值(使用wshttpbinding)。我正在使用消息级安全性(使用用户名凭据),并创建了一个开发服务器证书以使其正常工作。我被头顶的高度所迷惑。以前有人见过这个吗?我甚至不确定我是否在看正确的东西。我计划在每个调用上都使用这个方法,我希望在同一个服务上的后续方法调用上减少开销,但似乎不是这样。

    我想创造一个 Login() 方法通过ssl验证用户并返回一个guid,该guid将通过每个guid的过期策略等对后续请求进行身份验证。直观地说,我认为这可能是一个坏主意,但我是一个安全假人,因此我不确定。

    如有任何建议,我们将不胜感激。

    <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
    <s:Header>
    <a:Action s:mustUnderstand="1" u:Id="_2" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:a="http://www.w3.org/2005/08/addressing">http://tempuri.org/IWsAppointmentService/GetTest</a:Action>
    <a:MessageID u:Id="_3" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:a="http://www.w3.org/2005/08/addressing">urn:uuid:d83df40a-979b-440c-9292-7a5a84a64ecd</a:MessageID>
    <a:ReplyTo u:Id="_4" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:a="http://www.w3.org/2005/08/addressing">
    <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
    </a:ReplyTo>
    <a:To s:mustUnderstand="1" u:Id="_5" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:a="http://www.w3.org/2005/08/addressing">http://localhost:8731/service/ws</a:To>
    <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="uuid-169b0950-217e-48af-9057-ea832e0c7e19-14" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <u:Created>2009-09-08T14:08:36.224Z</u:Created>
    <u:Expires>2009-09-08T14:13:36.224Z</u:Expires>
    </u:Timestamp>
    <c:SecurityContextToken u:Id="uuid-95cdaf11-3974-4cc0-93a8-a3d2191bbef4-5" xmlns:c="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <c:Identifier>urn:uuid:3b6a325b-a4e1-478a-92a7-108dd3f94adb</c:Identifier>
    </c:SecurityContextToken>
    <c:DerivedKeyToken u:Id="uuid-169b0950-217e-48af-9057-ea832e0c7e19-9" xmlns:c="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <o:SecurityTokenReference>
    <o:Reference ValueType="http://schemas.xmlsoap.org/ws/2005/02/sc/sct" URI="#uuid-95cdaf11-3974-4cc0-93a8-a3d2191bbef4-5"></o:Reference>
    </o:SecurityTokenReference>
    <c:Offset>0</c:Offset>
    <c:Length>24</c:Length>
    <c:Nonce>
    <!-- Removed-->
    </c:Nonce>
    </c:DerivedKeyToken>
    <c:DerivedKeyToken u:Id="uuid-169b0950-217e-48af-9057-ea832e0c7e19-10" xmlns:c="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <o:SecurityTokenReference>
    <o:Reference ValueType="http://schemas.xmlsoap.org/ws/2005/02/sc/sct" URI="#uuid-95cdaf11-3974-4cc0-93a8-a3d2191bbef4-5"></o:Reference>
    </o:SecurityTokenReference>
    <c:Nonce>
    <!-- Removed-->
    </c:Nonce>
    </c:DerivedKeyToken>
    <e:ReferenceList xmlns:e="http://www.w3.org/2001/04/xmlenc#">
    <e:DataReference URI="#_1"></e:DataReference>
    <e:DataReference URI="#_6"></e:DataReference>
    </e:ReferenceList>
    <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
    <SignedInfo>
    <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></CanonicalizationMethod>
    <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#hmac-sha1"></SignatureMethod>
    <Reference URI="#_0">
    <Transforms>
    <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></Transform>
    </Transforms>
    <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></DigestMethod>
    <DigestValue>NnVRkY+ZVgWd4qfBs3jtjxAf9m4=</DigestValue>
    </Reference>
    <Reference URI="#_2">
    <Transforms>
    <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></Transform>
    </Transforms>
    <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></DigestMethod>
    <DigestValue>+DXYZ0w5aRfe1m+owuJXfYnT4TU=</DigestValue>
    </Reference>
    <Reference URI="#_3">
    <Transforms>
    <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></Transform>
    </Transforms>
    <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></DigestMethod>
    <DigestValue>OCiMrL9/sZLY3qMANeBgpmmPTHQ=</DigestValue>
    </Reference>
    <Reference URI="#_4">
    <Transforms>
    <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></Transform>
    </Transforms>
    <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></DigestMethod>
    <DigestValue>l6mMmQ2LE9VFtjaA6Qc4GKBXURw=</DigestValue>
    </Reference>
    <Reference URI="#_5">
    <Transforms>
    <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></Transform>
    </Transforms>
    <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></DigestMethod>
    <DigestValue>gwaCnZv9JZtGrNhF6q8l2qIptMU=</DigestValue>
    </Reference>
    <Reference URI="#uuid-169b0950-217e-48af-9057-ea832e0c7e19-14">
    <Transforms>
    <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></Transform>
    </Transforms>
    <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></DigestMethod>
    <DigestValue>i6m9Hb2aKQPRshhSqEpESJJASQg=</DigestValue>
    </Reference>
    </SignedInfo>
    <SignatureValue>lo3sUvYlRiCCfag3kesKx9LFpHU=</SignatureValue>
    <KeyInfo>
    <o:SecurityTokenReference xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
    <o:Reference ValueType="http://schemas.xmlsoap.org/ws/2005/02/sc/dk" URI="#uuid-169b0950-217e-48af-9057-ea832e0c7e19-9"></o:Reference>
    </o:SecurityTokenReference>
    </KeyInfo>
    </Signature>
    </o:Security>
    </s:Header>
    <s:Body u:Id="_0" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <GetTest xmlns="http://tempuri.org/"></GetTest>
    </s:Body>
    </s:Envelope>
    
    1 回复  |  直到 15 年前
        1
  •  4
  •   marc_s HarisH Sharma    15 年前

    没有人声称使用wshttpbinding是个好主意!;-)

    wshttpbinding实现了一系列的WS-*标准,它们并不便宜!

    通常,如果你在公司防火墙后面,我建议你使用nettcp。大多数情况下,当您处理面向互联网的公共服务时,您最好使用basichttpbinding或webhttpbinding(rest)。

    您可以调整wshttpbinding,当然-关闭会话,关闭安全功能等。

    但最后,你真的要问自己:创建这样一个登录方案,管理这些“会话guid”的生命周期,以及所有可能出错的方法(guid即将过期,guid被欺骗等)是否值得?是的,当然-邮件的大小只有几KB-但是它有吗? 真的? 物质?真的吗?

    不要在错误的地方进行优化-随着今天的技术的到位,许多这些“直觉优化”真的不值得麻烦,开发工作“优化”离开这些在每个调用上的几个知识库可能会大大高于任何性能惩罚从传输几个知识库来回。

    想想看!

    马克