OpenSSL generate HTTPS Certificate

Source: Internet
Author: User
Tags mkdir modulus openssl openssl rsa openssl x509 pkcs12


1. First to 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
command to remove key file password:
OpenSSL rsa-in server.key-out Server.key

2. Generate Certificate Signing Request (CSR)

OpenSSL req-new-key server.key-out server.csr-config openssl.cfg

The generated CSR file is signed by the CA and forms the server's own certificate. The screen will be prompted to enter the required personal information step-by-step according to its instructions.

3. The client also makes the same command to generate key and CSR files: OpenSSL genrsa-des3-out client.key 1024
OpenSSL req-new-key client.key-out client.csr-config openssl.cfg

4.CSR files must have a CA's signature to form a certificate. This file can be sent to VeriSign where it is validated. Build yourself: OpenSSL req-new-x509-keyout ca.key-out ca.crt-config Openssl.cfg

5. Sign the SERVER.CSR,CLIENT.CSR file that you just generated with the certificate of the generated CA: Openssl ca-in server.csr-out Server.crt-cert ca.crt-keyfile ca.key-config
Openssl ca-in client.csr-out Client.crt-cert ca.crt-keyfile ca.key-config

PS: such as the report update database error, the index.txt.attr file content update to Unique_subject = no

Note: This error occurs: Using configuration from/usr/share/ssl/openssl.cfg I am unable to access the./democa/newcerts directory./demo Ca/newcerts:no such file or directory
Solution: 1. mkdir-p./democa/newcerts
2). Touch Democa/index.txt
3). Touch democa/serial
4. Echo > Democa/serial 6. Merge certificate file (CRT) and private key file (key)

1). Cat Client.crt Client.key > Client.pem

2. Cat Server.crt server.key > Server.pem 7. To be merged into a PFX certificate

1). OpenSSL pkcs12-export-clcerts-in Client.crt-inkey client.key-out client.p12
2). OpenSSL pkcs12-export-clcerts-in Server.crt-inkey server.key-out server.p12
8. Certificate of text

1). OpenSSL pkcs12-in client.p12-out client.txt

2). OpenSSL pkcs12-in server.p12-out server.txt 9. Screen mode explicit: (certificate, private key, public key)

1). OpenSSL x509-in Client.crt-noout-text-modulus

2). OpenSSL rsa-in Server.key-noout-text-modulus

3). OpenSSL rsa-in server.pub-noout-text-modulus 10. DH

one). OpenSSL dhparam-out Dh1024.pem 1024


(8) Edit Apache configuration file httpd.cfg
Open: LoadModule ssl_module modules/mod_ssl.so
Remove the comment for the following statement, Include Conf/extra/httpd-ssl.cfg
# Secure (SSL/TLS) connections
Include conf/extra/httpd-ssl.cfg
#
(9) Edit conf/extra/httpd-ssl.cfg

<virtualhost *:443>
Sslengine on
Sslcertificatefile CONF/SSL/SERVER.CRT
Sslcertificatekeyfile Conf/ssl/server.key
Sslcertificatechainfile CONF/SSL/CA.CRT
</VirtualHost>

cd/usr/local/apache/conf
OpenSSL genrsa-des3-out server.key 1024
OpenSSL req-new-key server.key-out serv er.csr-config/usr/local/ssl/openssl.cfg 
OpenSSL req-new-x509-keyout ca.key-out ca.crt-config/usr/local/s SL/OPENSSL.CFG&NBSP
Mkdir-p./democa/newcerts 
Touch democa/index.txt
Touch democa/serial
Echo > democa/serial
OpenSSL ca-in server.csr-out server.crt-cert ca.crt-keyfile ca.key-config/usr/local/ssl/op ENSSL.CFG&NBSP
Bin/apachectl Start

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.