2.1. インストール

今では、OpenSSL のインストールについて、そんなに心配する必要はありません。 と言うのも、ほとんどのディストリビューションでは パッケージ管理アプリケーションを用いているからです。 各ディストリビューションのドキュメントを参照するか、 OpenSSl tarball に含まれている README と INSTALL ファイルを読んでください。 この HOWTO を証明書を扱う HOWTO よりも、 インストール HOWTO にしてしまうことは避けたいと思います。

ここでは、後の例を理解するために知る必要のある 標準的なインストールオプションをいくつか紹介しておきます。 場合によっては変更が必要かもしれません。

全ての OpenSSL 証明書のためのディレクトリは /var/ssl/ です。 この文書の中の全てのコマンドとパスはこのディレクトリから始まっています。 これは必須ではありませんが、以下の例を理解する役に立つでしょう。

デフォルトの OpenSSL は /usr/lib/ssl/openssl.cnf で設定ファイルを探します。 ですから例えば、openssl ca や openssl req のコマンドに 常に -config /etc/openssl.cnf を加えてください。 私は /etc/openssl.cnf を用いることにしますので、 私の全ての設定ファイルは /etc 以下にあることになります。

ユーティリティと他のライブラリは /usr/lib/ssl 以下におかれています。

2.1.1. CA.pl ユーティリティ

ユーティリティ CA.pl が /usr/sbin のようなアクセス可能なディレクトリに あることを確認してください。 CA.pl は /usr/lib/ssl ディレクトリの中で見つけられます。 CA.pl は openssl コマンドの複雑さを覆い隠すユーティリティです。 以下の全ての例で、私が CA.pl を使うときは、その openssl での等価コマンドを 括弧の中に書くことにします。

<-- /usr/sbin/CA.pl needs to be modified to include -config /etc/openssl.cnf in ca and req calls. --> /usr/sbin/CA.pl は ca と req コールでは -config /etc/openssl.cnf をつけて変形する必要があります。

#$SSLEAY_CONFIG=$ENV{"SSLEAY_CONFIG"}; 
$SSLEAY_CONFIG="-config /etc/openssl.cnf"; 
#$CATOP="./demoCA"; 
$CATOP="/var/ssl";

2.1.2. openssl.cnf ファイル

/etc/openssl.cnf は input エントリーを最小限にするように 適切に設定しなければいけません。

#---Begin---
# 
# OpenSSL example configuration file. 
# OpenSSL 設定ファイル例
# This is mostly being used for generation of certificate requests. 
# これは主に証明書要求の生成のために使われるもの。
#
RANDFILE  = $ENV::HOME/.rnd 
oid_file  = $ENV::HOME/.oid 
oid_section  = new_oids
# To use this configuration file with the "-extfile" option of the 
# "openssl x509" utility, name here the section containing the 
# X.509v3 extensions to use: 
# この設定ファイルを "openssl x509" ユーティリティの "-extfile"
# オプションとともに使うためには、用いる X509v3 拡張を
# 含むセクションにここで名前をつける:
# extensions  = 
# (Alternatively, use a configuration file that has only 
# X.509v3 extensions in its main [= default] section.)
# (または、メインの[=default]セクションで X.509v3 拡張
# だけを持つ設定ファイルを使う)
[ new_oids ]
# We can add new OIDs in here for use by 'ca' and 'req'. 
# Add a simple OID like this: 
# ここで 'ca' と 'req' によって用いるための新たな OID らを追加。
# 一つの OID をこのように追加する:
# testoid1=1.2.3.4 
# Or use config file substitution like this: 
# または以下のように設定ファイルの挿入を使う:
# testoid2=${testoid1}.5.6
#################################################################### 
[ ca ] 
default_ca = CA_default  # The default ca section デフォルト CA セクション
#################################################################### 
[ CA_default ]
dir             = /var/ssl                # Where everything is kept 全てが保存されている場所
certs           = $dir/certs              # Where the issued certs are kept 発行された証明書が保存されている場所
crl_dir         = $dir/crl                # Where the issued crl are kept 発行された crl が保存されている場所
database        = $dir/index.txt          # database index file. データベースインデックスファイル
new_certs_dir   = $dir/newcerts           # default place for new certs.新しい証明書をおくデフォルトの場所
certificate     = $dir/cacert.pem         # The CA certificate (CA 証明書)
serial          = $dir/serial             # The current serial number 現在のシリアル番号
crl             = $dir/crl.pem            # The current CRL 現在の 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 に追加する拡張。注意:Netscape communicator は V2 CRL は受け入れない
# よって、これは V1 CRL を残すためデフォルトでコメントアウト。
# crl_extensions = crl_ext
default_days    = 365                     # how long to certify for 有効期間
default_crl_days= 7                       # how long before next CRL 次の CRL までの期間
default_md      = sha1                    # which md to use. 用いる md の種類
preserve        = no                      # keep passed DN ordering パスした DN 順序を保存
# 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 :-) 
# 要求の類似性を特定する二、三の違った方法
# タイプ CA については、リストされた属性は同じでなくてならず、
# 追加されたフィールドと供給されたフィールドはまさにそれで :-)
policy  = policy_match
# For the CA policy (CA のポリシー)
[ policy_match ] 
countryName            = match 
stateOrProvinceName    = optional 
localityName           = 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. 
# 「なんでも」ポリシー
# この時点で、全ての受け入れ可能な 'object'タイプをリスト
[ 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 
default_md         = sha1
x509_extensions    = v3_ca # The extentions to add to the self signed cert
                           # 自己署名証明書へ追加される拡張項目
# Passwords for private keys if not present they will be prompted for 
# 秘密鍵用のパスワード、存在しないとき入力を促される
# input_password = secret 
# output_password = secret
# This sets a mask for permitted string types. There are several options. 
# 許可される文字列型のためのマスクを設定。以下のような色々なオプションがある。
# default: PrintableString, T61String, BMPString. 
# pkix : PrintableString, BMPString. 
# utf8only: only UTF8Strings. 
# nombstr : PrintableString, T61String (no BMPStrings or UTF8Strings). 
# MASK:XXXX a literal mask value. 
# WARNING: current versions of Netscape crash on BMPStrings or UTF8Strings 
# so use this option with caution! 
# 警告:Netscape の現在のヴァージョンは BMPStrings か UTF8Strings では
# クラッシュするので、このオプションは注意して!
string_mask = nombstr
# req_extensions = v3_req # The extensions to add to a certificate request
#                           証明書要求に追加する拡張項目
[ req_distinguished_name ] 
countryName         = Country Name (2 letter code) 
countryName_default = FJ 
countryName_min     = 2 
countryName_max     = 2
 
stateOrProvinceName         = State or Province Name (full name) #国名・州名(フルネームで)
stateOrProvinceName_default = Fiji
localityName          = Locality Name (eg, city) # 地方名(市など)
localityName_default  = Suva
0.organizationName         = Organization Name (eg, company) #組織名(会社など)
0.organizationName_default = SOPAC
# 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 = ITU
commonName       = Common Name (eg, YOUR name) #通常の名前(あなたの名前など)
commonName_max   = 64
emailAddress     = Email Address #メイルアドレス
emailAddress_max = 40
# SET-ex3   = SET extension number 3
[ req_attributes ] 
challengePassword     = A challenge password #チャレンジパスワード
challengePassword_min = 4 
challengePassword_max = 20
unstructuredName      = An optional company name #オプションの会社名
[ usr_cert ]
# These extensions are added when 'ca' signs a request.
# This goes against PKIX guidelines but some CAs do it and some software 
# requires this to avoid interpreting an end user certificate as a CA.
# これらの拡張項目は 'ca' が要求に署名するとき追加される。
# これは PKIX 勧告に反するが、CA にはそうするものもあり、
# ソフトウェアによってはエンドユーザ証明書を CA と解釈するのを避けるため
# 要求するものもある。
basicConstraints=CA:FALSE
# Here are some examples of the usage of nsCertType. If it is omitted 
# the certificate can be used for anything *except* object signing.
# ここは nsCertType の使い方の例。もし省略されれば、
# その証明書はオブジェクト署名を *除いて* 何にでも用いることができる。
# This is OK for an SSL server. 
# SSL サーバのため、これは OK.
# nsCertType   = server
# For an object signing certificate this would be used. 
# オブジェクト署名証明書のために用いられることも。
# nsCertType = objsign
# For normal client use this is typical 
# 普通のクライアントの使用では、これは典型的。
# nsCertType = client, email
# and for everything including object signing: 
# そして、オブジェクト署名を含む全てについて:
# nsCertType = client, email, objsign
# This is typical in keyUsage for a client certificate. 
# これはクライアントの証明書についての keyUsage では典型的
# keyUsage = nonRepudiation, digitalSignature, keyEncipherment
# This will be displayed in Netscape's comment listbox. 
# これは Netscape のコメントリストボックスに表示される。
nsComment  = "Certificate issued by https://www.sopac.org/ssl/"
# PKIX recommendations harmless if included in all certificates. 
# すべての証明書に含まれていれば PKIX 勧告は問題なし。
subjectKeyIdentifier=hash 
authorityKeyIdentifier=keyid,issuer:always
# This stuff is for subjectAltName and issuerAltname. 
# Import the email address. 
# この内容は subjectAltName と issuerAltname のため。
# email アドレスをインポート。
# subjectAltName=email:copy
# Copy subject details 
# 項目の詳細をコピー
# issuerAltName=issuer:copy
# This is the base URL for all others URL addresses 
# if not supplied
# これは、指定されないときの、全てのほかの URL アドレスの
# ためのベース URL として使われる。
nsBaseUrl  = https://www.sopac.org/ssl/
# This is the link where to download the latest Certificate
# Revocation List (CRL)
# これは最新の失効証明書リスト(CRL)をダウンロードする
# 場所のリンク
nsCaRevocationUrl = https://www.sopac.org/ssl/sopac-ca.crl
# This is the link where to revoke the certificate
# これは証明書を破棄(無効化)するための場所のリンク
nsRevocationUrl  = https://www.sopac.org/ssl/revocation.html? 
# This is the location where the certificate can be renewed
# 証明書を更新するための場所のリンク
nsRenewalUrl  = https://www.sopac.org/ssl/renewal.html? 
# This is the link where the CA policy can be found
# CA ポリシーがある場所のリンク
nsCaPolicyUrl  = https://www.sopac.org/ssl/policy.html 
# This is the link where we can get the issuer certificate
# 発行者の証明書がある場所のリンク
issuerAltName = URI:https://www.sopac.org/ssl/sopac.crt
# This is the link where to get the latest CRL
# 最新の CRL がある場所のリンク
crlDistributionPoints = URI:https://www.sopac.org/ssl/sopac-ca.crl
[ v3_ca ]
# Extensions for a typical CA
# 典型的な CA のための拡張項目
# PKIX recommendation.
# PKIX 勧告の推奨
 
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid:always,issuer:always
# This is what PKIX recommends but some broken software chokes on critical 
# extensions. 
# PKIX はそう勧めているが、いいかげんなソフトウェアには
# critical 拡張を受け入れないものもある。
# basicConstraints = critical,CA:true 
# So we do this instead. 
# だから代わりにこうする。
basicConstraints = CA:true
# Key usage: this is typical for a CA certificate. However since it will 
# prevent it being used as an test self-signed certificate it is best 
# left out by default. 
# 鍵の使い方: CA 証明書の場合に典型的。しかしながら、
# テスト用自己署名証明書として用いられるのを妨げるだろうから、
# デフォルトで省いておくのがベスト。
# keyUsage = cRLSign, keyCertSign
# Some might want this also 
# これも必要な場合もある
# nsCertType = sslCA, emailCA
# Include email address in subject alt name: another PKIX recommendation 
# 本人の別名に email アドレスを含める: PKIX のまた別の推奨
# subjectAltName=email:copy 
# Copy issuer details 
# 発行者の詳細をコピー
# issuerAltName=issuer:copy
# RAW DER hex encoding of an extension: beware experts only! 
# 拡張の RAW DER 16進エンコーディング:ご用心、エキスパートのみ!
# 1.2.3.5=RAW:02:03 
# You can even override a supported extension: 
# サポートされた拡張に優先させることも可能
# basicConstraints= critical, RAW:30:03:01:01:FF
# This will be displayed in Netscape's comment listbox. 
# これが Netscape のコメントリストボックスに表示される。
nsComment  = "Certificate issued by https://www.sopac.org/ssl/"
# This is the base URL for all others URL addresses 
# if not supplied
# 与えられていないなら
# 他の全ての URL アドレスのための使うベース URL.
nsBaseUrl  = https://www.sopac.org/ssl/
# This is the link where to download the latest Certificate
# Revocation List (CRL)
# 最新の失効証明書リスト(CRL)をダウンロードするための
# 場所のリンク
nsCaRevocationUrl = https://www.sopac.org/ssl/sopac-ca.crl
# This is the link where to revoke the certificate
# 証明書を破棄(無効化)するための場所のリンク
nsRevocationUrl  = https://www.sopac.org/ssl/revocation.html? 
# This is the location where the certificate can be renewed
# 証明書を更新するための更新のリンク
nsRenewalUrl  = https://www.sopac.org/ssl/renewal.html? 
# This is the link where the CA policy can be found
# CA ポリシーがある場所のリンク
nsCaPolicyUrl  = https://www.sopac.org/ssl/policy.html 
# This is the link where we can get the issuer certificate
# 発行者の証明書がある場所のリンク
issuerAltName = URI:https://www.sopac.org/ssl/sopac.crt
# This is the link where to get the latest CRL
# 最新の CRL がある場所のリンク
crlDistributionPoints = URI:https://www.sopac.org/ssl/sopac-ca.crl
[ crl_ext ]
# CRL extensions. 
# Only issuerAltName and authorityKeyIdentifier make any sense in a CRL.
# CRL 拡張項目。
# issuerAltName と authorityKeyIdentifier 項目だけが CRL の中で意味を持つ
# issuerAltName=issuer:copy 
authorityKeyIdentifier=keyid:always,issuer:always
#----End----

openssl.cnf について二、三のコメント。

2.1.3. 認証局を作る

認証局を作るには、正確に openssl.cnf を編集したのち、以下のコマンドを使います:

CA.pl -newca

このユーティリティはあなたの CA 証明書として発効させる証明書ファイルを選ぶか、 または新たに作るように尋ねてきます。 練習のために以下の手順に従って一つ作ってみましょう。 次の章では、このデフォルトで作成された CA を上書きして、 もっと長く使える新しいものを作成します。 CA.pl は 365 日間の証明書だけしか作ってくれません。