小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

Ubuntu使用OpenSSL生成數(shù)字證書詳解

 waston 2018-01-12
在安全通信編程中有時我們會用到數(shù)字證書進(jìn)行通信加密,那么如何生成自己的數(shù)字證書進(jìn)行測試呢?下面是使用OpenSSL在Ubuntu環(huán)境生成數(shù)字證書的步驟:

一、安裝openssl
    a)    略
二、生成ca證書
    a)    創(chuàng)建一個證書目錄,mkdir /home/liuzhigong/SSL
    b)    將CA.sh拷貝到/home/liuzhigong/SSL目錄,cp /usr/lib/ssl/misc/CA.sh /home/liuzhigong/SSL
    c)    ./CA.sh -newca
    d)    根據(jù)提示填寫信息完成后,在demoCA下會生成證書文件,其中demoCA/private/cakey.pem為ca證書私鑰,demoCA/cacert.pem為ca根證書。
三、生成服務(wù)器證書
    a)    生成私鑰:        openssl genrsa -des3 -out server.key 1024
    b)    生成csr文件:   openssl req -new -key server.key -out server.csr
    c)    生成證書&簽名:    openssl ca -in server.csr -out server.crt

四、生成客戶端證書
    a)    生成私鑰:        openssl genrsa -des3 -out client.key 1024
    b)    生成csr文件:   openssl req -new -key client.key -out client.csr
    c)    生成證書&簽名:        openssl ca -in client.csr -out client.crt
 
五、生成瀏覽器支持的.pfx(.p12)證書
    安裝過支付寶、財付通證書的用戶都知道,證書文件格式為pfx,那如何把我們的數(shù)字證書轉(zhuǎn)換為瀏覽器識別的格式呢?
    a)    openssl pkcs12 -export -clcerts -in client.crt -inkey client.key -out client.pfx

六、生成不帶密碼驗證的client/server.key.unsecure
    如果你想要把數(shù)字證書用于Nginx、Apache等Web服務(wù)器,你會發(fā)現(xiàn)啟動nginx服務(wù)器時會要求你輸入數(shù)字證書密碼,這是因為在設(shè)置私鑰key時將密碼寫入了key文件,導(dǎo)致Nginx/Apache等系列服務(wù)器在啟動時要求Enter PEM pass phrase。我們需要做的是剝離這個密碼,利用如下OpenSSL命令生成server.key.unsecure文件
    openssl rsa -in server.key -out server.key.unsecure

七、常見錯誤
    a)    openssl TXT_DB error number 2 failed to update database.
            This thing happens when certificates share common data. You cannot have two certificates that look otherwise the same.
            這種情況一般發(fā)生在你之前生成過一樣的證書,又想重新生成一模一樣的證書。
            解決方法有2種:
            1)    修改demoCA下 index.txt.attr,將unique_subject = yes改為unique_subject = no
            2)    刪除demoCA下的index.txt,并新建一個空的index.txt
       

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多