Linux create certificate pem

How do I create a self-signed SSL certificate?

How do I create a self-signed certificate for testing purposes?

3 Answers 3

Ubuntu, even the ‘minimal’ flavour, comes with the ssl-cert package pre-installed, which means you don’t need to do anything.

The files you’re looking for are already on your system:

/etc/ssl/certs/ssl-cert-snakeoil.pem /etc/ssl/private/ssl-cert-snakeoil.key 

If for some reason you need to create a fresh certificate, you can run

sudo make-ssl-cert generate-default-snakeoil --force-overwrite 

If you want to change the expiration date of you certificate, you can manipulate the make-ssl-cert script at /usr/sbin/make-ssl-cert . Around like 124 there’s a line similar to this:

openssl req -config $TMPFILE -new -x509 -nodes \ 

Where you can change the expiration date by adding the -days argument:

openssl req -config $TMPFILE -new -days 365 -x509 -nodes \ 

More options can be found in the manual page of req .

ubuntu-server 12.04 ( AMI cloud image) doesn’t have ssl-cert installed by default have it. But once ssl-cert is installed — /etc/ssl/certs/ssl-cert-snakeoil.pem becomes available automatically.

In attempting to test a website in a local vagrant VM instance, I wanted to Google Chrome to act as if it was a totally normal certificate. I had to first set the VM’s hostname to match the testing url (e.g. www.test.mydomain.com ) using the hostname command in the VM CLI. Then regenerating the key as you suggest, with —force-overwrite , the key’s Common Name (CN) then matched the testing url. Finally, on the host machine, installing the key as a Trusted Root Certificate Authority (in Chrome’s Settings/Advanced) gave me the coveted green address bar.

Читайте также:  Makefile linux как установить

my 9-year old cert stopped working with my upgrade to debian 10, so the make-ssl-cert command saved the day for me!

Also, nginx on ubuntu has /etc/nginx/snippets/snakeoil.conf that sets up paths to certificate files generated by ssl-cert .

As already mentioned, Ubuntu Server comes with the necessary tools. Depending on your server version you’ll have to look up the specific documentation. I’ll try to summarize the self-signed certificate generation process of the current LTS (12.04).

First you generate the keys for the Certificate Signing Request (CSR):

openssl genrsa -des3 -out server.key 2048 

It’s up to you to enter a passphrase or not. If you do, everytime you (re)start a service usign that certificate, you’ll have to provide the passphrase. Otoh you can create an «insecure» key without a passphrase from the secure one:

openssl rsa -in server.key -out server.key.insecure # shuffle the key names to continue without passphrases mv server.key server.key.secure mv server.key.insecure server.key 

And now you’ll create the CSR from the key. With the CSR and the key a self-signed certificate can be generated:

openssl req -new -key server.key -out server.csr openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt 

The last step consists of installing the certificate and the key, in Debian/Ubuntu usually in /etc/ssl :

sudo cp server.crt /etc/ssl/certs sudo cp server.key /etc/ssl/private 

And finally the applications using the certificate/key have to be configured accordingly.

Источник

How to create a .pem file for SSL Certificate Installations

This document (7013103) is provided subject to the disclaimer at the end of this document.

Environment

Situation

Resolution

Privacy Enhanced Mail (PEM) files are concatenated certificate containers frequently used in certificate installations when multiple certificates that form a complete chain are being imported as a single file. They are a defined standard in RFCs 1421 through 1424. They can be thought of as a layered container of chained certificates. A .pem file is a container format that may just include the public certificate or the entire certificate chain (private key, public key, root certificates):

  • Private Key
  • Server Certificate (crt, puplic key)
  • (optional) Intermediate CA and/or bundles if signed by a 3rd party
Читайте также:  Psql command not found linux

How to create a self-signed PEM file

openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem

How to create a PEM file from existing certificate files that form a chain

openssl rsa -in server.key -out nopassword.key
cat nopassword.key > server.pem cat server.crt >> server.pem
cat intermediate.crt >> server.pem

Additional Information

  • Download NetIQ Cool Tool OpenSSL-Toolkit.
  • Select Create Certificates | PEM with key and entire trust chain
  • Provide the full path to the directory containing the certificate files.
  • Provide the filenames of the following:
    • private key
    • public key (server crt)
    • (conditional) password for private key
    • (conditional) any intermediate certificate chain file(s)

    The following details the structure of a typical .pem file (including the entire certificate chain):

    -----BEGIN RSA PRIVATE KEY----- (Private Key: domain_name.key contents) -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- (Primary SSL certificate: domain_name.crt contents) -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- (Intermediate certificate: certChainCA.crt contents) -----END CERTIFICATE----

    Disclaimer

    This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented «AS IS» WITHOUT WARRANTY OF ANY KIND.

    • Document ID:7013103
    • Creation Date: 26-Aug-2013
    • Modified Date:11-Aug-2022
      • SUSE Linux Enterprise Server

      For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

      Источник

Оцените статью
Adblock
detector