Using OpenSSL to generate certificates under Linux

Source: Internet
Author: User
Tags openssl openssl rsa

Using OpenSSL to generate the Library and command program, in the generated command program includes the addition/decryption algorithm test, OpenSSL program, CA program. Use OPENSSL,CA to generate certificate files and CA files for the C/s mode.

Reference: http://blog.chinaunix.net/uid-26760055-id-3128132.html

Steps to build the certificate file:

One, server-side
1. Generate the server-side private key (key file);

OpenSSL genrsa-des3-out Server.key 1024

The runtime prompts for a password, which is used to encrypt the key file (the parameter des3 is an encryption algorithm or other secure algorithm), and you will need to enter the password whenever you need to read the file (via the command or API provided by OpenSSL). If you do not have a password, you can use the following command to remove the password:

OpenSSL rsa-in server.key-out Server.key

2. Generate server-side certificate signing request file (CSR file);

OpenSSL Req-new-key server.key-out SERVER.CSR

Generate Certificate Signing request (CSR), the generated CSR file is handed to the CA to form the service side's own certificate. The screen will prompt you to enter the required personal information in step-by-steps, such as: Country,province, City,company, etc.).

Second, the client
1. The client also makes the same command to generate key and CSR files;

OpenSSL genrsa-des3-out client.key 1024x768OpenSSL req-new-key client.key-out CLIENT.CSR

Iii. Generating CA certificate files
SERVER.CSR and CLIENT.CSR files must be signed by a CA to form a certificate.

1. First generate the CA's key file:

OpenSSL genrsa-des3-out Ca.key 1024

2. Generate the CA self-signed certificate:

OpenSSL Req-new-x509-key ca.key-out ca.crt

You can add the certificate Expiration Time option "-days 365".


Iv. signing with a CA certificate
Sign the SERVER.CSR,CLIENT.CSR file with the generated CA certificate, taking advantage of the ca.pl file included with OpenSSL

1. When prompted to enter the existing certificate file, enter the above generated CA.CRT certificate file;

Ca.pl–newca


2. Generate a server-side certificate file

OpenSSL ca-in server.csr-out server.crt-cert ca.crt-keyfile ca.key-config openssl.cnf

3. Generating the client certificate file

OpenSSL ca-in client.csr-out client.crt-cert ca.crt-keyfile ca.key-config openssl.cnf

OPENSSL.CNF must be guaranteed in the current directory, this file can be found in the Apps directory.

V. Errors that may occur

Error 1:

Error loading the config file ' openssl.cnf '

Workaround

Find. -name "openssl.c*"cp/usr/local/ssl/openssl.cnf.

Error 2:

Workaround

"XX" > Democa/serial

Using OpenSSL to generate certificates under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.