`
zl198751
  • 浏览: 273235 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

OpenSSL的配置文件

 
阅读更多

原文:   http://www.iona.com/support/docs/orbix2000/2.0/tls/html/OpenSslUtils3.html

许 多OpenSSL命令(例如,req和ca)带有一个-config参数用于指定openssl配置文件的位置.
本节提供配置文件格式的简短描述 和它怎么应用于req和ca命令.本节结尾列出了一个配置文件的例子.

openssl.cnf配置文件由许多节(section)组成, 这些节指定了一系列由openssl命令使用的默认值.

[req] 变量
req节包含下列设置:

default_bits=1024
default_keyfile=privkey.pem
distinguished_name=req_distingguished_name  # section name
attributes=req_attributes                   # section name

default_bits       : 是你希望使用的RSA key的默认长度,其它的可能值是512,2048和4096
default_keyfile    : 由req建立的私钥文件的默认文件名.
distinguished_name : 也是配置文件中的节,这个节为distinguished name域各组件定义默认值.req_attributes
变量指定配置文件中 定义证书请求属性的默认值的节.

[ca] 变量
你可以配置openssl.cnf来支持许多为签名CSR文件而有着不同策略 (policy)的CA.
-name参数来指定要使用哪个CA节.例如:

 openssl ca -name MyCa ...

这 个命令引用CA的节[MyCa], 如果-name没被提供给ca命令,那就使用default_ca变量指定的节.
可以有多个不同的CA,但只 能有一个是默认的CA。

可能的[ca]变量包含如下内容:
dir: CA数据库的位置.
  数据库是指一个简单的文本数据库,里面包含由tab分隔的字段:
  status        : 'R' - revoked(撤销的), 'E' - expired(过期的), 'V' - 有效
  issued date   : 发证日期
  revoked date  : 撤销日期,如果没被撤销,空
  serial number : 序号
  certificate   : 证书存放位置
  CN            : 证书的文件名

  serial字段应当是唯当像CN/status组合一样是唯一的,ca程序在启动时检测这些值.

certs: 所有以前发布的证书保存的地方.

[policy] 变量
如果ca命令的-policy参数没被提供,policy变量指定默认的 policy节.
CA策略节表示在证书在被CA签发前,证书请求的内容必须被满足的必要条件.
例子定义了两个policy: policy_match和policy_anything.

看一下如下值:
countryName=match
这意味 着country name必须匹配CA证书。

organisationalUnitName=optional
这表示 organistationalUnitName是可选的.

commonName=supplied
这表示commonName 在证书请求中必须提供


例子openssl.cnf文件的policy_match节指定了在生成的证书中属性的顺序,如下:
countryName
stateOrProvinceName
organizationName
organizationalUnitName
commonName
emailAddress



Example openssl.cnf File

    ################################################################
    # openssl example configuration file.
    # This is mostly used for generation of certificate requests.
    #################################################################
    [ ca ]
    default_ca= CA_default          # The default ca section
    #################################################################
     
    [ CA_default ]
    
    dir=/opt/iona/OrbixSSL1.0c/certs # Where everything is kept
    certs=$dir                       # 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/new_certs    # default place for new certs
    certificate=$dir/CA/OrbixCA      # The CA certificate
    serial= $dir/serial              # The current serial number
    crl= $dir/crl.pem                # The current CRL
    private_key= $dir/CA/OrbixCA.pk  # The private key
    RANDFILE= $dir/.rand             # private random number file
    default_days= 365                # how long to certify for
    default_crl_days= 30             # how long before next CRL
    default_md= md5                  # which message digest to use
    preserve= no                     # keep passed DN ordering
    
    # A few different ways of specifying how closely the request should
    # conform to the details of the CA
    
    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
    
    [ req ]
    default_bits = 1024
    default_keyfile= privkey.pem
    distinguished_name = req_distinguished_name
    attributes = req_attributes
    
    [ req_distinguished_name ]
    countryName= Country Name (2 letter code)
    countryName_min= 2
    countryName_max = 2
    stateOrProvinceName= State or Province Name (full name)
    localityName = Locality Name (eg, city)
    organizationName = Organization Name (eg, company)
    organizationalUnitName  = Organizational Unit Name (eg, section)
    commonName = Common Name (eg. YOUR name)
    commonName_max = 64
    emailAddress = Email Address
    emailAddress_max = 40
    
    [ req_attributes ]
    challengePassword = A challenge password
    challengePassword_min = 4
    challengePassword_max = 20
    unstructuredName= An optional company name

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics