# CMS task

A CMS task encrypts or decrypts the files on the list with a **certificate**, in the format called CMS (the one S/MIME mail uses; files often end in `.p7m`). It is the counterpart of the [PGP](Task-PGP.md) task for partners who work with certificates and not with PGP keys: banks and public bodies, mostly.

> [!NOTE]
> CMS here is the Cryptographic Message Syntax. The task picker's line for this task, "Hand the file to a content management system.", describes something else; the task encrypts and decrypts.

As with PGP, there are two halves. The **certificate** encrypts and can be handed out. The **private key** that belongs to it decrypts and stays with its owner.

| To | You need |
|---|---|
| encrypt a file for a partner | the partner's certificate |
| decrypt a file a partner sent you | your certificate's private key, and its password |

Both are kept in a key store: a file of the kind JKS or PFX (PKCS#12).

## Fields

| Field | What it does | On a new task |
|---|---|---|
| **CMS jks/pfx file** | the key store. **Browse**, **Test**. | |
| **Method** | **Encrypt** or **Decrypt** | Encrypt |
| **Key store password** | the password of the store | |
| **Private key password** | for decrypting: the password of the key, if it has one of its own | |
| **Certificate alias** | which entry of the store: the partner's certificate to encrypt for, or your own key to decrypt with | |
| **Delete Original?** | after encrypting, the plain file is deleted; after decrypting, the encrypted one | on |
| **Route connection through DMZ when possible** | the connection is made from a DMZ server | |

## What it does to the files

The result is written beside the file it was made from, and takes its place on the list. With **Delete Original?** the other one is removed.

Give the task a filter when the list is mixed, such as `*.p7m` for decrypting. In the log: "CMS filtering has …", then "CMS Encrypting …" or "CMS Decrypting …" per file.

Each item gets the size and the checksum of the new file.

## What it hands on

The encrypted or decrypted files, in place of the ones it was given. Items the filter does not match pass untouched.

## Things to know

- **Encrypting needs no secret**: the store for a job that only encrypts holds the partner's certificate and no private key.
- **The alias must be exact.** A store can hold many entries. **Test** shows whether the store opens with the password; the alias is checked when the task runs.
- **Certificates run out.** A file encrypted for a certificate that has since expired can still be decrypted by its owner, but partners replace certificates, and then the old one is the wrong one. Ask for the new certificate before the date.
- **Signing.** This task encrypts and decrypts. For exchanges where every file must be signed and acknowledged, the usual answer is [AS2](Task-AS2.md), which does both and gives a receipt.
- **PGP or CMS?** They do the same job with different kinds of key and cannot read each other's files. Use what the partner uses.
