The N/certificateControl module enables scripting access to the Digital Certificates list found in the UI at Setup > Company > Certificates. You can use this module to find, create, update, read and delete certificates records. For more information, see Digital Signing and Uploading Digital Certificates.
To access this module, you must use the Execute As Role field on the script deployment record. Select either the Administrator role or a custom role with the Certificate Access permission. For more information, see Access to Digital Certificates.
The certificate record holds information for a digital certificate, but it is not a standard NetSuite record and cannot be accessed with the N/record.
N/certificateControl Module Members
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Object |
object |
Server scripts |
Encapsulates a digital certificate record. |
|
Method |
object |
Server scripts |
Returns metadata about the certificate(s). |
|
object[] |
Server scripts |
Returns an audit trail of how a certificate has been used. Includes operations performed with time stamps. |
||
Server scripts |
Creates a certificate record using a file from the File Cabinet. After saving with Certificate.save(), the certificate is accessible on the Certificates. |
|||
string |
Server scripts |
Deletes a certificate record that has been uploaded to the Certificates list in the UI or created using certificateControl.createCertificate(options) and saved with Certificate.save(). |
||
Server scripts |
Loads a certificate record that has been uploaded to the Certificates list in the UI or created using certificateControl.createCertificate(options). |
|||
string |
Server scripts |
Locks a certificate record so that it cannot be edited. |
||
string |
Server scripts |
Unlocks a certificate record that has been locked with certificateControl.lock(options). |
||
Enum |
enum |
Server scripts |
Holds the values for the operation when searchng for certificates with certificateControl.findUsages(options). |
|
enum |
Server scripts |
Holds string values for search operators to use with the |
||
enum |
Server scripts |
- |
Certificate Object Members
The following members are called on the certificateControl.Certificate object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Method |
object containing the script ID of the new certificate record |
Server scripts |
Saves a certificate record. |
|
Property |
string |
Server scripts |
Describes the certificate record. |
|
File Object Members object |
Server scripts |
Includes the properties of the file uploaded to create the certificate. |
||
string |
Server scripts |
The name of the certificate record. |
||
boolean |
Server scripts |
Indicates the setting of the Month box for Expiration Reminders on the certificate record. |
||
number[] |
Server scripts |
The internal IDs of the employees selected in the Copy Employees field on the certificate record. |
||
string (write-only) |
Server scripts |
The password for the digital certificate. You can create a GUID for the password using Form.addSecretKeyField(options) or you can create an API secret for the secret at Setup > Company > API Secrets. |
||
number[] |
Server scripts |
The internal IDs of the employees selected in the Restrict to Employees field of the certificate record. |
||
string |
Server scripts |
The ID of the certificate record. |
||
number[] |
Server scripts |
The internal IDs of the subsidiaries associated with the certificate record. |
||
boolean |
Server scripts |
Indicates the setting of the 3 Months box for Expiration Reminders on the certificate record. |
||
boolean |
Server scripts |
Indicates the setting of the Week box for Expiration Reminders on the certificate record. |
N/certificateControl Module Script Samples
Filter the Digital Certificates list by subsidiary and file type
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 depoly). For more information, see SuiteScript 2.x Script Basics and SuiteScript 2.x Script Types.
The following sample shows how to filter the Digital Certificates list by subsidiary and by file type.
Find the audit trail of POST operations for the certificate record with ID
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.
The following sample shows how to find the audit trail of POST operations for the certificate record with ID ‘custcertificate_china’.
Create a File object by loading a file from the File Cabinet
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.
The following sample shows how to create a file object by loading a file from the File Cabinet. It then creates the options needed for the certificateControl.createCertificate(options) method and creates and saves the certificate record. The certificate record is then loaded again, edited to the change the file, and saved again.
Find an existing certificate record
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.
The following sample shows how to find an existing certificate record and use it in an operation.
Generate signature of a plaintext string and verify the signature using the same certificate
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.
The following sample shows how to generate a signature of a plaintext string and then verifies the signature using the same certificate.
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.
Establish SFTP connection using an SSH key
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.
The following sample establishes a SFTP connection using an SSH key that has already been uploaded to NetSuite. It then creates, updates, loads, and deletes a certificate record to show the full CRUD operation. Replace the server URL with your correct URL.
For the SFTP connection, the public key corresponding to the private key in the certificate must be stored in the .ssh/authorized_keys file on the server.