Tag: ws security

从WCF创建的ws-security标头中删除timestamp元素

我正在使用来自WCF的旧Java Web服务,该服务需要以下forms的请求: username password … 使用以下配置hack“工作”但我不希望在config中公开用户名和密码: … username password 我想要使​​用的是以下内容: 但是这会在安全元素中生成timestamp元素,java webservice将其置于其中。 我需要做的是从它生成的XML中删除时间戳,或者为我做一些自定义绑定。 我尝试创建自定义凭据,但这只更改了usernameToken元素。 我已经看过许多很多SO问题(许多来自2007年及之前的问题),其中包括以下内容并没有任何乐趣: 从安全性中删除Timestamp元素 如何使WCF客户端符合特定的WS-Security 删除timestamp元素的最佳,最简单和最优雅的方法是什么。 提前致谢

在C#中以编程方式创建WCF客户端的标头(wsse)部分

如何以编程方式在app #config中创建app.config服务设置的以下部分: someusername somepassword 我设法从c#生成绑定部分(上面没有包含)和端点部分。 我无法创建标题部分。 出现的错误是:(这是因为当我从c#生成所有内容时,我没有标题部分) 此服务需要 ,缺少该服务。 header部分很重要,好像我从配置中排除它并使用config运行代码它也会产生上述错误。 我不想使用web.config / app.config。 我必须从C#运行所有东西。 (上面的app.config工作正常,但我想通过c#做同样的事情) 注意:以下更新是基于以下提供的解决方案请通过以下解决方案的评论,以获得更好的理解 更新1 :(首先以编程方式使用BasicHttpBinding) BasicHttpBinding binding = new BasicHttpBinding(); binding.Name = “Contact”; binding.CloseTimeout = TimeSpan.FromMinutes(1); binding.OpenTimeout = TimeSpan.FromMinutes(1); binding.ReceiveTimeout = TimeSpan.FromMinutes(10); binding.SendTimeout = TimeSpan.FromMinutes(1); binding.AllowCookies = false; binding.BypassProxyOnLocal = false; binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; binding.MaxBufferSize = 524288; binding.MaxBufferPoolSize = 524288; binding.MaxReceivedMessageSize = […]

使用C#,WCF SOAP使用者使用WSSE纯文本身份validation?

我有一个WCF SOAP使用者,它由Visual Studio 2012从WSDL实现。 WSDL由PeopleTools生成。 基础对象的类型为System.ServiceModel.ClientBase 。 我需要SOAP请求类似于: [plain text username goes here] [plain text password goes here] Aren Cambre 这是我们最接近的: http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue urn:uuid:3cc3f2ca-c647-466c-b38b-f2423462c837 http://www.w3.org/2005/08/addressing/anonymous http://[internal URL to soap listener] http://schemas.xmlsoap.org/ws/2005/02/sc/sct http://schemas.xmlsoap.org/ws/2005/02/trust/Issue 256 FgMBAFoBAABWAwFQ9IhUFGUO6tCH+0baQ0n/3us//MMXzQA78Udm4xFj5gAAGAAvADUABQAKwBPAFMAJwAoAMgA4ABMABAEAABX/AQABAAAKAAYABAAXABgACwACAQA= 你会发现两个问题: 没有纯文本WSSE凭据。 传递服务不使用的二进制forms的凭据。 身份validation在Body ,而不是Header 。 该请求省略了InputParameters 。 这是必不可少的C#代码: var service = new ServiceWithBizarreNameFromPeoplesoft(); if (service.ClientCredentials == null) throw new NullReferenceException(); service.ClientCredentials.UserName.UserName […]

如何使WCF客户端符合特定的WS-Security – 签署UsernameToken和SecurityTokenReference

我需要创建一个wcf客户端来调用我无法控制的服务。 我得到了一个wsdl和一个有效的soapui项目。 该服务使用用户名/密码和x509证书。 UPDATE 我现在明白问题是什么,但我仍然不确定我需要采取哪些步骤才能创建所需的消息,所以任何帮助都将非常感激。 我需要同时签署UsernameToken和SecurityTokenReference。 由于不再使用,我必须从此post中删除我必须创建自定义绑定的代码。 我不再向绑定添加SecurityBindingElement,而是添加一个将安全元素写入标头的新行为。 因此,通过inheritanceSignedXml类,添加签名引用然后调用ComputeSignature以在Security头中创建Signature节点,从头开始创建安全节点。 您需要传递xml以登录SignedXml构造函数才能使其生效。 传递UsernameToken是没问题的,这似乎是正确签名的。 问题是SecurityTokenReference仅在调用ComputeSignature()时创建,因此我无法向此元素添加签名引用,因为它在需要时不存在(在SignedXml的重写的GetIdElement方法中)在ComputeSignature()之前调用的) 我用来创建要插入Security头的签名块的代码如下 string certificatePath = System.Windows.Forms.Application.StartupPath + “\\” + “Certs\\sign-and- enc.p12”; XmlDocument xd = new XmlDocument(); xd.LoadXml(xml); // Set Certificate System.Security.Cryptography.X509Certificates.X509Certificate2 cert = new X509Certificate2(certificatePath, “password”); MySignedXml signedXml = new MySignedXml(xd); signedXml.SigningKey = cert.PrivateKey; // Create a new KeyInfo object. KeyInfo keyInfo = new […]

使用Visual Studios 2010在.NET 4.0中进行ONVIF身份validation

我的任务是尝试与建筑物中的ONVIF摄像机建立通信,最终升级公司的domotic解决方案,以自动识别ONVIF摄像机,并能够设置它们并使用它们的服务。 我已经能够以这种方式收集一些基本信息,如模型,MAC地址和固件版本: EndpointAddress endPointAddress = new EndpointAddress(“<mycameraurl:/onvif/device_service”); CustomBinding bind = new CustomBinding(“DeviceBinding”); DeviceClient temp = new DeviceClient(bind, endPointAddress); String[] arrayString = new String[4]; String res = temp.GetDeviceInformation(out arrayString[0], out arrayString[1], out arrayString[2], out arrayString[3]); MessageBox.Show(“Model ” + arrayString[0] + “, FirmwareVersion ” + arrayString[1] + “, SerialNumber ” + arrayString[2] + “, HardwareId ” + […]

WCF是否支持SOAP 1.1的WS-Security?

我需要调用一些需要WS-Security的第三Web服务。 我使用以下配置创建了一个WCF端点: 问题是第三方服务器抛出以下exception: 收到协议’_http://schemas.xmlsoap.org/wsdl/soap12/’,必需的协议’_http://schemas.xmlsoap.org/wsdl/soap/’。 据我所知,使用wsHttpBinding将导致WCF发送SOAP 1.2请求,而使用basicHttpBinding将导致SOAP 1.1请求。 由于WS-Security部分是必需的,据我所知,我必须使用wsHttpBinding。 我的问题是如何强制SOAP 1.1请求? 我有什么选择?

使用WS-Security UsernameToken PasswordDigest身份validation方案的WCF客户端使用Axis 2 Web服务时出错

我有一个WCF客户端连接到基于Java的Axis2 Web服务(在我的控制之外)。 它即将应用WS-Security,我需要修复.NET客户端。 但是,我正在努力提供正确的身份validation。 我知道WSE 3.0可能会让它变得更容易,但我宁愿不再使用过时的技术。 类似的问题(未解决),包括这个 , 这个和这个 。 SOAP消息应如下所示: 2010-05-28T12:50:33.675+01:00 但是,我的看起来像这样: 2010-06-23T10:31:23.441Z 2010-06-23T10:36:23.441Z 我的客户端看起来像这样:PS注意所需的 SecurityHeaderType参数。 那是什么? public MyAck SendRequest(MyRequest request) { RemoteServicePortTypeClient client = new RemoteServicePortTypeClient(); client.ClientCredentials.UserName.UserName = “JAY”; client.ClientCredentials.UserName.Password = “AND”; // what is the difference between the two different Credential types?? //client.ClientCredentials.HttpDigest.ClientCredential.UserName = “SILENT”; //client.ClientCredentials.HttpDigest.ClientCredential.Password = “BOB”; SecurityHeaderType sht = new […]