CMSDECRYPT Decrypt a CMS encrypted file |
Top Previous Next |
This script command decrypts / verifies a CMS (PKCS #7) file that was previously encrypted / signed using the CMSENCRYPT command. To decrypt a file you must have already imported the PKCS#12 SSL certificate that corresponds to the X.509 SSL certificate that was used to encrypt the file. The certificate used for decryption will be contained in a .pfx (PKCS #12) file. Such certificates are imported by using the Import Certificate functionality in the Robo-FTP Configurator. To validate the signature of a file you must have already used the Robo-FTP Configurator to import the SSL certificate provided by the signer, which will be given as an X.509 certificate enclosed within a .cer or .pem file.
In the following example, the CMSDECRYPT command is used to decrypt and validate the signature of a file which was previously signed by "Fictional Company A" and encrypted in the CMS format for recipient "Fictional Company B". Because the /signature=required option is provided, if no signature is found inside the CMS file, an error will occur. Note that in order for the recipient to successfully validate the signature in the file, Fictional Company A's X.509 SSL certificate (e.g. file "fictional_company_a.cer") must have been previously imported in the Configurator, as an SSL certificate ("for: encryption"). Additionally, for decryption to succeed, the recipient's PKCS #12 certificate (e.g. from file "fictional_company_b.pfx") must have been previously imported in the Configurator, as an SSL certificate ("for: decryption + signing"):
CMSDECRYPT "plaintext.signed_and_encrypted.cms" "plaintext.txt" /signature=required /validatewith="Fictional Company A"
In the following example, the same conditions apply, but with one exception. Since the /signature=required option has been changed to /signature=ignore, the file will be decrypted into the target file "plaintext.txt", regardless of the existence or validity of any enclosed signature in the source file:
CMSDECRYPT "plaintext.signed_and_encrypted.cms" "plaintext.txt" /signature=ignore
These are the possible result codes returned by the CMSDECRYPT command:
Related command(s): CMSENCRYPT See also: SSL Certificates menu, Import Certificate
|