I am trying to decode a PEM encoded file using java. There is a very similar question posted already, however it is for DER encoded files, as opposed to PEM encoded files.
The CMSEnvelopedDataParser used there doesn't seem to be suitable for my job. What can I use instead? I am struggling to find a working example online. Any snippet would be very appreciated.
To recreate the problem one can simply follow the steps below.
openssl req -nodes -new -x509 -keyout private.pem -out cert.cert
openssl rsa -pubout -in private.pem -out public.pem
openssl smime -encrypt -outform PEM -inkey public.pem -in text.txt -out text.txt.pem cert.cert
Then the command I am trying to replace with java is the following:
openssl smime -decrypt -inform PEM -in text.txt.pem -out dec.txt -inkey private.pem