Shammer's Philosophy

My private adversaria

OpenSSL の DName 項目変更

以下のサイトで紹介されていた。

 Gmane Loom

手順は以下のとおり。

  1. 項目を決定し、[ new_oids ] セクションに追記(小文字でないとうまくいかなかった)
  2. 追加項目の oid を指定(何らかの羅列を OID のルートとして連番を振るのがよさそう)
  3. [ req_distinguish_name ] に項目を追加
  4. [ policy_match ] を追加項目に合わせて変更
  5. (使っている場合は)[ policy_anything ] の内容も変更

デフォルトでは、おそらく US の地域分けに倣った内容になっている。そのため、都道府県、市または群を追加して、stateOrProvinceName を削除、organizationalUnitName を Division に変更した。openssl.cnf から該当箇所を引用するとそれぞれ以下のような感じ。

[ new_oids ]

# We can add new OIDs in here for use by 'ca', 'req' and 'ts'.
# Add a simple OID like this:
# testoid1=1.2.3.4
# Or use config file substitution like this:
# testoid2=${testoid1}.5.6

# Policies used by the TSA examples.
tsa_policy1 = 1.2.3.4.1
tsa_policy2 = 1.2.3.4.5.6
tsa_policy3 = 1.2.3.4.5.7

# My new Oids
prefecturalGovernments = 1.2.3.4.1.1
city = 1.2.3.4.1.2
division = 1.2.3.4.1.3

…

[ policy_match ]
countryName		= match
# stateOrProvinceName	= match
PrefecturalGovernments	= optional
organizationName	= match
#organizationalUnitName	= optional
Division		= optional
commonName		= supplied
emailAddress		= optional

…

[ req_distinguished_name ]
countryName			= Country Name (2 letter code)
countryName_default		= JP
countryName_min			= 2
countryName_max			= 2

# stateOrProvinceName		= State or Province Name (full name)
# stateOrProvinceName_default	= Some-State
prefecturalGovernments		= Prefecture
prefecturalGovernments_default	= Tokyo


# localityName			= Locality Name (eg, city)
city				= City or Gun

organizationName		= Organization Name (eg, company)
organizationName_default	= Internet Widgits Pty Ltd

# we can do this but it is not needed normally :-)
#1.organizationName		= Second Organization Name (eg, company)
#1.organizationName_default	= World Wide Web Pty Ltd

#organizationalUnitName		= Organizational Unit Name (eg, section)
#organizationalUnitName_default	=
division			= Division Name (eg, TechnicalSupport)

commonName			= Common Name (e.g. server FQDN or YOUR name)
commonName_max			= 64

emailAddress			= Email Address
emailAddress_max		= 64

まあ、division_default を追加してもいいかもしれない。