Message.decrypt(options)
The content in this help topic pertains to SuiteScript 2.1.
Method Description |
Decrypts a message and optionally verifies the signatures. |
Returns |
|
Supported Script Types |
Server scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
None |
Module |
|
Parent Object |
|
Sibling Module Members |
|
Since |
2022.2 |
Parameters
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
|
required |
Uses one or more keys to attempt message decryption. |
2022.2 |
|
|
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 |
|
|
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 = |
2022.2 |
|
|
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 = |
2022.2 |
|
optional |
The configuration. Default value is pgp.createConfig(options). |
2022.2 |
Errors
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
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