Decrypt files through SQL Server Integration Services Job

Hello Everyone,

Our situation is we are trying to automate the decryption of an encrypted file through SQL Server Integration Services.

We are running the following command through a SQL Server Job:
gpg --output c:\temp\test.txt.pgp --batch --passphrase testpassphrase --decrypt c:\temp\test.txt

Running it as a SQL job is failing, with the following message:
gpg: decryption failed: No secret key. Process Exit Code 2. The step failed.

If we try to run the same command through cmd.exe it decrypts the file successfully.

Thank you,

Jason

This job was failing because when it attempted to decrypt the file it used the user account that was running SQL Server Agent service instead of the account that was running the job. No certificate had been uploaded to the account running SQL Server Agent (Network Service in this case).

Temporary resolution was to copy the entire gpg directory under AppData/Roaming/ from a user with access to the certificate to the user running the SQL Agent service.