Bonjour a tous,

Je galère un peu pour signer un fichier XML en c# ou vb.net

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<soapenv:Envelope xmlns:ser="http://service.lock.sazwl.be/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><ds:Signature Id="SIG-74BC5B9F1E142B68071577180338092185" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"><ec:InclusiveNamespaces PrefixList="ser soapenv" xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/></ds:CanonicalizationMethod><ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/><ds:Reference URI="#id-74BC5B9F1E142B68071577180338019184"><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"><ec:InclusiveNamespaces PrefixList="ser" xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/></ds:Transform></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><ds:DigestValue>NZ/yKxr*****errj0IeNkPJmwgs=</ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue>N63lnOGnhyGGL8f/9Ffu8ciB11RMXt5Ac/zd3rfrzliATF3Vjbzmg4f80yvA2pxXemQd0FPfJ5F7
aNE9bGJ0dRA4***********ZfcNWJfbRYRzRD7YPY6NZ5EcN1a5s8LhoXHOVWuwtOVkgA7VRH
GKEn1Rvx2QGXGL8oz3hgwQdpnJVt4idrd6/B4f2a0VMkZLWYHeKtyp/8hRqyQhuJPnkUTfG+Jart
BhQWTZLgA12YPO6JDZ2pE/Ka9LzA+lujpK4GlXeVELkKPckT3NfosYVxj6TR//BRfGsH8ox2WxMZ
Mam/G0b4IxyaUDhyrvsYlcfrUHqYPDZJM5r1Zw==</ds:SignatureValue><ds:KeyInfo Id="KI-74BC5B9F1E142B68071577180338019182"><wsse:SecurityTokenReference wsu:Id="STR-74BC5B9F1E142B68071577180338019183"><wsse:KeyIdentifier EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3">MIIEjTCCA3WgRKLihqIXasAq9oE9BCT8O9g4xQvjdKDvQVB2O4kT8w6EnZ5YRNvk9RFG2hEDw6OcOF0v+M/zJhHIb6Xi5YcPrfIxrLF+k0VVq1E3NKzDUV5LbysYcR0CojIqD5s7RgUQgtUMZ4jRBOmGWDqCM/vNMDSUjJZ************qDY3jEyo6PBDqrClLDCVl7DcQ1UdHSd/CloWJn9Han/RXmg7uA7tKgufM/BXNS19xSZoO5wrsleAu8M01/b7TsvDCppGrV4B5/yw=</wsse:KeyIdentifier></wsse:SecurityTokenReference></ds:KeyInfo></ds:Signature></wsse:Security></soapenv:Header>
   <soapenv:Body wsu:Id="id-74BC5B9F1E142B68071577180338019184" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
      <ser:getPerson>
         <customerInformations>
            <ticket>f3943170-4ba9-4532-8733-88ac1ca8ed8f</ticket>
            <timestampSent>2019-12-23T11:45:01.249+01:00</timestampSent>
            <organisationId>5003</organisationId>
            <applicationName/>
         </customerInformations>
         <privacyLog>
            <context>LOZAATAIRE</context>
            <treatmentManagerIdentifier identityManager="RN_RBIS">80******567</treatmentManagerIdentifier>
            <civilServantIdentifier identityManager="RN_RBIS">80******567</civilServantIdentifier>
            <dossier>
               <dossierSLSP source="?">425</dossierSLSP>
            </dossier>
         </privacyLog>
         <request>
            <personNumber>80******567</personNumber>
         </request>
      </ser:getPerson>
   </soapenv:Body>
</soapenv:Envelope>

C'est toute les balise wsse:security ainsi que l'id dans le body. Je dois utiliser un certificat avec une clé privée. L'exemple provient de SOAPUI et à fonctionné.

Si quelqu'un à une piste je suis preneur ;-).

D'avance je vous remercie et vous souhaite à tous des bonnes fêtes de fin d'annee.

OLBI