Extract the private key from mycert.pfx:
openssl pkcs12 -in mycert.pfx -nocerts -out my-private-key.pem
Convert .pfx/.p12 to .pem:
openssl pkcs12 -in mycert.pfx -out mycert.pem
Extract the public key:
openssl x509 -inform pem -in mycert.pem -pubkey -out my-public-key.pem