I've been given a certificate and told to encrypt a file using openssl.
- This certificate is a .cer file, so I need to create a .pem file first. I have tried doing this using macOS's Keychain Access, and also using openssl in the terminal. They result in the same file, which starts with
-----BEGIN CERTIFICATE-----
. I run the following command
openssl pkeyutl -encrypt -inkey certificate.pem -pubin -in key.xml -pkeyopt rsa_padding_mode:oaep -pkeyopt rsa_oaep_md:sha256 -pkeyopt rsa_mgf1_md:sha256 -out key.xml.enc
I get the error
unable to load Public Key Error initializing context 4799456876:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:697:Expecting: PUBLIC KEY
Am I using the wrong tools or the wrong approach? Any help is appreciated :)