Check the certificat openssl x509 -in certificate.crt -text -noout
Compare the certificat & the private key; This :
openssl x509 -modulus -noout -in mycomp.com.crt | openssl md5
Should return the same as :
openssl rsa -modulus -noout -in mycomp.com.key | openssl md5
1 - First : retrieve the public key in the certificat
openssl x509 -in mycomp.com.crt -pubkey -noout > mycomp.com-pub.pem
2 - encrypt a string
openssl rsautl -encrypt -inkey mycomp.com-pub.pem -pubin -in <(echo "my string to encrypt") -out /tmp/data.enc
cat /tmp/data.enc
3 - Check that file is well encrypted
openssl rsautl -decrypt -inkey mycomp.com.key -in /tmp/data.enc
rm /tmp/data.enc