Just faced it and no ideas how to solve it. I got a task to encode with RSA the file using .PEM file ( This file begins with BEGIN CERTIFICATE and ends with END CERTIFICATE). I tried alotta ways using openssl command, but got no positive result.
Note: I have no public/private keys...
I think I need, firstly, extract the public key from certificate. Then I should to encrypt my file using public key from this certificate, right ?
That's how I got public key from my .PEM certificate file:
openssl x509 -inform pem -in certificate.pem -noout -pubkey >pubkey.pem