PGP Decryption in MuleSoft
Vendor can share their public key either in asc (Text) or gpg (Binary) extension to their clients so that they can do the decryption and send the decrypted data/files to Vendor. Once vendor receive the decrypted message then they can use their Private Key to decrypt the message. Let’s see how PGP decryption works in MuleSoft.
Before that if you want to understand PGP from starting then please go through below tutorials.
- PGP Introduction and Kleopatra tool for Key management
- Generate Private Public PGP key
- Vendor Provided PGP Public Key
PGP Decryption – We need two things to decrypt in MuleSoft
- Private Key in gpg format
- Passphrase
- Fingerprint
For this POC we will use Private Key we created in our earlier Tutorial – Generate Private Public PGP key
Let’s create a project in MuleSoft
Add the Crypto connector in Mule Palette – Checkout this tutorial on how to add module in Anypoint studio
Drag and drop PGP decrypt and Logger into the flow
Add Private_4232E6BD7151FF89D9F755807AC70C45987C59AA.gpg – PGP private key in resources
Click on PGP decrypt connector and click on add configuration
Populate Private keyring with Private key name we place in resources
- Click Add symbol to add key detail
- Add Key id, Fingerprint and Passphrase detail
Click Finish
Configuration will be like below
In logger we will capture the decrypted payload
Now run the application and test the endpoint in SOAP UI, will use the encrypted payload we generated in link
We can see the decrypted message in response
PGP MuleSoft application – pgp-sample-service
PGP SOAP UI application – PGP-Sample-soapui-project