生成私钥与公钥的方法
其他
2018-09-17 11:32:39
阅读次数: 0
CA重要配置文件:
/etc/pki/tls/openssl.cnf
![4.CA重要配置文件-----etc-pki-tls-openssl.cnf.png](https://upload-images.jianshu.io/upload_images/10967676-f7cbd8770baf214e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
1.生成私钥
1.1不加密
:(umask 066;openssl genrsa -out private.key 1024)
:(umask 066;openssl genrsa -out /etc/pki/CA/private/cakey .pem 1024)
![1.0生成私钥(600).png](https://upload-images.jianshu.io/upload_images/10967676-dc2ce81bfd2d7eb2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
1.2加密
:(umask 066;openssl genrsa -out private.key -des 1024)
:(umask 066;openssl genrsa -out /etc/pki/CA/private/cakey .pem -des 1024)
![1.1生成加密私钥(600).png](https://upload-images.jianshu.io/upload_images/10967676-97dd5cda3d675edb.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
1.2.1解密
:openssl rsa -in private.key -out private.key2
![1.2.将加密私钥解密-rsa.png](https://upload-images.jianshu.io/upload_images/10967676-9bb81b8f038736fa.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2.根据私钥生成公钥
2.1由没有加密的私钥(private.key2)生成公钥(public.key2)
openssl rsa -in private.key2 -pubout -out public.key2
![2.1.由没有加密的私钥生成公钥.png](https://upload-images.jianshu.io/upload_images/10967676-f4e42851196304f8.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2.2由有加密的私钥(private.key)生成公钥(public.key)
openssl rsa -in private.key -pubout -out public.key
![2.2.由加密的私钥生成公钥.png](https://upload-images.jianshu.io/upload_images/10967676-3d06e5c6bc2bff22.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
3.生成的公钥与私钥
![3.生成后的公钥与私钥.png](https://upload-images.jianshu.io/upload_images/10967676-d3f29b24112056c9.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
转载自www.cnblogs.com/lqynkdcwy/p/9661037.html