基于openssl的https服务的配置

openssl实现私有CA,并配置基于openssl的https服务的配置,原理如下图

在CA服务器上实现私有CA步骤如下;

1、生成一对密钥

2.生成自签证书

基本的配置如下代码;

[[email protected] CA]# pwd
/etc/pki/CA
[[email protected] CA]# (umask 077;openssl genrsa -out private/cakey.pem 2048)
[[email protected] CA]# openssl req -new -x509 -key private/cakey.pem -out cacert.pem
You are about to be asked to enter information that will be incorporated
into 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 blank
For some fields there will be a default value,
If you enter ‘.‘, the field will be left blank.
-----
Country Name (2 letter code) [CN]:
State or Province Name (full name) [NEIMENGGU]:
Locality Name (eg, city) [Huhhot]:
Organization Name (eg, company) [EDU]:
Organizational Unit Name (eg, section) [Tech]:
Common Name (eg, your name or your server‘s hostname) []:ca.edu.cn
Email Address []:[email protected]
[[email protected] CA]# touch index.txt
[[email protected] CA]# touch serial
[[email protected] CA]# echo 01 > serial 
[[email protected] CA]# ls
cacert.pem  certs  crl  index.txt  newcerts  private  serial

webserver服务器上的证书生成步骤;

[[email protected] ~]# cd /etc/httpd/
[[email protected] httpd]# mkdir ssl
[[email protected] httpd]# cd ssl/
[[email protected] ssl]# pwd
/etc/httpd/ssl
[[email protected] ssl]# (umask 077; openssl genrsa -out httpd.key 1024)
Generating RSA private key, 1024 bit long modulus
..........................++++++
.......++++++
e is 65537 (0x10001)
[[email protected] ssl]# ll
total 4
-rw-------. 1 root root 887 Aug  6 23:46 httpd.key

webserver生成证书签署请求;

[[email protected] ssl]# openssl req -new -key httpd.key -out httpd.csr
You are about to be asked to enter information that will be incorporated
into 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 blank
For some fields there will be a default value,
If you enter ‘.‘, the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:NEIMENGGU
Locality Name (eg, city) [Default City]:Huhhot
Organization Name (eg, company) [Default Company Ltd]:EDU
Organizational Unit Name (eg, section) []:Tech
Common Name (eg, your name or your server‘s hostname) []:www.edu.cn
Email Address []:
Please enter the following ‘extra‘ attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:

将申请证书发送打CA服务器上,让CA服务器来完成证书的签署

[[email protected] CA]# scp [email protected]:/etc/httpd/ssl/httpd.csr ./certs/
[email protected]‘s password: 
httpd.csr                                 100%  647     0.6KB/s   00:00    
[[email protected] CA]# ll ./certs/
total 4
-rw-r--r-- 1 root root 647 Aug  5 21:39 httpd.csr

CA服务器来完成证书的签署

[[email protected] CA]# openssl ca -in ./certs/httpd.csr -out ./certs/httpd.crt -days 365
Using configuration from /etc/pki/tls/openssl.cnf
Check that the request matches the signature
Signature ok
Certificate Details:
        Serial Number: 1 (0x1)
        Validity
            Not Before: Aug  5 13:45:06 2016 GMT
            Not After : Aug  5 13:45:06 2017 GMT
        Subject:
            countryName               = CN
            stateOrProvinceName       = NEIMENGGU
            organizationName          = EDU
            organizationalUnitName    = Tech
            commonName                = www.edu.cn
        X509v3 extensions:
            X509v3 Basic Constraints: 
                CA:FALSE
            Netscape Comment: 
                OpenSSL Generated Certificate
            X509v3 Subject Key Identifier: 
                12:2C:ED:3F:F1:FA:54:FB:71:03:79:03:81:77:2D:A6:33:EF:8E:8F
            X509v3 Authority Key Identifier: 
                keyid:1B:1E:92:D1:DD:79:A6:68:19:91:5F:08:04:FF:7C:25:73:E4:BC:82
Certificate is to be certified until Aug  5 13:45:06 2017 GMT (365 days)
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
[[email protected] CA]# ll ./certs/
total 4
-rw-r--r-- 1 root root   0 Aug  5 21:43 httpd.crt
-rw-r--r-- 1 root root 647 Aug  5 21:39 httpd.csr

将证书文件发送给请求端;

[[email protected] CA]# scp ./certs/httpd.crt [email protected]:/etc/httpd/ssl/
[email protected]‘s password: 
httpd.crt                                 100% 3754     3.7KB/s   00:00

在webserver服务器上安装支持ssl的模块;

# yum install -y mod_ssl

配置ssl.conf配置文件,修改如下行;

[[email protected] ssl]# vim /etc/httpd/conf.d/ssl.conf 
107 SSLCertificateFile /etc/httpd/ssl/httpd.crt
114 SSLCertificateKeyFile /etc/httpd/ssl/httpd.key

启动apache服务

[[email protected] ssl]

在windows客户端通过如下方式安装信任CA证书颁发机构;

将CA服务器上的cakey.pem文件下载到windows客户端上,修改文件名后缀为crt(cakey.crt),双击此文件,安装信任该证书颁发机构,具体步骤;

安装证书-->下一步-->选择将证书放入下列存储-->浏览-->选择受信任的根证书颁发机构-->完成;

通过web页面访问,效果如下;

部署完成。

时间: 2024-08-03 10:31:34

基于openssl的https服务的配置的相关文章

基于openssl搭建https服务

多种应用层协议,例如http,ftp,smtp等都是明文协议,而这些服务在互联网通信中是不可或缺的,而有时安全显得特别重要,例如网购的时候,所以出现了ssl/tls的技术,那么现在就来实现以下基于ssl搭建https服务 查看当前httpd服务器是否安装了mod_ssl模块 httpd -M 一般在使用rpm包安装的时候,不会安装该模块,在编译安装httpd的时候,在./configure --enable-ssl编译该模块 如果单独使用rpm安装mod_ssl,可以看到安装这个模块生成的文件

基于openssl 的https服务配置

1.安装mod_ssl 2.在另一台机器上创建CA cd /etc/pki/CA (umask 077; openssl genrsa -out private/cakey.pem 2048) 3.生成文件的权限是600 4.vim  ../tls/openssl.cnf 5.找到 [ req_distinguished_name ] 6.将默认城市改成CN 7.将默认省份名称stateOrProvinceName_default 改为Hebei 8.城市名称 localityName_defa

基于openssl的https服务配置

1.安装模块 [[email protected] yum.repos.d]# yum -y install mod_ssl [[email protected] yum.repos.d]# rpm -ql mod_ssl /etc/httpd/conf.d/ssl.conf 配置文件 /usr/lib/httpd/modules/mod_ssl.so /var/cache/mod_ssl /var/cache/mod_ssl/scache.dir /var/cache/mod_ssl/scac

如何实现基于lamp搭建https服务

如何实现基于lamp搭建https服务 lamp:服务架构 httpd:接收用户的web请求:静态资源则直接响应:动态资源为php脚本,对此类资源的请求将交由php来运行: php:运行php程序: MariaDB:数据管理系统: (一):  安装其相关服务 CentOS 6: httpd, php, mysql-server, php-mysql # service httpd  start # service  mysqld  start CentOS 7: httpd, php, php-

Nginx + openssl 搭建https服务

近期忙着和第三方短信公司对接短信上行接口.给予https和digest认证方式进行数据的传输.digest认证由前端phper进行实现,我需要完成nginx+ssl实现https服务.ssl使用openssl自己进行制作. SSL原理: 给予SSL原理知识,在这里不再过多阐述.想详细了解,可以猛戳此链接进行查看:http://www.fenesky.com/blog/2014/07/19/how-https-works.html 1.首先要生成服务器的私钥:    运行时会提示输入密码,此密码用

漫漫运维路——各种加密方式介绍及基于OpenSSL实现HTTPS

一.为什么要加密 在网络中通信有时通信双方会发送一些比较敏感的信息,如果直接明文在网上传输,就可能被居心叵测的人截获,从而达到其非法的目的.为保证通信双方信息传输不被第三方所知晓,使用加密技术把双方传输的数据进行加密,即使数据被第三方所截获,那么第三方也不会知晓其数据的真实含义.在此,通信双方所交换的信息中,未被加密的数据称为明文,而加密后的数据称为密文,加密采用的方式称作加密密钥. 二.常见加密方式以及其用途 对称加密 对称加密是指在加密通信过程中,把明文加密为密文的密钥和把密文解密为明文的密

Nginx详解二十一:Nginx深度学习篇之配置苹果要求的openssl后台HTTPS服务

配置苹果要求的证书: 1.服务器所有的连接使用TLS1.2以上的版本(openssl 1.0.2) 2.HTTPS证书必须使用SHA256以上哈希算法签名 3.HTTPS证书必须使用RSA2048位或ECC256位以上公钥算法 4.使用前向加密技术 首先看openssl版本:openssl version,为1.0.1,需要升级 查看当前使用的自签算法类型:openssl x509 -noout -text -in ./jesonc.crt,使用的是sha1,位数是1024位,都不符合规定 升级

基于openssl实现https访问

1.说明 部署之前,先举例说明一下,方便理解. 比如我想去租房子,于是便在某网站上搜寻,结果联系的时候发现好多都是假的. 有看上的房子吧,又担心房东是个骗子.这个时候,我为了租房,找到了一家房屋中介公司,虽然收费,但是可以放心的租到房子. 2.部署 CA server: 192.168.1.10 http server: 192.168.1.200 2-1)在CA上生成自签证 cacert.pem 切换到CA server: 192.168.1.10 2-1-1)创建私钥 #(umask 077

httpd服务详解及基于openssl的使用

httpd常见特性 1.事先创建空闲进程. 2.按需维持适当的进程. 3.使用模块化设计,核心比较小,各种功能都以模块方式添加. 4.支持运行时配置,支持单独编译模块. 5.支持多种方式的虚拟主机配置. 6.支持https协议,通过mod_ssl模块实现. 7.支持用户认证 8.支持基于IP或主机名的ACL 9.支持基于每目录的访问控制. 10.支持URL重写. MPM(Mulit Path Modules)多道处理模块. mpm_winnt windows上专用的线程处理机制. perfork