N/crypto/certificate Module Features in SuiteScript

The N/crypto/certificate module in SuiteScript offers XML signing and verification, enhancing data security through digital signatures.

·2 min read·View Oracle Docs

The N/crypto/certificate module is essential for SuiteScript developers focused on securely signing XML data. This module provides methods to create digital signatures and verify them, thereby ensuring data integrity during transactions.

What Are the Key Features of the N/crypto/certificate Module?

The N/crypto/certificate module includes the following core members:

Objects

NameReturn TypeSupported Script TypesDescription
certificate.SignedXmlObjectServer scriptsEncapsulates an XML string that has been digitally signed.
certificate.SignerObjectServer scriptsEncapsulates a created signature (signer) for plain strings.
certificate.VerifierObjectServer scriptsEncapsulates a created verifier for verifying plain string signatures.

Methods

NameReturn TypeSupported Script TypesDescription
certificate.createSigner(options)certificate.SignerServer scriptsCreates a certificate.Signer object for signing plain strings.
certificate.createVerifier(options)certificate.VerifierServer scriptsCreates a certificate.Verifier object for verifying signatures of plain strings.
certificate.signXml(options)certificate.SignedXmlServer scriptsSigns the input XML string using the Certificate ID, returning a signed XML object.
certificate.verifyXmlSignature(options)voidServer scriptsVerifies the signature in the SignedXml file.

Enums

NameTypeSupported Script TypesDescription
certificate.HashAlgenumServer scriptsHolds string values for hash algorithm types, used in signing and verifying methods.

How to Use the N/crypto/certificate Module

To use the module for signing and verifying XML signatures, follow the syntax shown below:

suitescript
1// Establishing a signedXml object
2var signedXml = certificate.signXml({
3 algorithm: certificate.HashAlg.SHA256,
4 certId: 'custcertificate1',
5 rootTag: 'infNFe',
6 xmlString: infNFe.getContents()
7});
8
9// Verifying the XML signature
10certificate.verifyXmlSignature({
11 signedXml: signedXml,
12 rootTag: 'infNFe'
13});

Important Notes

  • The signing methods disable formatting, which means any line breaks in the XML will not be included in the signature.
  • This module is only available for use in server scripts, emphasizing its security and operational integrity.

Who This Affects

  • Developers: Utilizing the N/crypto/certificate module for secure XML processing.
  • Administrators: Implementing secure transaction processes through SuiteScript.

Key Takeaways

  • The N/crypto/certificate module facilitates secure XML signing and verification.
  • It includes essential methods for creating signers and verifiers.
  • Effective for server-side scripts, enhancing data security through digital signatures.

Frequently Asked Questions (4)

Can the N/crypto/certificate module be used in client scripts?
No, the N/crypto/certificate module is only available for use in server scripts to ensure security and operational integrity.
What algorithms are supported by the N/crypto/certificate module for signing?
The module uses string values from the certificate.HashAlg enum for hash algorithms, such as SHA256, in its signing and verifying methods.
How does the signXml method handle XML formatting?
The signing methods disable formatting, meaning any line breaks in the XML will not be included in the signature. This is crucial for maintaining data integrity in the signature.
What objects does the N/crypto/certificate module provide for signature creation and verification?
The module provides objects such as certificate.SignedXml for signed XML strings, certificate.Signer for creating signatures, and certificate.Verifier for verifying signatures.
Source: N/crypto/certificate Module Members Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in Integration

View all Integration articles →