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

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

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

    零全零美(www.zzgwt.com)
    生活中的很多事情,并不像If...Else那么簡單!
    posts - 96,comments - 52,trackbacks - 0
    用途:
    模擬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的時候,哪些信息是我們必須的,哪些不是??纯碿onfig文件里面的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文件:openssl.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 2009-11-27 17:34 零全零美 閱讀(589) 評論(0)  編輯  收藏 所屬分類: 安全相關
    主站蜘蛛池模板: 亚洲短视频在线观看| 精品无码专区亚洲| 免费高清小黄站在线观看| 精品女同一区二区三区免费播放| 久久久久亚洲精品中文字幕| 久久久久久国产精品免费无码| 亚洲一区二区观看播放| 一本久久a久久精品亚洲| 97性无码区免费| 国产精品美女免费视频观看| 亚洲精品国产成人| 亚洲国产一区视频| 五月亭亭免费高清在线| jizz免费观看视频| 亚洲偷偷自拍高清| 亚洲日本va在线视频观看| 成年人视频在线观看免费| 成人免费777777被爆出| 久久无码av亚洲精品色午夜| 91嫩草私人成人亚洲影院| 亚洲成av人片一区二区三区 | 一级毛片在线免费看| 特级毛片免费播放| 亚洲一区在线观看视频| 国产日韩亚洲大尺度高清| 日本免费高清一本视频| 在线观看www日本免费网站| 亚洲精品偷拍视频免费观看| 亚洲综合av一区二区三区不卡| 亚洲成av人片在线观看无码不卡| 国产zzjjzzjj视频全免费| 两性刺激生活片免费视频| a级毛片在线视频免费观看| 国产成人高清亚洲一区久久| 亚洲制服丝袜在线播放| 亚洲av日韩av不卡在线观看| 亚洲M码 欧洲S码SSS222| 永久免费毛片手机版在线看| 免费国产作爱视频网站| 91香蕉在线观看免费高清| 在线观看免费无码视频|