1. Extract the key-pair

openssl pkcs12 -in sample.pfx -nocerts -nodes -out sample.key


2. Get the Private Key from the key-pair

openssl rsa -in sample.key -out sample_private.key


3. Get the Public Key from key pair

openssl rsa -in sample.key -pubout -out sample_public.key


4. Need to do some modification to the private key -> to pkcs8 format

openssl pkcs8 -topk8 -inform PEM -in sample_private.key -outform PEM -nocrypt

Copy the output and save it as sample_private_pkcs8.key


5. Get those files

public key: sample_public.key

private key:  sample_private_pkcs8.key


6. If you need base64 file run this command

openssl enc -base64 -in sample_public.key -out base64_public.key