Generate a Signature of a Plain Text String and Verify the Signature Using the Same Certificate

The following sample shows how to generate a signature of a plaintext string and then verifies the signature using the same certificate.

Note:

This sample script uses the require function so that you can copy it into the SuiteScript Debugger and test it. You must use the define function in an entry point script (the script you attach to a script record and deploy). For more information, see SuiteScript 2.x Script Basics and SuiteScript 2.x Script Types.

          /**
 * @NApiVersion 2.x
 */

require(['N/certificateControl','N/crypto/certificate'], function(cc, certificate){
    var signer = certificate.createSigner({
        certId:'custcertficiate_cert_1',
        algorithm: 'SHA256'
        });
    var result = signer.sign();
    var verifier = certificate.createVerifier({
        certId: 'custcertificate_cert_1',
        algorithm: 'SHA256'
        });
    verifier.update('test');
    verifier.verify(result);
}) 

        

The res variable returns an array of information about the usage of the digital certificate, including the date of the action, the type of operation, such as sign, and the internal ID of the person who performed the action.

General Notices