Generate self-signed certificate

The creation of a self-signed certificate with Linux and OpenSSL is described here. There are many other possibilities, so the solution presented here should be understood as an example.

  1. Generate a certificate with public key and a file for the private key:

    $ openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -sha256 -days 365

    Enter PEM pass phrase = <pass phrase>

    Country: C = e.g. DE

    State: ST = e.g. NDS

    Locality: L = e.g. Hameln

    Organisation: O = e.g. Development

    OrgaUnit: OU = e.g. Department-Product-A

    Common Name = e.g. Name-Of-Certificate

    EMail Address = e.g. Product@Vendor.com

    file ‘cert.pem’ includes the certificate with public key
    file ‘key.pem’ includes the private key

  2. Change format of certificate with public key:

    openssl x509 -outform der -in cert.pem -out certificate.cer

  3. Change format of certificate, including private key:

    openssl pkcs12 -export -out certificate.pfx -inkey key.pem -in cert.pem