WCF sur HTTPS et signature du corps

J’ai un service SOAP auquel je veux me connecter. Il doit être accessible via https et son corps doit être signé par un certificate.

J’ai essayé le code suivant:

         

Configurez mon client comme suit:

 P4_ServiceReference.P4PortTypeClient client = new P4_ServiceReference.P4PortTypeClient(); client.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None; client.ClientCredentials.ServiceCertificate.DefaultCertificate = new X509Certificate2(@"[..].cer"); client.ClientCredentials.ClientCertificate.Certificate = new X509Certificate2(@"[..]", "somepass"); 

Même changé mes références.c pour inclure le ProtectionLevel=ProtectionLevel.Sign sur le ServiceContractAtsortingbute et le OperationContractAtsortingbute.

Ce qui se passe, c’est que l’en-tête wse: security est créé, mais le corps n’est pas en cours de signature. Le service renvoie l’ Element http://schemas.xmlsoap.org/soap/envelope/Body must be signed Les Element http://schemas.xmlsoap.org/soap/envelope/Body must be signed .

Qu’est-ce qui me manque pour que le corps soit signé correctement?

Corrigé en utilisant ce customBinding au lieu du basicHttpBinding .

  //Setup custom binding with HTTPS + Body Signing + Soap1.1 CustomBinding binding = new CustomBinding(); //HTTPS Transport HttpsTransportBindingElement transport = new HttpsTransportBindingElement(); //Body signing AsymmesortingcSecurityBindingElement asec = (AsymmesortingcSecurityBindingElement)SecurityBindingElement.CreateMutualCertificateBindingElement(MessageSecurityVersion.WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10); asec.SetKeyDerivation(false); asec.AllowInsecureTransport = true; asec.IncludeTimestamp = true; //Setup for SOAP 11 and UTF8 Encoding TextMessageEncodingBindingElement textMessageEncoding = new TextMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8); //Bind in order (Security layer, message layer, transport layer) binding.Elements.Add(asec); binding.Elements.Add(textMessageEncoding); binding.Elements.Add(transport); 

Il semble que TransportWithMessageCredential utilise uniquement le transport pour la sécurité et ignore tout le rest.