1. The basic function of creating a certificate is to bind a public key with the name of a security individual (individual, company, organization, etc. Generally, several steps are required to create a certificate, as shown in. First, use opensslgenrsa to generate a private key, then use opensslreq to generate a signing request, and finally send the request to the CA. After signing the request, the CA will become the certificate for the CA authentication. If the-x509 parameter is added to the second request, a self-1 certificate is generated directly.
The basic function of a certificate is to bind a public key with the name of a security individual (individual, company, organization, etc.
Generally, several steps are required to create a certificate, as shown in. First, use openssl genrsa to generate a private key, then use openssl req to generate a signing request, and finally send the request to the CA. After signing the request, the CA will become the CA-certified certificate. If the-x509 parameter is added to the second request, a self-signed certificate is generated directly, that is, the CA authenticates itself.
In addition to this method, the Debian or Ubuntu system has a simpler way to create a self-signed certificate using the make-ssl-cert command. This command is usually installed along with Apache installation in the ssl-cert package. It may also be installed separately.
If you only want to make an electronic certificate for testing or do not want to spend money to find a CA to sign, you can create a Self-signed electronic certificate. Of course, this type of e-certificate does not have any guarantee, and most software occasionally sends a warning to this certificate, or even does not receive this type of certificate. Self-signed (self-signed) certificates are mainly used for SSL communication between users and systems rather than anti-counterfeiting, to ensure the security of personal information such as passwords during transmission.
Here are the certificate-related terms:
The RSA private key can decrypt the Information encrypted with the certificate public key. The private key is also called a key. The Administrator must be careful to keep it confidential.
CSR (Certificate Signing Request) contains the public key and name information. It is usually suffixed with. csr. It is the intermediate file that the website initiates an authentication request to the CA.
The certificate is usually suffixed with. crt, indicating the Certificate file.
CA (Certifying Authority) indicates the certificate Authority. It is responsible for proving that the public key belongs to an individual, company, or other organization.
1. Create a self-signed certificate
Use make-ssl-cert to create a self-signed certificate
If this tool is not installed, run the following command to install it.
Make-ssl-cert can be used to generate a certificate either by default or by template file.
# Generate by defaultMake-ssl-cert generate-default-Snail keoil
Note: by default, the Public Key (certificate) is generated in/etc/ssl/certs/ssl-cert-snakeoil.pem, and the private key is in/etc/ssl/private/ssl-cert-snakeoil.key.
# Generate by template fileMake-ssl-cert/Usr/Share/Ssl-cert/Ssleay. cnf/Etc/Ssl/Private/Apache2.pem |
The certificate generated here adopts the pem format. This pem format file contains the private key and Public Key (certificate.
Note: When you need to enter Common Name (eg, YOUR name), enter YOUR host Name. The Common Name must be consistent with the server name in httpd. conf; otherwise, apache cannot be started. When apache is started, the error message is: RSA server certificate CommonName (CN) 'koda' does NOT match server name !? .
Make-ssl-cert is a command that can only be executed by the root user.
Use the openssl command line to create a self-signed certificate
The certificate generated here also uses the pem format. This pem format file contains the private key and Public Key (certificate. If you use different file names for keyout and out, the files corresponding to keyout and out will respectively store the private key and Public Key (certificate ).
Openssl req-X509 -NewkeyRsa:1024 -Keyout /Etc/Ssl/Private/Apache. pem-Out /Etc/Ssl/Private/Apache. pem-Nodes -Days 999Writing new private key'/Etc/ssl/private/apache. pem'-----You are about to be asked to enter information that will be inreceivatedinto your certificate request. what you are about to enter is what is called a Distinguished Name or a DN. there are quite a few fields but you can leave some blankFor some fields there will be a default value, If you enter'.', The field will be left blank.-----Country Name(2Letter code) [AU]: CN # enter the country code State or Province Name(Full name) [Some-State]: CHONGQING Province: Enter the province Name Locality Name(Eg, city) []: CHONGQING login enter the city Name Organization Name(Eg, company) [Internet Widgits Pty Ltd]: MIKE Smith enters the company Name Organizational Unit Name(Eg, section) []: MIKE Xiaoming: Enter the organization unit Name Common Name(Eg, YOUR name) []: Www. mike. me hosts enter the host name Email Address[]: Easylife206@Gmail.com enter the email address |
Note: When you need to enter Common Name (eg, YOUR name), enter YOUR host Name. The Common Name must be the same as the server name in httpd. conf.
2. Make a Certificate signed by CA (Certificate Authority ).
Step 1. Generate a private key
openssl genrsa -des3 1024 >server.key |
Note: DES3 is used to encrypt the newly generated private key server. key File. each time you use this private key, you must enter a password. If your e-certificate is used on servers such as apache, you must enter a password each time you start the server.
openssl genrsa 1024 >server.key |
Note: The 128-bit rsa algorithm is used to generate the key server. key file. The certificate generated by this method does not require a password when the server is started in apache or other servers, and the private key is not encrypted.
Step 2: generate a Certificate Request file (Certificate Signing Request)
openssl req -new -key server.key > server.csr |
Note: This is to use the key of step 1 to generate the certificate request file server. csr. The input content in this step is similar to the content used to create the self-signed certificate. You can enter the content as required.
Step 3: sign and generate the certificate
You only need to send the server. csr file to a third-party CA (Certificate Authority) to sign and generate a Certificate.