温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

利用openssl签署多域名证书

发布时间:2020-07-06 08:44:27 来源:网络 阅读:20102 作者:colinzhouyj 栏目:安全技术

    openssl自建CA默认签署的是单域名证书,因为单台服务器上有多个https域名,签署多域名证书能方便很多,今天找了很久,除了一些卖证书的网站上有scr工具能加“使用者备用名称”,都没有找到openssl相关的添加方法。

    后来看openssl.cnf找到一个方法,这里记录一下:

    !!这个方法比较笨重,如果有其他方法,欢迎留言给我,感激不尽。

    (已找到,详见使用openssl为ssl证书增加“使用者备用名称(DNS)”)

    主要修改在openssl.cnf

        将文件中原来的

commonName                    = Common Name (eg, your name or your server\'s hostname)

commonName_max                = 64

修改为

0.commonName                    = Common Name (eg, your name or your server\'s hostname)
0.commonName_max                = 64

就是在前面加了个 “0.”,好了,如果要添加其他域名,只需要再增加相同的记录,前面的序号依次递增即可:

0.commonName                    = Common Name (eg, your name or your server\'s hostname)
0.commonName_max                = 64
1.commonName                    = other  Common Name

1.commonNAme_max                = 64

......


其他的步骤:

openssl.cnf中会要求部分文件及目录存在:

[root@localhost]#mkdir -p CA/{certs,crl,newcerts,private}

[root@localhost]# touch CA/index.txt

[root@localhost]#echo 00 > CA/serial


1.生成ca.key并自签署

openssl req -new -x509 -days 3650 -keyout ca.key -out ca.crt -config openssl.cnf


2.生成server.key(名字不重要)

openssl genrsa -out server.key 2048

3.生成证书签名请求
openssl req -new -key server.key -out server.csr -config openssl.cnf

Common Name 就是在这一步填写的,每次一个,如果没有那么多,可以直接回车


4.使用自签署的CA,签署server.scr

openssl ca -in server.csr -out server.crt -cert ca.crt -keyfile ca.key -config openssl.cnf
#输入第一步设置的密码,一直按y就可以了


server.crt server.key就是web服务器中使用的文件。


NGINX 双向认证

如果要做NGINX客户端证书验证的话,重复2、3、4,并执行下面命令生成个人证书

openssl  pkcs12 -export -inkey server.key -in server.crt -out  server.p12

将个人证书导入pc,同时在nginx ssl基础上增加设置:

ssl_verify_client on;
ssl_client_certificate ca.crt;


另外:nginx的双向认证是相对独立的,你可以在验证server端用你购买的ssl证书,然后在验证客户端用自签名的ca和证书。

附件:http://down.51cto.com/data/2364956
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI