https

简介:

########https#######

 

1.https定义

Hyper text transfer protocol over Secure socker layer

通过ssl

 

如果加密的通信非常重要,而经过验证的身份不重要,管理员可以通过生成self-

signed certificate来避免与认证机构进行交互所带来的复杂性。

使用genkey实用程序(通过crypto-utils软件包分发),生成自签名证书及其关联的

私钥。为了简化起见,genkey将在“正确”的位置(/etc/pki/tls目录)创建证书及其

关联的密钥。相应地,必须以授权用户(root)身份运行该实用程序。

wKioL1kbwAXjPKjtAACRN-gXxzc416.png-wh_50 


2.配置

yum install mod_ssl -y

yum install crypto-utils -y

genkey www.westos.com

[root@localhost virtual]# genkey www.westos.com    ##配置钥匙

wKiom1kbvxPz4VLoAADsRuedZDQ512.png-wh_50

wKioL1kbvxPRxo72AAEMkbtkpbY408.png-wh_50

wKiom1kbvxTgxpayAADNOU3pFec009.png-wh_50

wKioL1kbvxSSCj5oAAFN_EnP6VI121.png-wh_50

wKioL1kbvxXR35rNAAGkJIa9YY0921.png-wh_50



@@@@@@@

/usr/bin/keyutil -c makecert -g 1024 -s "CN=www.westos.com, OU=linux, O=westos, L=xi'an, ST=shannxi, C=CN" -v 1 -a -z /etc/pki/tls/.rand.6165 -o /etc/pki/tls/certs/www.westos.com.crt -k /etc/pki/tls/private/www.westos.com.key

cmdstr: makecert

 

cmd_CreateNewCert

command:  makecert

keysize = 1024 bits

subject = CN=www.westos.com, OU=linux, O=westos, L=xi'an, ST=shannxi, C=CN

valid for 1 months

random seed from /etc/pki/tls/.rand.6165

output will be written to /etc/pki/tls/certs/www.westos.com.crt

output key written to /etc/pki/tls/private/www.westos.com.key

 

 

Generating key. This may take a few moments...

 

Made a key

Opened tmprequest for writing

/usr/bin/keyutil Copying the cert pointer

Created a certificate

Wrote 882 bytes of encoded data to /etc/pki/tls/private/www.westos.com.key

Wrote the key to:

/etc/pki/tls/private/www.westos.com.key

@@@@@@@@

 

/etc/pki/tls/private/www.westos.com.key

/etc/pki/tls/certs/www.westos.com.crt

vim /etc/httpd/conf.d/login.conf

 

[root@localhost conf.d]# ls

autoindex.conf  login.conf  php.conf  squid.conf  userdir.conf

default.conf    news.conf   README    ssl.conf    welcome.conf

[root@localhost conf.d]# vim ssl.conf   ##添加加密字符文件

@@@@@@

# pass phrase.  Note that a kill -HUP will prompt again.  A new

# certificate can be generated using the genkey(1) command.

SSLCertificateFile /etc/pki/tls/certs/www.westos.com.crt

 

#   Server Private Key:

#   If the key is not combined with the certificate, use this

#   directive to point at the key file.  Keep in mind that if

#   you've both a RSA and a DSA private key you can configure

#   both in parallel (to also allow the use of DSA ciphers, etc.)

SSLCertificateKeyFile /etc/pki/tls/private/www.westos.com.key

 

#   Server Certificate Chain:

#   Point SSLCertificateChainFile at a file containing the

#   concatenation of PEM encoded CA certificates which form the

#   certificate chain for the server certificate. Alternatively

@@@@@@@

 

[root@localhost conf.d]# vim login.conf

<Virtualhost *:443>

ServerName "login.westos.com"

DocumentRoot "/var/www/virtual/login.westos.com/html"

CustomLog "logs/login.log" combined

SSLEngine on     ##开启https功能

SSLCertificateFile /etc/pki/tls/certs/www.westos.com.crt   ##证书

SSLCertificateKeyFile /etc/pki/tls/private/www.westos.com.key  ##密钥

</Virtualhost>

<Directory "/var/www/virtual/login.westos.com/html">

Require all granted

</Directory>

</Virtualhost *:80>     ##网页重写实现自动访问(把所有80端口的请求全部重定向由https来处理)

ServerName login.westos.com

RewriteEngine on

RewriteRule ^(/.*)$ https://%{HTTP_HOST}$1 [redirect=301]

</Virtualhost>

 

^(/.*)$ http://%{HTTP_HOST}$1 [redirect=301]

^(/.*)$   ##客户主机在地址栏中写入的所有字符,除过换行符

http://   ##定向成为的访问协议

%{HTTP_HOST}   ##客户请求主机

$1##$1的值就表示^(/.*)$ 的值

[redirect=301]  ##临时重定向    302表示永久定向

 

 

mkdir /var/www/virtual/login.westos.com/html -p

vim /var/www/virtual/login.westos.com/html/index.html

 

systemctl restart httpd

 

测试:

在客户主机中添加解析

172.25.254.113 login.westos.com

 

 

访问http://login.westos.com 会实现自动调转

https://login.westos.com 实现网页数据加密传送


本文转自 AELY木 51CTO博客,原文链接:http://blog.51cto.com/12768057/1926547,如需转载请自行联系原作者

相关文章
|
6月前
|
安全 数据安全/隐私保护
HTTPS
HTTPS
75 0
|
3月前
|
安全 Java 网络安全
https:邮递员
https:邮递员
19 3
|
9月前
|
安全 算法 网络协议
HTTPS在什么场景是不安全的?
HTTPS在什么场景是不安全的?
107 1
|
11月前
|
安全 网络协议 网络安全
HTTPS中的S是什么?
使用浏览器输入网址的时候,我们通常都会输入“http://”或者“https://”这样的开头(当然,更多情况下可能大家会输入www),然后才输入对应的域名地址,那这里肯定就会有不少的网友疑惑,为什么有些地址会在前面加多一个“s”呢?那么多出的“s”是什么呢?
190 0
HTTPS中的S是什么?
|
安全 算法 网络协议
|
Web App开发 缓存 算法
WHY |HTTPS 为什么是安全的 ? (下)
WHY |HTTPS 为什么是安全的 ? (下)
WHY |HTTPS 为什么是安全的 ? (下)
|
算法 安全 网络协议
浅谈HTTPS🔐
浅谈HTTPS🔐
217 0
浅谈HTTPS🔐
|
Web App开发 安全 算法
Why | Https 为什么是安全的?(上)
Why | Https 为什么是安全的?(上)
Why | Https 为什么是安全的?(上)
|
存储 开发框架 安全
2020年了,再不会Https就老了
合格的web后端程序员,除搬砖技能,还必须会给各种web服务器启用Https,本文结合ASP.NET Core部署模型聊一聊启用Https的方式。
2020年了,再不会Https就老了
|
算法 安全 网络协议
HTTPS介绍
HTTPS (全称:Hyper Text Transfer Protocol over SecureSocket Layer),是以安全为目标的 HTTP 通道,在HTTP的基础上通过传输加密和身份认证保证了传输过程的安全性 。HTTPS 在HTTP 的基础下加入SSL,HTTPS 的安全基础是 SSL,因此加密的详细内容就需要 SSL。 HTTPS 存在不同于 HTTP 的默认端口及一个加密/身份验证层(在 HTTP与 TCP 之间)。这个系统提供了身份验证与加密通讯方法。它被广泛用于万维网上安全敏感的通讯。
HTTPS介绍