openssl RSA加解密和生成证书

2019-05-05  本文已影响0人  2525252472
//生成私钥
openssl genrsa -out private.pem 1024
//生成公钥
openssl rsa -in private.pem -pubout -out public.pem

//查看私钥
openssl rsa -in private.pem -text -out private.txt

//公钥加密
openssl rsautl -encrypt -in message.txt -inkey public.pem -out enc.txt
//私钥解密
openssl rsautl -decrypt -in enc.txt -inkey private.pem -out dec.txt

//私钥签名
openssl rsautl -sign -in message.txt -inkey private.pem -out enc.txt
// 公钥验证
openssl rsautl -verify -in enc.txt -inkey public.pem -out dec.txt
//生成请求文件
openssl req -new -key private.pem -out rsacert.csr
//生成crt证书
openssl x509 -req -days 365 -in rsacert.csr -signkey private.pem -out rsacert.crt
//生成der证书
openssl x509 -outform der -in rsacert.crt -out rsacert.der
//生成p12文件
openssl pkcs12 -export -out p.p12 -inkey private.pem -in rsacert.crt

上一篇下一篇

猜你喜欢

热点阅读