Generate OpenSSL certificates in Linux environment

Generate OpenSSL certificates in Linux environment

1. Environment: CentOS7, Openssl1.1.1k.

2. Concept:

Root certificate: It is the basis for generating server certificates and client certificates. It can also be called a self-signed certificate, i.e. a CA certificate.

Server certificate: issued by the root certificate and configured on the server.

Client certificate: issued by the root certificate and configured on the client. It can also be configured on a web server and installed on a browser.

Symmetric encryption: A file is encrypted with a password, and then the same password is used to decrypt it.

Asymmetric encryption: one password is used for encryption and another set of passwords is used for decryption. This includes the following two situations:

When used to encrypt data: public key encryption, private key decryption

When used for file signing: private key signature, public key signature verification

3. Steps:

1. View the openssl configuration file openssl.cnf

vim /etc/pki/tls/openssl.cnf

2. Create the directory and files required for the root certificate CA

cd /etc/pki/CA

#Create the directories and files required in the configuration file information mkdir -pv {certs,crl,newcerts,private}

touch {serial,index.txt}

3. Indicate the starting number of the certificate

echo 01 >> serial

4. Generate root certificate

# Generate CA private key (ca.key)
openssl genrsa -des3 -out ca.key 2048 
# Generate CA certificate signing request (ca.csr)
openssl req -new -key ca.key -out ca.csr
# Generate a self-signed CA certificate (ca.cert)
openssl x509 -req -days 3650 -in ca.csr -signkey ca.key -out ca.crt

5. Generate server certificate

# Generate server private key (server.key)
openssl genrsa -des3 -out server.key 2048 
# Generate server certificate signing request (server.csr)
openssl req -new -key server.key -out server.csr
# Use the CA certificate to sign the server CSR to generate the server certificate (server.cert)
openssl ca -days 3650 -in server.csr -out server.crt -cert ca.crt -keyfile ca.key

6. Generate client certificate

# Generate client private key (client.key)
openssl genrsa -des3 -out client.key 2048
# Generate client certificate signing request (client.csr)
openssl req -new -key client.key -out client.csr
# Use the CA certificate to sign the client csr to generate the client certificate (client.cert)
openssl ca -days 3650 -in client.csr -out client.crt -cert ca.crt -keyfile ca.key

7. View the certificate content

openssl x509 -in server.crt -noout -text

8. Convert crt to pem

openssl x509 -in ca.crt -out ca.pem -outform PEM

openssl x509 -in server.crt -out server.pem -outform PEM

openssl x509 -in client.crt -out client.pem -outform PEM

9. Strip the password of the private key

openssl rsa -in server.key -out serverkey.pem

openssl rsa -in client.key -out clientkey.pem

The generated certificate list:

This is the end of this article about the details of generating openssl certificates in Linux environment. For more relevant content about generating openssl certificates in Linux, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • OpenSSL commands and example code in Linux
  • Detailed steps to install openssl, swoole and other extensions under Linux
  • Linux openssl basic introduction

<<:  Detailed explanation of simple html and css usage

>>:  30 free high-quality English ribbon fonts

Recommend

How to run the springboot project in docker

1. Click Terminal below in IDEA and enter mvn cle...

Solution to "Specialized key was too long" in MySQL

Table of contents Solution 1 Solution 2 When crea...

Understand the initial use of redux in react in one article

Redux is a data state management plug-in. When us...

How to clean up data in MySQL online database

Table of contents 01 Scenario Analysis 02 Operati...

Service management of source package installation under Linux

Table of contents 1. Startup management of source...

Vue routing relative path jump method

Table of contents Vue routing relative path jump ...

Pure CSS and Flutter realize breathing light effect respectively (example code)

Last time, a very studious fan asked if it was po...

Docker uses nextcloud to build a private Baidu cloud disk

Suddenly, I needed to build a private service for...

Example of implementing a virtual list in WeChat Mini Program

Table of contents Preface analyze Initial Renderi...

Detailed tutorial on how to automatically install CentOS7.6 using PXE

1. Demand The base has 300 new servers, and needs...

Share 13 basic syntax of Typescript

Table of contents 1. What is Ts 2. Basic Grammar ...

How to view the execution time of SQL statements in MySQL

Table of contents 1. Initial SQL Preparation 2. M...

Use of Docker image storage overlayfs

1. Overview The image in Docker is designed in la...

MySQL data compression performance comparison details

Table of contents 1. Test environment 1.1 Hardwar...