centos下https 证书生成及转换方式

1、生成证书文件:

# mkdir cert
# openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout private.key -out public.crt

# ls -ltr
total 10
-rw-r--r-- 1 root root 1220 Mar 23 13:41 public.crt
-rw-r--r-- 1 root root 1704 Mar 23 13:41 private.key

2、将crt证书转换成pem格式:

# openssl x509 -inform PEM -in public.crt > cert.pem
[root@localhost cert]# ls -ltr
total 15
-rw-r--r-- 1 root root 1220 Mar 23 13:41 public.crt
-rw-r--r-- 1 root root 1704 Mar 23 13:41 private.key
-rw-r--r-- 1 root root 1220 Mar 23 13:51 cert.pem

3、将key证书转换成pem格式:

# openssl rsa -in private.key -text > key.pem
writing RSA key
[root@localhost cert]# ll
total 15
-rw-r--r-- 1 root root 5681 Mar 23 13:54 key.pem
-rw-r--r-- 1 root root 1704 Mar 23 13:41 private.key
-rw-r--r-- 1 root root 1220 Mar 23 13:41 public.crt

4、pem证书转换成crt格式:

# openssl x509 -in key.pem -out public.crt

5、pem证书转key格式:

# openssl rsa -in key.pem -out privkey.key

 

参考文档:https://kbsml.com/?p=307

 

posted @ 2021-03-23 14:01  梦徒  阅读(524)  评论(0编辑  收藏  举报