function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Prakash NawalePrakash Nawale 

How to calculate ds:DigestValue and ds:SignatureValue in apex

We are doing Integration with external systems and unable to calcualte ds:DigestValue and ds:SignatureValue values
<soap:Envelope xmlns:soap="" xmlns:v1=".........." xmlns:v11="........">
  <soap:Header xmlns:wsa="">
    <wsse:Security xmlns:wsse="" xmlns:wsu="">
      <wsu:Timestamp wsu:Id="TS-128F375C5B3256FAE8151780686184254">
      <wsse:BinarySecurityToken EncodingType="" ValueType="" wsu:Id="X509-128F375C5B3256FAE8151780686183551"> ----
      <ds:Signature Id="SIG-128F375C5B3256FAE8151780686183653" xmlns:ds="">
          <ds:CanonicalizationMethod Algorithm="">
            <ec:InclusiveNamespaces PrefixList="wsa soap v1 v11" xmlns:ec=""/>
          <ds:SignatureMethod Algorithm=""/>
          <ds:Reference URI="#id-128F375C5B3256FAE8151780686183652">
              <ds:Transform Algorithm="">
                <ec:InclusiveNamespaces PrefixList="soap v1 v11" xmlns:ec=""/>
            <ds:DigestMethod Algorithm=""/>
            <ds:DigestValue>--How to calcualte this?--</ds:DigestValue>
        <ds:SignatureValue> --How to calcualte this?--</ds:SignatureValue>
        <ds:KeyInfo Id="KI-128F375C5B3256FAE8151780686183550">
          <wsse:SecurityTokenReference wsu:Id="STR-128F375C5B3256FAE8151780686183551">
            <wsse:Reference URI="#X509-128F375C5B3256FAE8151780686183549" ValueType=""/>

Please let me know how to get ds:DigestValue, ds:SignatureValue values and in which order we have to calculate.
NagendraNagendra (Salesforce Developers) 
Hi Prakash,

May I suggest you please give a try by using System.Crypto methods for all the Signing. which should help.

Please let us know if this helps.

Hello Prakash,

I have the same usecase of need to generate the Digest and Signature value.  Can you please let me know if you got succeeded? I tried using crypto.generatedigest and crypto.Sign methods but the values generated are not matching with other external tools values.

Prakash NawalePrakash Nawale
Hi All,

Salesforce not supports wsu tags, I suggested client to move to REST service
Thank you for your response Prakash. It's good that your end point moved to REST. But in our case we don't have much control over end point and we need to connect via WS SOAP protocol and looking for work arounds as SF dont support WS.