openssl x509 -noout -text -in ca.crt
openssl verify -CAfile ca.crt myserver.crt
openssl verify selfsign.crt
openssl rsa -noout -text -in myserver.key
openssl rsa -in server.key -out server.key
openssl dgst -md5 filename
openssl dgst -sha1 filename
生成CA私钥(.key)–>生成CA证书请求(.csr)–>自签名得到根证书(.pem)(CA给自已颁发的证书)。
# Generate CA private key $ openssl genrsa -out ca.key 2048 # Generate CSR $ openssl req -new -key ca.key -out ca.csr # Generate Self Signed certificate(CA 根证书) $ openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.pem生成私钥(.key)–>生成证书请求(.csr)–>用CA根证书签名得到证书(.pem)
# private key $ openssl genrsa -des3 -out server.key 1024 # generate csr $ openssl req -new -key server.key -out server.csr # generate certificate $ openssl ca -in server.csr -out server.pem -cert ca.crt -keyfile ca.key最后一步可能碰到错误,我是在windows上运行:
Using configuration from C:\OpenSSL-Win64\bin\openssl.cfg ca: ./demoCA/newcerts is not a directory ./demoCA/newcerts: No such file or directory解决办法是在当前操作目录新建demoCA/newcerts两级目录。然后在demoCA文件夹下新建一个空的index.txt文件,再新建一个serial文件,没有后缀,里面填入01。