CA是證書的簽發機構,它是PKI的核心。CA是負責簽發證書、認證證書、管理已頒發證書的機關。它要制定政策和具體步驟來驗證、識別用戶身份,並對用戶證書進行簽名,以確保證書持有者的身份和公鑰的擁有權,那麼有一個疑問,誰給CA來頒發證書呢,嘿嘿,固然是它本身給本身頒發了。linux
openssl是一款開源的加密工具,在Linux環境下,咱們可以利用它來搭建一個CA來實現證書的發放,能夠用於企業內部使用的加密工具。 算法
加密機制:明文加密: telnet ftp pop3 密碼不可靠 ;sendmail NFS NIS 信息數據的不可靠; rsh rcp 驗證的不可靠vim
常見的算法:安全
md2 md5 mdc2 rmd160 sha sha1 ---> md5 sha1服務器
三、對稱加密: DES 3DES AES Twofish RC6併發
四、非對稱加密:公鑰加密 基於單向函數功能實現,密鑰成對出現dom
CA:證書頒發機構 公信力的第三方ide
其具體步驟流程爲:
發送方:函數
接收方:
工具
下面用redhat 開源的openssl來搭建一個CA,並實現證書的頒發
##linux下的ssl是由openssl提供的。
- [root@server1 tls]#vim openssl.cnf #ca的配置文檔
- [ CA_default ]
- dir = /etc/pki/CA #CA存放的路徑
- certs = $dir/certs #存放簽名的公鑰
- crl_dir = $dir/crl # 證書過時列表,存放過時證書
- database = $dir/index.txt # 證書頒發、吊銷的信息
- new_certs_dir = $dir/newcerts # 證書副本(吊銷憑證)
- certificate = $dir/cacert.pem #CA公鑰(任何人均可以擁有的)
- serial = $dir/serial # 序列號(每做一次簽名,序列號就增長1)
- crlnumber = $dir/crlnumber #吊銷序列號
- crl = $dir/my-ca.crl #吊銷證書名單列表
- private_key = $dir/private/cakey.pem # 私鑰 與產生本身私鑰的名字對應
- RANDFILE = $dir/private/.rand # private random number file
- x509_extensions = usr_cert # The extentions to add to the cert
- default_days = 365 # 證書有效期
- default_crl_days= 30 #crl更新時間
- [ policy_match ]
- countryName = match #國家代碼必須徹底匹配能夠修改成optional
- stateOrProvinceName = match #
- organizationName = match
- organizationalUnitName = optional #optional能夠不同
- commonName = supplied #表明惟一身份,必須不匹配
- emailAddress = optional
- [ req_distinguished_name ]
- countryName = Country Name (2 letter code)
- countryName_default = CN #國家代碼
- countryName_min = 2
- countryName_max = 2
- stateOrProvinceName = State or Province Name (full name)
- stateOrProvinceName_default =henan
- localityName = Locality Name (eg, city)
- localityName_default = zhengzhou #城市
- 0.organizationName = Organization Name (eg, company)
- 0.organizationName_default = Example, Inc. #組織
##openssl.cnf配置完成
- [root@server1 tls]# cd ../CA/
- [root@server1 CA]# ls
- private
- [root@server1 CA]# mkdir {certs,newcerts,crl} #建立剛纔定義的那幾個目錄
- [root@server1 CA]# ls
- certs crl newcerts private
- [root@server1 CA]# echo 01 > serial ;touch index.txt #分配一個開始序列號並建立index.txt
開始生成CA中心本身的私鑰
- [root@server1 CA]#(umask 077; openssl genrsa –out private/cakey.pem 2048 )
- Generating RSA private key, 2048 bit long modulus
- ..................+++
- .........................................................................................................................................+++
- e is 65537 (0x10001)
- Enter pass phrase for private/cakey.pem:redhat #輸入私鑰密碼
- Verifying - Enter pass phrase for private/cakey.pem:redhat #確認輸入
經過私鑰來生成公鑰:
- [root@server1 CA]# openssl req -new -x509 -key private/cakey.pem -days 365 -out cacert.pem
- Enter pass phrase for private/cakey.pem:
- 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.
- -----
- Country Name (2 letter code) [CN]:
- State or Province Name (full name) [henan]:
- Locality Name (eg, city) [zhengzhou]:
- Organization Name (eg, company) [Example, Inc.]:
- Organizational Unit Name (eg, section) []:
- Common Name (eg, your name or your server's hostname) []:server1.example.com
- Email Address []:
CA中心已經搭完了,此時就能夠做爲一個被信任的機構來爲其餘頒發證書了
給httpd服務頒發證書
一、新建並進入工做目錄
- [root@server1 ~]# cd /etc/httpd
- [root@server1 httpd]# mkdir certs #存放證書信息
- [root@server1 certs]# cd certs
二、模擬客戶機生成密鑰
- [root@server1 certs]# openssl genrsa 1024 > httpd.key
- [root@server1 certs]# chmod 400 httpd.key
三、生成並向CA提交申請
填寫的信息要與CA保持一致
- [root@server1 certs]# openssl req -new -key httpd.key -out httpd.csr #後綴名
四、將CA申請提交給CA服務器
五、在服務器端192.168.0.21簽署證書
- # scp httpd.csr 192.168.0.1:/tmp
證書生成之後就能夠直接發給客戶端了 此時證書頒發完畢,
- # cd /tmp
- # openssl ca -in httpd.csr -out /etc/pki/CA/certs/httpd.crt
證書申請和頒發沒有留有圖片。有什麼疑問能夠直接留言,相互促進,相互學習!!!