<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    捕風之巢

    統計

    留言簿(3)

    java友情鏈接

    閱讀排行榜

    評論排行榜

    openssl簡介(八)--指令ca

    ?

    八.???? 指令 ca

    用途:
    ? ?
    模擬 CA 行為的工具 . 有了它,你就是一個 CA, 不過估計是 nobody trusted CA. 可以用來給各種格式的 CSR 簽名,用來產生和維護 CRL( 不記得 CRL 是什么了?去看證書那一章 ). 他還維護著一個文本數據庫,記錄了所有經手頒發 的證書及那些證書的狀態。
    ? ?
    用法:
    ? ???openssl ca [-verbose] [-config filename] [-name section] [-gencrl]
    ? ?
    ? ???[-revoke file] [-crldays days] [-crlhours hours] [-crlexts section]
    ? ?
    ? ???[-startdate date] [-enddate date] [-days arg] [-md arg] [-policy arg]
    ? ?
    ? ???[-keyfile arg] [-key arg] [-passin arg] [-cert file] [-in file]
    ? ?
    ? ???[-out file] [-notext] [-outdir dir] [-infiles] [-spkac file]
    ? ?
    ? ???[-ss_cert file] [-preserveDN] [-batch] [-msie_hack] [-extensions section]

    ? ???
    哇噻,好復雜也。不過用過 GCC 的人應該覺得這么點 flag 還是小 case.
    ? ?
    -config filename
    ? ?
    指定使用的 configure 文件。
    ? ?
    ? ? -in filename
    ? ?
    要簽名的 CSR 文件。
    ? ?
    ? ? -ss_cert filename
    ? ?
    一個有自簽名的證書,需要我們 CA 簽名,就從這里輸入文件名。
    ? ?
    ? ? -spkac filename
    ? ?
    這一段實在沒有看懂,也沒興趣,估計和 SPKAC 打交道可能性不大,奉送上英文原文。
    ? ? a file containing a single Netscape signed public key and challenge and additional field values to be signed by the CA.
    SPKAC FORMAT
    ? ? The input to the -spkac command line option is a Netscape signed public key and challenge. This will usually come from the KEYGEN tag in an HTML form to create a new private key. It is however possible to create SPKACs using the spkac utility.
    ? ? The file should contain the variable SPKAC set to the value of the SPKAC and also the required DN components as name value pairs. If you need to include the same component twice then it can be preceded by a number and a .
    ? ? -infiles
    ? ?
    如果你一次要給幾個 CSR 簽名,就用這個來輸入,但記得這個選項一定要放在最后。這個項后面的所有東東都被認為是 CSR 文件名參數。
    ? ? -out filename
    ? ?
    簽名后的證書文件名。證書的細節也會給寫進去。
    ? ? -outdir directory
    ? ?
    擺證書文件的目錄。證書名就是該證書的系列號,后綴是 .pem
    ? ? -cert
    ? ? CA
    本身的證書文件名
    ? ? -keyfile filename
    ? ? CA
    自己的私有密鑰文件
    ? ? -key password
    ? ? CA
    的私有密鑰文件的保護密碼。
    ? ?
    在有的系統上,可以用 ps 看到你輸入的指令,所以這個參數要小心點用。
    ? ? -passin arg
    ? ?
    也是一個輸入私有密鑰保護文件的保護密碼的一種方式,可以是文件名,設備名或者是有名管道。程序會把該文件的第一行作為密碼讀入。(也蠻危險的)。
    ? ? -verbose
    ? ?
    操作過程被詳細 printf 出來
    ? ? -notext
    ? ?
    不要把證書文件的明文內容輸出到文件中去。
    ? ? -startdate date
    ? ?
    指明證書的有效開始日期。格式是 YYMMDDHHMMSSZ, ASN1 UTCTime 結構相同。
    ? ? -enddate date
    ? ?
    指明證書的有效截止日期,格式同上。
    ? ? -days arg
    ? ?
    指明給證書的有效時間,比如 365 天。
    ? ? -md alg
    ? ?
    簽名用的哈希算法,比如 MD2, MD5 等。
    ? ? -policy arg
    ? ?
    指定 CA 使用的策略。其實很簡單,就是決定在你填寫信息生成 CSR 的時候,哪些信息是我們必須的,哪些不是。看看 config 文件里面的 policy 這個 item 就明白了。
    ? ? -msie_hack
    ? ?
    為了和及其古老的證書版本兼容而做出的犧牲品,估計沒人會用的,不解釋了。
    ? ? -preserveDN
    ? ?
    -msie_hack 差不多的一個選項。
    ? ? -batch
    ? ?
    設置為批處理的模式,所有的 CSR 會被自動處理。
    ? ? -extensions section
    ? ?
    我們知道一般我們都用 X509 格式的證書, X509 也有幾個版本的。如果你在這個選項后面帶的那個參數在 config 文件里有同樣名稱的 key, 那么就頒發 X509V3 證書,否則頒發 X509v1 證書。
    ? ?
    還有幾個關于 CRL 的選項,但我想一般很少人會去用。我自己也沒興趣去研究。
    ? ?
    有興趣的自己看看英文吧。
    ? ?? ???
    ? ???CRL OPTIONS
    ? ?
    ? ???-gencrl
    ? ?
    ? ???this option generates a CRL based on information in the index file.
    ? ?? ?-crldays num
    ? ?
    ? ???the number of days before the next CRL is due. That is the days from
    ? ?
    ? ???now to place in the CRL nextUpdate field.
    ? ?
    -crlhours num
    ? ?
    ? ???the number of hours before the next CRL is due.
    ? ?? ???
    ? ???-revoke filename
    ? ?
    ? ???a filename containing a certificate to revoke.
    ? ?? ???
    ? ???-crlexts section
    ? ?
    ? ???the section of the configuration file containing CRL extensions to
    ? ?
    ? ???include. If no CRL extension section is present then a V1 CRL is created,
    ? ?
    ? ???if the CRL extension section is present (even if it is empty) then a V2
    ? ?
    ? ???CRL is created. The CRL extensions specified are CRL extensions and not
    ? ?
    ? ???CRL entry extensions. It should be noted that some software (for example
    ? ?
    ? ???Netscape) can't handle V2 CRLs.
    ? ?
    ? ?
    相信剛才大家都看到很多選項都和 config 文件有關 , 那么我們來解釋一下 config 文件 make install 之后, openssl 會生成一個全是缺省值的 config 文件 penssl.cnf. 也長的很,貼出來有賺篇幅之嫌, xgh 不屑。簡單解釋一下其中與 CA 有關的 key.
    CA 有關的 key 都在 ca 這個 section 之中。
    ? ? [ ca ]
    ? ? default_ca = CA_default
    ? ? [ CA_default ]
    ? ? dir = ./demoCA # Where everything is kept
    ? ? 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
    ? ? serial = $dir/serial # The current serial number
    ? ? crl = $dir/crl.pem # The current CRL
    ? ? private_key = $dir/private/cakey.pem# The private key
    ? ? RANDFILE = $dir/private/.rand # private random number file
    ? ? x509_extensions = usr_cert # The extentions to add to the cert
    ? ? # Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs
    ? ? # so this is commented out by default to leave a V1 CRL.
    ? ? # crl_extensions = crl_ext
    ? ? default_days = 365 # how long to certify for
    ? ? default_crl_days= 30 # how long before next CRL
    ? ? default_md = md5 # which md to use.
    ? ? preserve = no # keep passed DN ordering
    ? ? # A few difference way of specifying how similar the request should look
    ? ? # For type CA, the listed attributes must be the same, and the optional
    ? ? # and supplied fields are just that
    ? ? policy = policy_match
    ? ? # For the CA policy
    ? ? [ policy_match ]
    ? ? countryName = match
    ? ? stateOrProvinceName = match
    ? ? organizationName = match
    ? ? organizationalUnitName = optional
    ? ? commonName = supplied
    ? ? emailAddress = optional
    ? ? # 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
    ? ? config
    文件里 CA section 里面的很多 key 都和命令行參數是對應的。
    ? ?
    如果某個 key 后面標明 mandatory, 那就說明這個參數是必須提供的,無論你通過命令行還是通過 config 文件去提供。

    new_certs_dir
    ? ?
    key 同命令行的 -outdir 意義相同。 (mandatory)
    ? ? certificate
    ? ?
    同命令行的 -cert 意義相同。 (mandatory)
    ? ? private_key
    ? ?
    同命令行 -keyfile 意義相同 .(mandatory)
    ? ? RANDFILE
    ? ?
    指明一個用來讀寫時候產生 random key seed 文件。具體意義在以后的 RAND API 再給出解釋。 ( 不是我擺譜,我覺得重復解釋沒有必要 )
    ? ? default_days
    ? ?
    意義和命令行的 -days 相同。
    ? ? default_startdate
    ? ?
    意義同命令行的 -startdate 相同。如果沒有的話那么就使用產生證書的時間。
    ? ? default_enddate
    ? ?
    意義同命令行的 -enddate 相同。 (mandatory).
    ? ? crl_extensions
    ? ? preserve
    ? ? default_crl_hours default_crl_days
    ? ? CRL
    的東西 ..... 自己都沒弄懂 .....
    ? ? default_md
    ? ?
    同命令行的 -md 意義相同 . (mandatory)
    ? ? database
    ? ?
    記得 index.txt 是什么文件嗎?不記得自己往前找。這個 key 就是指定 index.txt 的。初始化是空文件。
    ? ? serialfile
    ? ?
    指明一個 txt 文件,里面必須包含下一個可用的 16 進制數字,用來給下一個證書做系列號。 (mandatory)
    ? ? x509_extensions
    ? ?
    意義同 -extensions 相同。
    ? ? msie_hack
    ? ?
    意義同 -msie_hack 相同。
    ? ? policy
    ? ?
    意義同 -policy 相同。自己看看這一塊是怎么回事。 (mandatory)
    ? ? [ policy_match ]
    ? ? countryName = match
    ? ? stateOrProvinceName = match
    ? ? organizationName = match
    ? ? organizationalUnitName = optional
    ? ? commonName = supplied
    ? ? emailAddress = optional
    ? ?
    其實如果你做過 CSR 就會明白,這些項就是你做 CSR 時候填寫的那些東西麻。
    ? ?
    后面的 "match", "supplied" 等又是什么意思呢? "match" 表示說明你填寫的這一欄一定要和 CA 本身的證書里面的這一欄相同。 supplied 表示本欄必須, optional 就表示本欄可以不填寫。
    ? ?
    舉例時間到了:
    ? ?
    注意,本例中我們先要在 $OPENSSL/misc 下面運行過 CA.sh -newca ,建立好相應的目錄,所有需要的文件,包括 CA 的私有密鑰文件,證書文件,系列號文件,和一個空的 index 文件。并且文件都已經各就各位。 放心把,產生文件和文件就位都由 CA.sh 搞定,你要做的就是運行 CA.sh -nweca 就行了,甚至在你的系列號文件中還有個 01, 用來給下一個證書做系列號。
    ? ?
    給一個 CSR 簽名:
    ? ? openssl ca -in req.pem -out newcert.pem
    ? ?
    給一個 CSR 簽名 , 產生 x509v3 證書:
    ? ? openssl ca -in req.pem -extensions v3_ca -out newcert.pem
    ? ?
    同時給數個 CSR 簽名:
    ? ? openssl ca -infiles req1.pem req2.pem req3.pem
    ? ?
    注意:
    ? ? index.txt
    文件是整個處理過程中很重要的一部分,如果這玩意壞了,很難修復。理論上根據已經頒發的證書和當前的 CRL 當然是有辦法修復的啦,但 openssl 沒提供這個功能。
    ? ? openssl
    還有倆大類指令 : crl, crl2pkcs7, 都是和 CRL 有關的,
    ? ?
    由于我們對這個沒有興趣,所以這倆大類不做翻譯和解釋。

    posted on 2006-10-17 15:27 捕風 閱讀(651) 評論(0)  編輯  收藏 所屬分類: java安全

    主站蜘蛛池模板: 999在线视频精品免费播放观看| 麻豆成人精品国产免费| 亚洲人配人种jizz| 四虎影视永久免费观看地址| a级成人毛片免费图片| 亚洲国产精品成人精品软件| 国产一区二区三区在线免费观看| 岛国岛国免费V片在线观看| 亚洲视频一区在线播放| 亚洲va中文字幕无码| 91短视频在线免费观看| 国产亚洲精品免费| 亚洲精品视频在线播放| 亚洲成a人无码av波多野按摩 | 色费女人18女人毛片免费视频| 亚洲线精品一区二区三区影音先锋 | 亚洲国产成人久久一区二区三区| 亚洲日韩精品一区二区三区| 成年人免费观看视频网站| 日本高清不卡aⅴ免费网站| 亚洲日韩一区精品射精| 亚洲AV日韩AV天堂一区二区三区| 日韩免费高清视频网站| 无码A级毛片免费视频内谢| 色噜噜狠狠色综合免费视频| 亚洲国产av美女网站| 亚洲色无码专区在线观看| 国产猛烈高潮尖叫视频免费| 18禁美女黄网站色大片免费观看| 一个人免费观看日本www视频| 色偷偷女男人的天堂亚洲网| 久久亚洲精品国产精品黑人| gogo全球高清大胆亚洲| 67194成是人免费无码| 久久这里只精品热免费99| 一级午夜免费视频| 国产在亚洲线视频观看| 波多野结衣亚洲一级| 亚洲综合久久成人69| 日本红怡院亚洲红怡院最新| 午夜亚洲福利在线老司机|