Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Unfortunately, I'm not sure that this is going to be possible using Apex. I created a test Java program (which works against the Google API) to observe the differences between what Java produces vs Apex. I noted the signatures generated from the two were different which narrowed it down to the output of the <code>Crypto.sign()</code> method.</p> <p>I found <a href="http://wiki.developerforce.com/index.php?title=Apex_Crypto_Class&amp;action=edit" rel="nofollow">this</a> link which gives the following info:</p> <blockquote> <p>The Apex Crypto class provides support for Digital Signatures with the sign() method. The following considerations apply:</p> <ul> <li>The two algorithms are RSA and RSA-SHA1, which are functionally equivalent. </li> <li>A PKCS8 formatted private key in base64 decoded form is required. This private key should not be hardcoded in the Apex script but should be stored in a protected custom setting or a encrypted fields in a custom table.</li> <li>It is equivalent to the Java Signature.sign() class method using "<strong>SHA1withRSA</strong>".</li> <li>In C#, it is the equivalent of (1) signing the clear text using SHA1Managed.ComputeHash() and (2) Signing using RSACryptoServiceProvider.ComputeHash() against the resulting hash.</li> <li>Functionally, it will compute a SHA1 digest from clear text and encrypt the digest using RSA with the provided private key.</li> </ul> </blockquote> <p>I have highlighted the key issue here, I believe you need the equivalent of <strong>SHA256withRSA</strong> which does not seem to be an option with the Crypto class (at least not that I can figure out).</p> <p>So, in summary I think your code is correct but the signature being generated is not.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload