自建 ca 及使用 ca 颁发证书
创建CA:
一、安装openssl
[root@localhost ~]# yum install -y openssl
二、创建CA的相关文件及目录
mkdir /opt/root_ca &&\
cd root_ca &&\
mkdir newcerts private crl &&\
touch index.txt &&\
touch serial &&\
echo >serial &&\
说明:
#newcerts目录用于存放CA签署(颁发)过的数字证书(证书备份目录)。
#private目录用于存放CA的私钥。
#文件serial和index.txt分别用于存放下一个证书的序列号和证书信息数据库。
#文件serial填写第一个证书序列号(如10000001),之后每前一张证书,序列号自动加1。
三、修改openssl配置文件
vim /etc/pki/tls/openssl.cnf [ CA_default ]
dir = /opt/root_ca [ policy_match ]
countryName = match
stateOrProvinceName = optional
organizationName = optional
organizationalUnitName = optional
commonName = supplied
emailAddress = optional
说明:
match 表示严格校验国家名称
optional 表示可选
这个“匹配”指的是在颁发证书的时候,检查请求中的信息是否和根证书中所对应的信息匹配;
加粗的部分为需要修改的配置,具体配置根据实际情况修改
四、生成CA私钥
[root@localhost root_ca] openssl genrsa -out private/ca.key
Generating RSA private key, bit long modulus
..................+++
...............................+++
e is (0x10001)
五、使用私钥生成CA请求信息
[root@localhost root_ca]# openssl req -new -key private/ca.key -out ca.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 ( letter code) [XX]:CN
State or Province Name (full name) []:BJ
Locality Name (eg, city) [Default City]:BJ
Organization Name (eg, company) [Default Company Ltd]:ESTREND
Organizational Unit Name (eg, section) []:IT
Common Name (eg, your name or your server's hostname) []:www.estrend.com
Email Address []:admin@estrend.com Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
六、使用CA私钥和证书请求,生成CA根证书
[root@localhost root_ca]# openssl x509 -req -days -in ca.csr -signkey private/ca.key -out ca.crt
Signature ok
subject=/C=CN/ST=BJ/L=BJ/O=ESTREND/OU=IT/CN=www.estrend.com/emailAddress=admin@estrend.com
Getting Private key
颁发证书:
一、生成私钥
[root@localhost s1]# openssl genrsa -out server.key
Generating RSA private key, bit long modulus
..................+++
...............................+++
e is (0x10001)
二、生成请求
[root@localhost server]# openssl req -new -key server.key -out server.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 ( letter code) [XX]:CN
State or Province Name (full name) []:BJ
Locality Name (eg, city) [Default City]:BJ
Organization Name (eg, company) [Default Company Ltd]:ESTREND
Organizational Unit Name (eg, section) []:IT
Common Name (eg, your name or your server's hostname) []:www.123.com
Email Address []:admin@.com Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
三、颁发证书
[root@localhost server]# openssl ca -in server.csr -cert /opt/root_ca/ca.crt -keyfile /opt/root_ca/private/ca.key -out server.crt -days
Using configuration from /etc/pki/tls/openssl.cnf
Check that the request matches the signature
Signature ok
Certificate Details:
Serial Number: (0x1)
Validity
Not Before: May :: GMT
Not After : May :: GMT
Subject:
countryName = CN
stateOrProvinceName = BJ
organizationName = ESTREND
organizationalUnitName = IT
commonName = www..com
emailAddress = admin@.com
X509v3 extensions:
X509v3 Basic Constraints:
CA:FALSE
Netscape Comment:
OpenSSL Generated Certificate
X509v3 Subject Key Identifier:
EA:DB:4B:E6::C6:::::EA:C2:7B:D5:::FB:::D4
X509v3 Authority Key Identifier:
DirName:/C=CN/ST=BJ/L=BJ/O=ESTREND/OU=IT/CN=www.estrend.com/emailAddress=admin@estrend.com
serial:B8:7C:0A:A8:8D:2E:AF: Certificate is to be certified until May :: GMT ( days)
Sign the certificate? [y/n]:y
out of certificate requests certified, commit? [y/n]y
Write out database with new entries
Data Base Updated
自建 ca 及使用 ca 颁发证书的更多相关文章
- 十二张图:从0开始理解对称/非对称加密、CA认证、以及K8S各组件颁发证书原由
目录 一.对称加密 二.对称加密-不安全 三.非对称加密 四.非对称加密-不安全 五.对称加密和非对称加密结合 六.对称加密和非对称加密结合-不安全 七.Https的做法-引入CA机构 八.乘胜追击理 ...
- 数字证书的理解以及自建CA机构颁发证书
一.理解什么是数字证书 http://www.cnblogs.com/JeffreySun/archive/2010/06/24/1627247.html 理解数字证书等概念,无数次想好好看 ...
- OpenSSL - 利用OpenSSL自签证书和CA颁发证书
秘钥操作 这个命令会生成一个1024/2048位的密钥,包含私钥和公钥. openssl genrsa -out private.key 1024/2038 ( ...
- 自己搭建CA颁发证书做https加密网站
192.168.10.187 CA服务器 192.168.10.190 web服务器 (1)搭建CA cd /etc/pki/CA 在这个目录下创建serial和index.txt两个文件 echo ...
- 使用OpenSsl自己CA根证书,二级根证书和颁发证书(亲测步骤)
---恢复内容开始--- 一.介绍 企业自用, 到证书机构签发证书的费用和时间等都可以省下..... SSl证书的背景功用.......(省略万字,不废话) 可以参考: SSL证书_百度百科 X509 ...
- 搭建CA颁发证书做https加密网站
92.168.10.187 CA服务器 192.168.10.190 web服务器 (1)搭建CA cd /etc/pki/CA 在这个目录下创建serial和index.txt两个文件 echo 0 ...
- CA证书、自颁发证书、自签名证书联系
一.理论基础 ssl:secure socket layer(安全套接层协议)的缩写,通过此协议可以保证两个应用通信的可靠性和保密性.openssl:是ssl协议的实现.提供了对称加密算法.非对称加密 ...
- 使用keytool工具产生带根CA和二级CA的用户证书
使用keytool工具产生带根CA和二级CA的用户证书 1 生成根CA 1.1 生成根CA证书 根CA实际是一张自签CA,自签CA的使用者和颁发者都是它自己.使用下面的命令生成根证书,如果没有指定 ...
- k8s基于CA签名的双向数字证书认证(三)
1.设置kube-apiserver的CA证书相关的文件和启动参数 1)创建CA证书和私钥相关的文件 openssl genrsa -out ca.key openssl req -x509 -n ...
随机推荐
- GIT VI操作汇总
在Git Bash Here中用命令行 pull\push\merge 代码,如果存在冲突或者自动合并时,会自动进入VI界面 1.按下 ESC 键,退出编辑模式,切换到命令模式. 2.输入 :wq , ...
- GitLab CI/CD的官译【原】
CI / CD方法简介 软件开发的持续集成基于自动执行脚本,以最大限度地减少在开发应用程序时引入错误的可能性.从新代码的开发到部署,它们需要较少的人为干预甚至根本不需要干预. 它涉及在每次小迭代中不断 ...
- vs2019 netocore项目本地程序ip地址访问需修改的配置文件
IISPress启动项目后,打开IISPress托盘可以看到当前项目 根据图中标识出来的applicationhost.config文件路径,一般为你的项目解决方案目录下的.vs\解决方案文件夹\co ...
- final,finally,finalize之间的区别。
fianl:可以修饰类.变量.方法.修饰类不能被继承,修饰变量只能赋值一次,修饰方法不能被重写. finally是try语句体中的一个语句体,不能单独使用,用来释放资源. finalize()是在ja ...
- C# 从注册表判断指定ocx控件是否已注册 以及获取它的注册路径
/// <summary> /// 注册控件 /// </summary> /// <returns></returns> public bool Re ...
- Js中级复习
JS中级复习—— 1,this 就是js的关键字 用途:指向某一个对象 如何判断this指向: 函数(方法)内—— 一种以函数的方式调用(不带.)this指向window 一种以方法的形式调用(函 ...
- Ueditor 关于视频上传相关问题
!!!每次改动后记得,清除一下浏览器缓存再试 !!! 4点: 1.修复编辑时视频不能预览问题: 2.插入视频的时候.在预览的窗口提示 “输入的视频地址有误,请检查后再试!” 3.ueditor ...
- Thinkphp5.1允许uni-app的H5跨域请求接口解决方法
情景: uni-app使用vue框架开发混合APP,虽然APP或者小程序没有跨域,但希望就是写完这个既有H5,又有APP,小程序等,所以能通过后端解决跨域最好.但是不知道是vue的原因还是什么,在PH ...
- python的with语法的深入理解
如果你有一些对象(比如一个文件.网络连接或锁),需要支持 with 语句,下面介绍两种定义方法. 方法(1): 首先介绍下with 工作原理 (1)紧跟with后面的语句被求值后,返回对象的“__en ...
- windows创建虚拟环境
mkvirtualenv --no-site-packages --python=C:\Python36\python.exe MyCrawler