什么是CA认证?算法
CA认证,即CA认证机构,为电子签名相关各方提供真实性、可靠性验证的行为。数据库
什么是CA证书?服务器
证书实际是由证书签证机关(CA)签发的对用户的公钥的认证。app
CA证书类型?dom
Linux系统如何搭建CA服务?ide
1.安装相关工具:opensslyum install openssl -y
2.openssl相关配置文件:/etc/pki/tls/openssl.cnf
指定默认使用的CA工具
[ ca ] default_ca = CA_default # The default ca section CA的相关配置 [ CA_default ] dir = /etc/pki/CA # Where everything is kept,CA的工做目录 certs = $dir/certs # Where the issued certs are kept,已经颁发的证书存放目录 crl_dir = $dir/crl # Where the issued crl are kept,证书吊销列表存放目录 database = $dir/index.txt # database index file,证书的索引数据库 new_certs_dir = $dir/newcerts # default place for new certs,新证书存放目录 certificate = $dir/cacert.pem # The CA certificate,CA证书 serial = $dir/serial # The current serial number,当前证书编号 crlnumber = $dir/crlnumber # the current crl number,当前吊销证书编号 crl = $dir/crl.pem # The current CRL,当前的吊销证书 private_key = $dir/private/cakey.pem # The private key,CA私钥 RANDFILE = $dir/private/.rand # private random number file,随机文件 default_days = 365 # how long to certify for,证书有效期 default_crl_days= 30 # how long before next CRL,发布证书 吊销列表的周期 default_md = sha256 # use SHA-256 by default,算法 preserve = no # keep passed DN ordering policy = policy_match #选择使用的策略类型 \# For the CA policy [ policy_match ] #第一种策略 countryName = match #是否匹配国家 stateOrProvinceName = match #是否匹配省 organizationName = match #是否匹配组织名称 organizationalUnitName = optional #是否单元名称 commonName = supplied #通用名 emailAddress = optional #邮箱 # For the 'anything' policy # At this point in time, you must list all acceptable 'object' # types. [ policy_anything ] countryName = optional stateOrProvinceName = optional localityName = optional organizationName = optional organizationalUnitName = optional commonName = supplied emailAddress = optional
3.建立CAthis
(1)建立索引数据库文件和指定证书编号 3d
touch /etc/pki/CA/index.txt echo 01 >/etc/pki/CA/serial
(2)CA自签名证书code
生成私钥:
(umask 077;openssl genrsa -out /etc/pki/CA/private/cakey.pem 2048)
生成自签名证书:
openssl req -new -x509 -key /etc/pki/CA/private/cakey.pem -out /etc/pki/CA/cacert.pem -days 365
(3)客户端建立申请文件
生成客户端私钥:
(umask 066;openssl genrsa -out app.key 1024)
生成申请文件:
openssl req -new -key app.key -out app.csr
将生成的申请文件发送到CA颁发服务器
scp app.csr 192.168.128.130:/etc/pki/CA/
(4)CA服务器为客户端颁发证书
openssl ca -in app.csr -out certs/app.crt -days 100
(5)将生成的证书发送给申请的客户端
scp certs/app.crt 192.168.128.129:
证书吊销
生成吊销证书序号文件
echo 01 >crlnumber
吊销证书
openssl ca -revoke /etc/pki/CA/newcerts/01.pem
生成吊销列表
openssl ca -gencrl -out /etc/pki/CA/crl.pem
注意事项:1.必需要提早建立证书数据库引导文件/etc/pki/CA/index.txt2.指定证书编号,证书颁发完成后会自动更新证书序号