Something related to Digital signature

if we have a doc in sales-force and needs to be digitally signed, which involves digital certificates.. and how we can use crypto class of apex in this. also how to verify that Digital signature in other peer for authenticity and integrity of the message.

If its come to digital signature, We use private and public key certificate for encrypt and decrypt the message. then how i can generate a public and private certificate in salesforce certificate key management.

Needed very solution very badly for this, Any help can be appreciated.

  • i have a code for signing the document and the sign will store in the attachment of the object using visual force page and apex class @NITHESH K
    – SFDC
    Commented Aug 31, 2017 at 6:41
  • Can share me a code of that for understanding . My this question also related my one more question present in StackExchange salesforce.stackexchange.com/questions/190290/…
    Commented Aug 31, 2017 at 6:45
  • but i have not use crypto, just using vf page and apex class, it will capture the sign and store in the attachment of the particular object
    – SFDC
    Commented Aug 31, 2017 at 6:46
  • 1
    i have created the custom button like signature , if you click that button, the box will open , after that i will sign in that box , down save button will be there,if you click save then it will store in the attachment of the object
    – SFDC
    Commented Aug 31, 2017 at 6:49
  • 1
    Can u share what you have done, So that i can get any idea about that
    Commented Aug 31, 2017 at 7:15

1 Answer 1


Apex class for capturing the sign

public class signAccountExtension {
    Id accountId;

    public string fileData { get; set; }

    public signAccountExtension(ApexPages.StandardController controller) {
        accountId = controller.getId();
    public void saveImage() {
        insert new Attachment(
            ParentId = accountId

Visual Force Page:

<apex:page standardController="Account" extensions="signAccountExtension">
        #signature {
        border: 1px solid black;
    <apex:form id="form">
        <apex:actionFunction action="{!saveImage}" name="saveImageToServer" reRender="">
            <apex:param assignTo="{!fileData}" name="data" value="" />
        <canvas id="signature" width="400" height="100" />
        <button id="save">
    !function() {
        var canvas, lastX, lastY;
        function start(event) {
            lastX = event.offsetX;
            lastY = event.offsetY;
            document.body.addEventListener("mousemove", draw);
            document.body.addEventListener("mouseup", end);
        function draw(event) {
            var context = canvas.getContext("2d");

            if(event.target === canvas) {
                context.fillStyle = "black";
                context.strokeStyle = "black";
                context.moveTo(lastX, lastY);
                context.lineTo(event.offsetX, event.offsetY, 3);
                lastX = event.offsetX;
                lastY = event.offsetY;
        function end(event) {
            document.body.removeEventListener("mousemove", draw);
            document.body.removeEventListener("mouseup", end);
            canvas.removeEventListener("mouseenter", mouseenter);
        function save(event) {
        function init() {
            var context;
            canvas = document.getElementById("signature");
            canvas.addEventListener("mousedown", start);

            context = canvas.getContext("2d");
            context.fillStyle = "white";
            context.fillRect(0, 0, canvas.width, canvas.height);

            document.getElementById("save").addEventListener("click", save);
        window.addEventListener('DOMContentLoaded', init);
  • Yes i read about this solution before .There storing in attachment , Signature draw in canvas window ..
    Commented Aug 31, 2017 at 7:23
  • but i dont know about your using crtfile requirement,i have done like this manner only
    – SFDC
    Commented Aug 31, 2017 at 7:24
  • this i kind alternative for storing the signature. if you look developer.salesforce.com/docs/atlas.en-us.apexcode.meta/… , click on funcion "signWithCertificate(algorithmName, input, certDevName)" this method will generate a signature based on org certificate and input file .
    Commented Aug 31, 2017 at 7:26
  • No problem, I appreciated for your help.
    Commented Aug 31, 2017 at 7:28
  • 1
    Yes, i am looking alternative solution for my question. it was my project requirement so.
    Commented Aug 31, 2017 at 7:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .