Message.decrypt(options)

Note:

The content in this help topic pertains to SuiteScript 2.1.

Method Description

Decrypts a message and optionally verifies the signatures.

Returns

pgp.MessageData

Supported Script Types

Server scripts

Governance

None

Module

N/pgp Module

Parent Object

pgp.Message

Sibling Module Members

Message Object Members

Since

2022.2

Parameters

Parameter

Type

Required / Optional

Description

Since

options.decryptionKeys

pgp.Key |pgp.Key[]

required

Uses one or more keys to attempt message decryption.

2022.2

options.verificationKeys

pgp.Key |pgp.Key[]

optional

Uses zero or more keys to attempt message signature verification. If you do not provide a verification key, the message's signature (if any) will be ignored.

If you do provide a verification key, at least one signature must be verifiable by one of the provided keys, otherwise an error will be thrown.

An expired key works if the signature was made before the expiration. Default value = [].

2022.2

options.verification

pgp.Verification

optional

An empty verification object. If you provide a value for this parameter, the verification results will be flushed instead of throwing an error for invalid signature. Default value = null.

2022.2

options.supressVerificationErrors

boolean

optional

If set to true, the verification errors will not be thrown. This value is implicitly set to true when the verification parameter is provided. Default value = false.

2022.2

options.config

pgp.Config

optional

The configuration. Default value is pgp.createConfig(options).

2022.2

Errors

Note:

If the message is not well formed, various parse errors can be thrown.

Error Code

Thrown If

PGP_EXPECTED_ENCRYPTED MESSAGE

The message is not encrypted.

PGP_NO_MATCHING_DECRYPTION_KEY_ANALYSIS_1

No matching decryption key was found.

PGP_MESSAGE_IS_NOT_INTEGRITY_PROTECTED

The message is not integrity protected.

PGP_INTEGRITY_VERIFICATION_FAILED

The message is corrupted.

PGP_VERIFICATION_FAILED_NO_SIGNATURE

The message is not signed, but verification keys were provided.

PGP_VERIFICATION_FAILED_1

None of the signatures could be verified using the provided verification keys.

Syntax

Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/pgp Module Script Samples.

            // Add additional code
...

const verification = pgp.createVerification();
message.decrypt({ 
   decryptionKeys: keys.ours.pri,
   verificationKeys: keys.our.pub,
   verification: verification,  // supresses verification errors
});

...
// Add additional code 

          

Related Topics

General Notices