标签: ws-security

使用 UserNameOverTransport 绑定时,如何让 WCF 以摘要模式发送密码?(将 WSE3.0 代码转换为 WCF)

我正在尝试将此 WSE3.0 代码转换为 WCF:

// we use Microsoft WSE 3.0 to insert the username token in the soap header.
// This strategy takes care of creating and inserting the Nonce and Created elements 
// for us, as well as creating a password digest based on Nonce, Created, and 
// the password itself.  Refer to the WS-Secutiry UsernameToken Profile 1.1
// specification at http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=wss.

Microsoft.Web.Services3.Security.Tokens.UsernameToken nametoken;
nametoken = new Microsoft.Web.Services3.Security.Tokens.UsernameToken(username, password, Microsoft.Web.Services3.Security.Tokens.PasswordOption.SendHashed);
Microsoft.Web.Services3.Design.Policy ClientPolicy = new Microsoft.Web.Services3.Design.Policy();

ClientPolicy.Assertions.Add(new UsernameOverTransportAssertion());
this._proxy.SetPolicy(ClientPolicy);
this._proxy.SetClientCredential<UsernameToken>(nametoken); …
Run Code Online (Sandbox Code Playgroud)

c# wcf ws-security wse

4
推荐指数
1
解决办法
4974
查看次数

通过SSL使用纯文本用户名凭据为第三方SOAP 1.1服务配置WCF客户端

我正在尝试连接到需要SSL安全性和用户名/密码凭据的第三方SOAP 1.1服务.预期的一个例子是:

<soapenv:Header>
    <wsse:Security>
        <wsse:UsernameToken>
            <wsse:Username>username</wsse:Username>
            <wsse:Password>password</wsse:Password>
        </wsse:UsernameToken>
    </wsse:Security>
</soapenv:Header>
Run Code Online (Sandbox Code Playgroud)

我的客户端配置如下:

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="thirdpartyservicebindingconfig">
                <security mode="TransportWithMessageCredential">
                    <message clientCredentialType="UserName"
                             algorithmSuite="Default" />
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="https://..." 
                  binding="basicHttpBinding"
                  bindingConfiguration="thirdpartyservicebindingconfig"
                  contract="thirdpartyservicecontract" 
                  name="thirdpartyserviceendpoint" />
    </client>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)

服务客户端代码是:

var client = new thirdpartyservicecontractclient();

client.ClientCredentials.UserName.UserName = "username";
client.ClientCredentials.UserName.Password = "password";

var result = client.DoSomething();
Run Code Online (Sandbox Code Playgroud)

我收到以下错误异常消息:

安全处理器无法在消息中找到安全标头.这可能是因为消息是不安全的故障,或者因为通信方之间存在绑定不匹配.如果为安全性配置服务并且客户端未使用安全性,则会发生这种情况.

编辑:
如果我将安全模式重新配置为"传输":
<security mode="TransportWithMessageCredential">
我从第三方服务收到错误:

com.sun.xml.wss.XWSSecurityException:消息不符合已配置的策略[AuthenticationTokenPolicy(S)]:未找到安全标头; 嵌套异常是com.sun.xml.wss.XWSSecurityException:com.sun.xml.wss.XWSSecurityException:消息不符合已配置的策略[AuthenticationTokenPolicy(S)]:找不到安全标头.

如何配置我的客户端以连接到此服务?

  • WS Security使用SSL上的纯文本密码

wcf ws-security soap basichttpbinding wcf-security

4
推荐指数
1
解决办法
4459
查看次数

如何从WSDL和SOAP消息中识别NAMESPACE,METHOD_NAME,URL和SOAP_ACTION

我在解析SOAP Web服务时遇到了一些问题.如何从WSDL中识别NAMESPACE,METHOD_NAME,URL和SOAP_ACTION以及如何使用SoapObject进行处理.

我想在android中调用soap.

下面是WSDL和SOAP REQUEST XML.

WSDL:

https://e1jas01.domain.cssus.com:8091/DV910/RI_AddressBookManager?WSDL

谢谢,Gowtham.

ws-security wsdl soap-client wsse

4
推荐指数
1
解决办法
9517
查看次数

带有用户名令牌和客户端证书的WCF SOAP调用

我正在尝试使用用户名令牌(用户名/密码)和客户端证书来调用Web服务(不确定后端是什么写入).

简短版本:如果我有一个客户端证书和用户名/密码可以使用WCF代码/配置的组合来生成下面的SOAP标头?

长版

下面是由Visual Studio 2010中的"添加服务引用"生成的服务接口(名称/ URI已更改以保护无辜者):

 [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ServiceModel.ServiceContractAttribute(Namespace="http://servicenamespacehere", ConfigurationName="Service.Contract.ConfigName.Here")]
    public interface IBackendService {

        // CODEGEN: ...
        [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://servicenamespacehere#Method1")]
        [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
        void Method1(Method1Params request);
Run Code Online (Sandbox Code Playgroud)

我需要生成的调用的SOAP安全标头如下所示:

<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>2014-08-26T20:22:50.522Z</u:Created>
            <u:Expires>2014-08-26T20:27:50.522Z</u:Expires>
         </u:Timestamp>
         <o:UsernameToken u:Id="uuid-6f243c9c-fd85-4634-8b57-cb196aee3195-60591">
            <o:Username>myUser</o:Username>
            <o:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">somePwd</o:Password>
         </o:UsernameToken>
         <o:BinarySecurityToken u:Id="uuid-6f243c9c-fd85-4634-8b57-cb196aee3195-60592" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">BASE64TOKENHERE=</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>BASE64DIGESTHERE=</DigestValue>
               </Reference>
            </SignedInfo>
            <SignatureValue>BASE64SIGNATUREHERE=</SignatureValue>
            <KeyInfo>
               <o:SecurityTokenReference>
                  <o:Reference ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" URI="#uuid-6f243c9c-fd85-4634-8b57-cb196aee3195-60592"/>
               </o:SecurityTokenReference>
            </KeyInfo>
         </Signature>
      </o:Security>
   </s:Header>
   SOAP XML PAYLOAD …
Run Code Online (Sandbox Code Playgroud)

.net c# wcf ws-security soap

4
推荐指数
1
解决办法
1499
查看次数

使用 .Net Core 3.1 签署 Soap 1.1 主体

我想从带有 C# 的 .Net Core 3.1 连接到需要我根据 WS-Security WS-Policy 2004/09签署Soap 1.1正文的 Web 服务

这是政策要求的文字描述:

AsymmetricBindingAssertion表示使用非对称加密,其中签名必须使用请求者的证书(X509v3)。该InitiatorToken字段指示请求令牌必须是 X509v3 令牌并且它必须包含在所有请求消息中,而该RecipientToken字段指示响应令牌必须是 X509v3 但不会包含在任何消息中。为了识别令牌,将使用 keyIdentifier – 由MustSupportKeyRefIdentitier字段指定 。Timestamp还需要包含在内以规避重放攻击,因此 - 默认情况下 - 这也是签名的。该OnlySignEntireHeadersAndBody字段规定只允许对整个标题或正文进行签名 - 以减轻 XML 签名包装。最后,我们只规定 SOAP Envelope 的 Bodyelement 需要签名。

我添加了一个与Microsoft WCF Web Reference Provider的连接服务在 Visual Studio 2019 中并且所有实体都添加到 Reference.cs 中。我可以在没有 WS-Policy 要求的情况下很好地连接到 SoapUI 中服务的模拟版本。我已经验证了证书和东西,我就是不知道如何在肥皂体上签名。

我无法使用,WSHttpBinding因为它生成 Soap 1.2 并且我尝试使用的服务只理解Soap 1.1

我用 尝试了不同的方法 …

wcf ws-security soap cryptography .net-core

4
推荐指数
1
解决办法
1929
查看次数

通过SSL进行SOAP纯文本密码身份验证的WCF配置

我有一个应用程序通过https连接到实现WS-Security的基于SOAP的Web服务.Web服务是用Java编写的,需要纯文本密码以及正确设置的时间戳.

经过大量的谷歌搜索和实验,我无法弄清楚如何配置我的WCF客户端与此服务进行交互.除了正确答案之外,我还要感谢指向WCF和SOAP的教程的链接.

我当前客户端的app.config如下所示:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="MyServiceSoapBinding" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                  <security mode="TransportWithMessageCredential">
                    <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                  </security>
                  <!--security mode="None">
                    <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                  </security-->
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="https://p1.my.com/tx/services/MyService"
                binding="basicHttpBinding" bindingConfiguration="MyServiceSoapBinding"
                contract="My.IMyService" name="MyServiceEndpointPort" />
        </client>
    </system.serviceModel>
</configuration>
Run Code Online (Sandbox Code Playgroud)

并且客户端代码如下所示:

string response;

try
{
    MyService.MyServiceClient svc = …
Run Code Online (Sandbox Code Playgroud)

wcf ws-security soap

3
推荐指数
1
解决办法
1万
查看次数

具有证书以及客户端和服务签名的WCF消息安全性

我们正在尝试使用x509证书在客户端和WCF服务之间实现消息安全性.客户端发送soap安全标头,服务按预期验证标头.问题是该服务没有使用我们需要的安全头来签署它的响应消息.我相信下面包含了所需的所有信息,但如果您还需要其他信息,请告诉我.谢谢!

该服务的web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.web>
    <customErrors mode="Off" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="RealIdCardService.AetnaNavigator" behaviorConfiguration="serviceCredentialBehavior">
        <endpoint address="" contract="RealIdCardService.IAetnaNav" binding="wsHttpBinding" bindingConfiguration="InteropCertificateBinding"></endpoint>
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="serviceCredentialBehavior">
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceMetadata httpsGetEnabled="true" />
          <serviceCredentials>
            <!--certificate storage path in the server-->
            <serviceCertificate findValue="WcfClient" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="TrustedPeople" />
            <issuedTokenAuthentication allowUntrustedRsaIssuers="true" />
            <!--certificate storage path in the client-->
            <clientCertificate>
              <certificate findValue="WcfServer" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="TrustedPeople" />
              <authentication certificateValidationMode="PeerTrust" revocationMode="NoCheck" />
            </clientCertificate>
          </serviceCredentials>
        </behavior>
          </serviceBehaviors>
    </behaviors>
    <bindings>
      <wsHttpBinding>
        <binding name="InteropCertificateBinding"> …
Run Code Online (Sandbox Code Playgroud)

wcf ws-security soap certificate wcf-security

3
推荐指数
1
解决办法
6222
查看次数

证书,加密和身份验证

大多数情况下,我的混淆似乎是从我在WCF环境中理解安全性的尝试中解脱出来的.在WCF中,看起来证书可用于身份验证和加密.基本上,我试图理解:

  1. 如何将X509证书用作身份验证令牌?ssl证书通常不是公开的吗?这不会使它们无法用于身份验证吗?如果没有,是否有一些通常用于此目的的协议?
  2. 使用WCF加密消息时,使用的证书是仅发送给客户端,仅发送给服务器,还是两者都发布?如果使用来自客户端和服务器的证书,我有点不清楚为什么.这主要源于我对https的理解,在这种情况下,只有颁发给服务器的证书(并且链接到根CA颁发的某些证书​​)才有必要建立加密连接并验证服务器.

我不完全确定这是正确的论坛.我的问题源于试图理解WCF,但我想我想理解这背后的理论.如果这是一个好主意,请为我建议正确的论坛.如果有必要的话,我很乐意尝试迁移这个问题.

提前致谢!

https wcf ws-security certificate wcf-security

3
推荐指数
1
解决办法
1973
查看次数

如何使WCF客户端符合特定的WS-Security

我必须使用Web服务安全X.509证书令牌配置文件1.1 OASIS标准规范,2006年2月1日,使我的WCF客户端使用Web服务(IBM DataPower)并签署/加密请求.

到目前为止,我已经创建了一个自定义绑定并"思考"我正在沿着正确的方向工作:

更新以反映最新的尝试

Private Function CreateCustomBinding() As Channels.Binding

    Dim asbe As New Channels.AsymmetricSecurityBindingElement

    asbe.MessageSecurityVersion = MessageSecurityVersion.WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10

    asbe.InitiatorTokenParameters = New ServiceModel.Security.Tokens.X509SecurityTokenParameters
    asbe.RecipientTokenParameters = New ServiceModel.Security.Tokens.X509SecurityTokenParameters

    asbe.MessageProtectionOrder = Security.MessageProtectionOrder.EncryptBeforeSign

    asbe.SecurityHeaderLayout = SecurityHeaderLayout.Strict

    asbe.IncludeTimestamp = True
    asbe.SetKeyDerivation(False)

    asbe.DefaultAlgorithmSuite = Security.SecurityAlgorithmSuite.Basic128Rsa15  'By default, AES-128 is used as the encryption algorithm.

    'Add the elements to the custom binding
    Dim myBinding As New CustomBinding

    'element order is important - see http://msdn.microsoft.com/en-us/library/ms733893(v=vs.90).aspx

    'Protocol Binding Elements (security)
    myBinding.Elements.Add(asbe)

    'Encoding Binding Element  
    myBinding.Elements.Add(New TextMessageEncodingBindingElement(MessageVersion.Soap11WSAddressing10, System.Text.Encoding.UTF8)) …
Run Code Online (Sandbox Code Playgroud)

wcf ws-security soap wcf-client x509certificate

3
推荐指数
1
解决办法
9878
查看次数

用于java swing的jnlp jar的安全问题

如何创建完全安全的证明jnlp.我创建了一个jnlp并上传到我的在线服务器上.它根本不工作,但在我的本地,它工作正常.

我的在线JNLP正在打开GUI,只有当我将java安全级别降低到中等时(我认为它根本不安全)并且它不起作用(没有任何功能正常工作)

我用Google搜索了它,但找不到任何有用的东西. 编辑 你可以验证JNLP文件...找到链接 ..这个应用程序在我的本地运行完全正常..它不工作..可能是什么原因?

java jnlp swing ws-security jar

3
推荐指数
2
解决办法
1845
查看次数