Generate unencrypted key pair using openssl
$ openssl genrsa -out private.pem 2048
Generate encrypted key pair using openssl
$ openssl genrsa -des3 -out private.pem 2048
Convert private key to PKCS#8 in der format
$ openssl pkcs8 -topk8 -inform PEM -outform DER -in private.pem -out private.der -nocrypt
Export public key to DER format
$ openssl rsa -in private.pem -pubout -outform DER -out public.der