create private key openssl genrsa -out keypair.pem 2048 create public key openssl rsa -in keypair.pem -pubout -out publickey.crt PKCS#8 format private key conversion command. openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in keypair.pem -out pkcs8.key