Skip to content

Instantly share code, notes, and snippets.

@marta-krzyk-dev
Last active April 2, 2025 18:32
Show Gist options
  • Save marta-krzyk-dev/83168c9a8e985e5b3b1b14a98b533b9c to your computer and use it in GitHub Desktop.
Save marta-krzyk-dev/83168c9a8e985e5b3b1b14a98b533b9c to your computer and use it in GitHub Desktop.

Revisions

  1. marta-krzyk-dev revised this gist Feb 8, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions Extras.txt
    Original file line number Diff line number Diff line change
    @@ -7,10 +7,10 @@ Convert crt to pfx.

    --- EXPORT KEYS FROM CERTIFICATE ----

    Export key pair:
    Export private key:
    pkcs12 -in certificate-private.pfx -nocerts -nodes -out sample.key

    Export public key:
    Export certificate:
    pkcs12 -in certificate-private.pfx -clcerts -nokeys -out publickey.pem

    pkcs12 -in certificate-private.pfx -nokeys -out public.key -nodes
  2. marta-krzyk-dev revised this gist Jan 22, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Create ECDSA certificate.txt
    Original file line number Diff line number Diff line change
    @@ -39,7 +39,7 @@ The pfx file's icon should be an opened letter with yellow key.

    --- IMPORT THE CERTIFICATE TO YOUR MACHINE (for Windows)----

    7. Click "Start" and open mmc Microsoft Management Console.
    7. Click "Start" and open mmc Microsoft Management Console as Administrator.
    8. Choose File -> Add/remove snap-in.
    9. Choose "Certificates" and "Add", Choose "Local machine".
    10. Open "Personal" or "Trusted Root..." and choose "Certificates".
  3. marta-krzyk-dev created this gist Jan 22, 2019.
    48 changes: 48 additions & 0 deletions Create ECDSA certificate.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    --- CREATE SELF-SIGNED ECDSA CERTIFICATE WITH PRIVATE KEY INSIDE ----

    1. Open openssl.exe.

    2. If you haven't chosen a curve, you can list them with this command:

    ecparam -list_curves

    I picked sect571r1 for this example. Use this to generate an EC private key if you don't have one already:

    ECDSA 384 - brainpoolP384r1
    ECDSA 512 - sect571r1

    3. Create private-key.pem

    ecparam -name brainpoolP512r1 -genkey -param_enc explicit -out private-key.pem
    ecparam -genkey -name secp521r1 -noout -out private-key.pem

    3. Create certificate in certificate.pem.

    req -new -x509 -key private-key.pem -out certificate.pem -days 900000 -subj "/C=PL/ST=Silesia/L=Katowice/O=MyOrganization/CN=CommonName"

    4. You can inspect the files in the console:

    ecparam -in private-key.pem -text -noout
    x509 -in certificate.pem -text -noout

    5. Combine private key and certificate into a new certificate-private.pem file. Open up command line, move to the folder where your files exist.

    cat private-key.pem certificate.pem > certificate-private.pem

    6. Create p12 / p7b / pfx certificate from certificate-private.pem.

    pkcs12 -export -inkey private-key.pem -in certificate-private.pem -out certificate-private.pfx
    pkcs12 -export -inkey private-key.pem -in certificate-private.pem -out certificate-private.p12
    pkcs12 -export -inkey private-key.pem -in certificate-private.pem -out certificate-private.p7b

    The pfx file's icon should be an opened letter with yellow key.

    --- IMPORT THE CERTIFICATE TO YOUR MACHINE (for Windows)----

    7. Click "Start" and open mmc Microsoft Management Console.
    8. Choose File -> Add/remove snap-in.
    9. Choose "Certificates" and "Add", Choose "Local machine".
    10. Open "Personal" or "Trusted Root..." and choose "Certificates".
    11. Right-click "Certificates" -> "All tasks" -> "Import" and choose the file.
    12. The certificate should come up in the list and the icon should have a key.
    Double click to show details. In "General" tab you should see "You have a private key that corresponds to this certificate".
    16 changes: 16 additions & 0 deletions Extras.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    --- CONVERT CERTIFICATE TO ANOTHER FORMAT ----

    Convert crt to pfx.

    pkcs12 -export -out certificate.pfx -inkey private.key -in public.crt


    --- EXPORT KEYS FROM CERTIFICATE ----

    Export key pair:
    pkcs12 -in certificate-private.pfx -nocerts -nodes -out sample.key

    Export public key:
    pkcs12 -in certificate-private.pfx -clcerts -nokeys -out publickey.pem

    pkcs12 -in certificate-private.pfx -nokeys -out public.key -nodes