搜索
Hi~登录注册
查看: 1448|回复: 0

CentOS openssl 签发证书 -centos教程

[复制链接]

1892

主题

1899

帖子

6406

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
6406
发表于 2015-4-16 16:03:56 | 显示全部楼层 |阅读模式
第一步:先建立一个 CA 的证书,首先为 CA 创建一个 RSA 私用密钥, #cd /etc/pki/CA#openssl genrsa -des3 -out ca.key 1024(由于windows系统下的ssl_module不支持加密密钥,使用openssl genrsa -out ca.key 1024)系统提示输入 PEM pass phrase,也就是密码,输入后牢记它。生成 ca.key 文件,将文件属性改为400。#chmod 400 ca.key你可以用下列命令查看它的内容,#openssl rsa -noout -text -in ca.key利用 CA 的 RSA 密钥创建一个自签署的 CA 证书(X.509结构)#openssl req -new -x509 -days 3650 -key ca.key -out ca.crt然后需要输入下列信息:Country Name: CN //两个字母的国家代号State or Province Name: Guangdong //省份名称Locality Name: Guangzhou //城市名称Organization Name: //公司名称Organizational Unit Name: //部门名称Common Name: //你的姓名Email Address: //Email地址生成 ca.crt 文件,将文件属性改为400。#chmod 400 ca.crt你可以用下列命令查看它的内容,#openssl x509 -noout -text -in ca.crt第二步:下面要创建服务器证书签署请求,#openssl genrsa -des3 -out server.key 1024(同上windows下使用openssl genrsa -out server.key 1024)这里也要设定pass phrase。生成 server.key 文件,将文件属性改为400。#chmod 400 server.key你可以用下列命令查看它的内容,#openssl rsa -noout -text -inserver.key用 server.key 生成证书签署请求 CSR.#openssl req -new -key server.key-out server.csr这里也要输入一些信息,和CA中的内容类似。至于 'extra' attributes 不用输入。“Common Name: Chen Yang 你的姓名”这条信息请你输入你的服务器的域名或者IP地址你可以查看 CSR 的细节#openssl req -noout -text -inserver.csr第三步:下面可以签署证书了#openssl ca -config /etc/pki/tls/openssl.cnf -days 3650 -cert ca.crt -keyfile ca.key -in server.csr -out server.crt注意需要手动创建一个CA目录结构 └─ etc └─ pki └─CA ├─newcerts ├─index.txt ├─serial在CA中建立 index.txt 空文件, serial文件 , serial文件中可输入01否则运行这个命令会出错:I am unable to access the ./CA/newcerts directory....将文件属性改为400,并放在安全的地方。#chmod 400 server.crt第四步:生成客户端证书生成客户私钥: #openssl genrsa -des3 -out client.key 1024生成客户证书 #openssl req -new -key client.key -out client.csr签证: ##openssl ca -config /etc/pki/tls/openssl.cnf -days 3650 -cert ca.crt -keyfile ca.key -in client.csr -out client.crt转换成pkcs12格式,为客户端安装所用 #openssl pkcs12 -export -clcerts -in client.crt -inkey client.key -out client.pfx
公众微信:idc5ahl
公众QQ:吾爱互联
关注公众微信,公众QQ每天领现金卡密
卡密介绍(http://www.5ahl.com/thread-2182-1-1.html
回复

使用道具 举报

游客
回复
您需要登录后才可以回帖 登录 | 点我注册

快速回复 返回顶部 返回列表