标签:letter unit 用户名 解密 state layer def ace 秘钥
CA和证书
OpenSSL
三个组件:
openssl:加密模块应用库,实现了ssl及tls,包nss
libcrypto:加密算法库,包openssl-libs
libssl:加密模块应用库,实现了ssl及tls,包nss
openssl命令
两种运行模式:交互模式和批处理模式
标准命令:
enc, ca, req, ...
对称加密
工具:oopenssl enc,
算法:3des, aes, blowfish, twofish
enc命令
帮助:man enc
加密: openssl enc -e -des3 -a -salt -in testfile -out testfile.cipher
enc(对称加密)
-des3 (加密算法)
-a(以base64编码,用可见字符表示,方便查看)
解密: openssl enc -d(解密) -des3 -a -salt -in testfile.cipher -out testfile
单向加密:
工具:md5sum, sha1sum, sha224sum,sha256sum…
openssl dgst
生成用户密码
passwd命令:
帮助:man sslpasswd
openssl passwd -1(以md5加密) -salt (加盐,杂质,不容易破解)
生成随机数
openssl rand -base64 | -hex NUM
NUM: 表示字节数;-hex时,每个字符为16进制,相当于4位二进制,出现的字符数为NUM*2
openssl rsa -in PRIVATEKEYFILE -pubout -out PUBLICKEYFILE
openssl rsa -in test.key -pubout -out test.key.pub
创建CA和申请证书
一、创建CA
1、ROOT CA 自己创建CA
生成私钥
自签名证书
二、用户或服务器
1、生成私钥
2、生成证书申请文件
3、将申请文件发给CA
三、CA颁发证书
证书签名
四、证书发送给客户端
五、应用软件使用证书
例:向CA申请证书
1、建立Root CA ,生成私钥
[root@laobai ~#cd /etc/pki/CA [root@laobai /etc/pki/CA#(umask 077;openssl genrsa -out private/cakey.pem 4096) Generating RSA private key, 4096 bit long modulus ...........++ .................................................................................................................++ e is 65537 (0x10001)
2、自签名证书
[root@laobai /etc/pki/CA#openssl req -new -x509 -key private/cakey.pem -out cacert.pem -days 3650 You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter ‘.‘, the field will be left blank. -----
3、用户服务器
(1)生成私钥
[root@laobai /etc/pki/CA#(umask 077;openssl genrsa -out app.key 1024) Generating RSA private key, 1024 bit long modulus .......++++++ .................................................................................++++++ e is 65537 (0x10001)
(2)生成证书申请文件
[root@laobai /etc/pki/CA#openssl req -new -key app.key -out app.csr Country Name (2 letter code) [XX]:CN State or Province Name (full name) []:beijing Locality Name (eg, city) [Default City]:beijing Organization Name (eg, company) [Default Company Ltd]:magedu Organizational Unit Name (eg, section) []:m30 Common Name (eg, your name or your server‘s hostname) []:www.magedu.com Email Address []: Please enter the following ‘extra‘ attributes to be sent with your certificate request A challenge password []: An optional company name []:
(3)将申请文件发给CA
[root@laobai /etc/pki/CA#sz certs/app.crt
此时在windows上的app.crt文件的后缀名改为cer,即可打开 证书
4、CA颁发证书
(1)
[root@laobai /etc/pki/CA#touch index.txt
(2)
[root@laobai /etc/pki/CA#echo 0F > serial
(3)
[root@laobai /etc/pki/CA#openssl ca -in app.csr -out certs/app.crt -days 100 Using configuration from /etc/pki/tls/openssl.cnf Check that the request matches the signature Signature ok
标签:letter unit 用户名 解密 state layer def ace 秘钥
原文地址:https://www.cnblogs.com/huxiaojun/p/9058285.html