To build a simple HTTPS

Source: Internet
Author: User

Building a simple HTTPS requires three servers to do the experiment:

CA : Centos7

Web Server: CENTOS6

Client

a , Configuration CA ( Centos7 )

1 , in /etc/pki/ca/ two files are created below

echo >/etc/pki/ca/serial (Generate serial number)

Touch/etc/pki/ca/index.txt

2 , create a private key

(Umask 066;openssl genrsa-out private/cakey.pem 4096)

the file that generates the private key must be placed in the /etc/pki/ca/private/cakey.pem

3 , generate a self-signed certificate

OpenSSL req-new-x509-key private/cakey.pem-out cacert.pem-days 3650

650) this.width=650; "src=" https://s5.51cto.com/oss/201710/22/d7ec46f54f6138bd75b858cd72c770a7.jpg "title=" 1.jpg " alt= "D7ec46f54f6138bd75b858cd72c770a7.jpg"/>

4 , give CENTOS6 Certificate Signing

OpenSSL ca-in httpd.csr-out certs/httpd.crt-days 300

650) this.width=650; "src=" https://s4.51cto.com/oss/201710/22/00f2b9e61313fbc7a68fd382d2b05292.jpg "title=" 1.jpg " alt= "00f2b9e61313fbc7a68fd382d2b05292.jpg"/>

5 , and then send the signed certificate to Web on the server

SCP CERTS/HTTPD.CRT 172.17.166.166:/etc/httpd//conf.d/ssl/

6 , sending your own public key to the Web on the server

SCP Cacert.pem 172.17.166.166:/etc/httpd//conf.d/ssl/

II web centos6

1 , installation Mod_ssl Package

Yum Install Mod_ssl

This package is installed with the certificate already generated because the installation Mod_ssl A script was executed when the . With rpm-q--scripts mod_ssl You can view the script:

650) this.width=650; "src=" https://s1.51cto.com/oss/201710/22/403eb5cdc54b241e0a020906308ef0dd.jpg "title=" 1.jpg " alt= "403eb5cdc54b241e0a020906308ef0dd.jpg"/>

2 , create a private key:

Mkdir/etc/httpd/conf.d/ssl

(Umask 066;openssl Genrsa-out/etc/httpd/conf.d/ssl/httpd.key 2048)

3 , generate certificates

OpenSSL REQ-NEW-KEY/ETC/HTTPD/CONF.D/SSL/HTTPD.KEY-OUT/ETC/HTTPD/CONF.D/SSL/HTTPD.CSR

650) this.width=650; "src=" https://s3.51cto.com/oss/201710/22/f92c4fa7d006c15bf46aeff9d5dd49f5.jpg "title=" 1.jpg " alt= "F92c4fa7d006c15bf46aeff9d5dd49f5.jpg"/>

the generated certificate has 3 item must be associated with CA generate self-signed certificates as

( 1 ) Country Name (2 letter code) [XX]:CN

( 2 ) State or province name (full name) []:henan

( 3 ) Organization Name (eg, company) [Default company Ltd]:magedu.com

4 , passing the generated certificate to CA

SCP/ETC/HTTPD/CONF.D/SSL/HTTPD.CSR 172.17.177.177:/etc/pki/ca/

5 , Configuration HTTPS master configuration file: /etc/httpd/conf.d/ssl.conf

650) this.width=650; "src=" https://s3.51cto.com/oss/201710/22/58c62b87ea3e5f616b6e14bd124960dc.jpg "title=" 1.jpg " alt= "58c62b87ea3e5f616b6e14bd124960dc.jpg"/>

And also

650) this.width=650; "src=" https://s4.51cto.com/oss/201710/22/e4a43caf8bb5d4ff730019a43b62bac4.jpg "title=" 1.jpg " alt= "E4a43caf8bb5d4ff730019a43b62bac4.jpg"/>

Change the path of the parent certificate

Change three paths, others can not be adjusted

Third, visit Web Server

1 , with CentOS to visit

650) this.width=650; "src=" https://s3.51cto.com/oss/201710/22/6605db72fba925367adddeea5ad07b50.jpg "title=" 1.jpg " alt= "6605db72fba925367adddeea5ad07b50.jpg"/>

2 , with Windows to visit https:/172.17.166.166

650) this.width=650; "src=" https://s5.51cto.com/oss/201710/22/c75395d1f4f0f61b22abfd85be88e0c9.jpg "title=" 1.jpg " alt= "C75395d1f4f0f61b22abfd85be88e0c9.jpg"/>

View Certificate at this time

650) this.width=650; "src=" Https://s2.51cto.com/oss/201710/22/01e18da58bd37275412ca8d5d2f52174.png "title=" 1.png " alt= "01e18da58bd37275412ca8d5d2f52174.png"/>

Ability to view superior certificates and their own certificates

If you want to trust its certificate, you need to install a higher certificate:

650) this.width=650; "src=" Https://s5.51cto.com/oss/201710/22/6e8ae6702d3d0090e05afc01cf4b1446.png "title=" 1.png " alt= "6e8ae6702d3d0090e05afc01cf4b1446.png"/>

and then in /windows/system32/drivers/etc/hosts You can add a record to the

172.17.166.166 www.magedu.com

Access after adding https://magedu.com you'll have direct access to the ( because the certificate only authenticates the domain name, the IP address is not authenticated )

650) this.width=650; "src=" Https://s3.51cto.com/oss/201710/22/781072decf8d38a4842aebce8d1c5e11.png "title=" 1.png " alt= "781072decf8d38a4842aebce8d1c5e11.png"/>

Such a simple HTTPS is constructed


Build a simple HTTPS

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.