|
| 1 | +### 設定ファイル形式 |
| 2 | + |
| 3 | +wolfCLUは `req` および `ca` コマンドでOpenSSLスタイルの設定ファイルをサポートしています。このページでは、サポートされているディレクティブについて説明します。 |
| 4 | + |
| 5 | +## 基本構造 |
| 6 | + |
| 7 | +設定ファイルはINIスタイルの形式で、セクションとキー・バリューのペアで構成されます: |
| 8 | + |
| 9 | +```ini |
| 10 | +[section_name] |
| 11 | +key = value |
| 12 | +``` |
| 13 | + |
| 14 | +## REQコマンドの設定 |
| 15 | + |
| 16 | +### メインセクション |
| 17 | + |
| 18 | +`[req]` セクションには主要な設定が含まれます: |
| 19 | + |
| 20 | +| ディレクティブ | 説明 | |
| 21 | +|---------------|------| |
| 22 | +| `prompt` | `no` に設定すると対話的なプロンプトを無効化 | |
| 23 | +| `default_bits` | デフォルトの鍵サイズ(ビット単位、例:2048) | |
| 24 | +| `default_md` | デフォルトのハッシュアルゴリズム(例:sha256) | |
| 25 | +| `default_keyfile` | デフォルトの鍵ファイルパス | |
| 26 | +| `distinguished_name` | DN フィールドを含むセクション名 | |
| 27 | +| `attributes` | 属性を含むセクション名 | |
| 28 | +| `x509_extensions` | X509拡張を含むセクション名 | |
| 29 | + |
| 30 | +### Distinguished Name セクション |
| 31 | + |
| 32 | +distinguished name セクション(`distinguished_name` で参照)は証明書のサブジェクトフィールドを定義します: |
| 33 | + |
| 34 | +| ディレクティブ | 説明 | |
| 35 | +|---------------|------| |
| 36 | +| `countryName` | 国コード(2文字、例:JP、US) | |
| 37 | +| `stateOrProvinceName` | 都道府県名 | |
| 38 | +| `localityName` | 市区町村名 | |
| 39 | +| `organizationName` | 組織名 | |
| 40 | +| `organizationalUnitName` | 部署名 | |
| 41 | +| `commonName` または `CN` | コモンネーム(例:ドメイン名) | |
| 42 | +| `emailAddress` | メールアドレス | |
| 43 | +| `name` | 名前 | |
| 44 | +| `surname` | 姓 | |
| 45 | +| `givenName` | 名 | |
| 46 | +| `initials` | イニシャル | |
| 47 | +| `dnQualifier` | DN修飾子 | |
| 48 | + |
| 49 | +各フィールドにはオプションの修飾子を設定できます: |
| 50 | + |
| 51 | +| 修飾子 | 説明 | |
| 52 | +|--------|------| |
| 53 | +| `<field>_default` | 指定されない場合のデフォルト値 | |
| 54 | +| `<field>_min` | 最小文字数 | |
| 55 | +| `<field>_max` | 最大文字数 | |
| 56 | + |
| 57 | +### 属性セクション |
| 58 | + |
| 59 | +属性セクション(`attributes` で参照)はPKCS#9属性を定義します: |
| 60 | + |
| 61 | +| ディレクティブ | 説明 | |
| 62 | +|---------------|------| |
| 63 | +| `challengePassword` | PKCS#9 チャレンジパスワード | |
| 64 | +| `unstructuredName` | PKCS#9 非構造化名 | |
| 65 | + |
| 66 | +## X509拡張セクション |
| 67 | + |
| 68 | +拡張セクション(`x509_extensions` で参照)は証明書の拡張を定義します: |
| 69 | + |
| 70 | +| ディレクティブ | 説明 | |
| 71 | +|---------------|------| |
| 72 | +| `basicConstraints` | CA制約とパス長 | |
| 73 | +| `subjectKeyIdentifier` | サブジェクト鍵識別子 | |
| 74 | +| `authorityKeyIdentifier` | 認証局鍵識別子 | |
| 75 | +| `keyUsage` | 鍵用途フラグ | |
| 76 | +| `subjectAltName` | サブジェクト代替名 | |
| 77 | + |
| 78 | +### basicConstraints |
| 79 | + |
| 80 | +証明書がCAかどうかと、最大パス長を定義します。 |
| 81 | + |
| 82 | +形式: `[critical, ]CA:TRUE|FALSE[, pathlen:<n>]` |
| 83 | + |
| 84 | +| 値 | 説明 | |
| 85 | +|----|------| |
| 86 | +| `critical` | クリティカル拡張としてマーク | |
| 87 | +| `CA:TRUE` | CA証明書である | |
| 88 | +| `CA:FALSE` | CA証明書ではない | |
| 89 | +| `pathlen:<n>` | 最大証明書パス長 | |
| 90 | + |
| 91 | +例: |
| 92 | +```ini |
| 93 | +basicConstraints = critical, CA:TRUE, pathlen:0 |
| 94 | +basicConstraints = CA:FALSE |
| 95 | +``` |
| 96 | + |
| 97 | +### keyUsage |
| 98 | + |
| 99 | +証明書に含まれる鍵の用途を定義します。 |
| 100 | + |
| 101 | +形式: `[critical, ]<usage>[, <usage>...]` |
| 102 | + |
| 103 | +| 値 | 説明 | |
| 104 | +|----|------| |
| 105 | +| `digitalSignature` | デジタル署名 | |
| 106 | +| `nonRepudiation` | 否認防止(`contentCommitment` も可) | |
| 107 | +| `keyEncipherment` | 鍵暗号化 | |
| 108 | +| `dataEncipherment` | データ暗号化 | |
| 109 | +| `keyAgreement` | 鍵共有 | |
| 110 | +| `keyCertSign` | 証明書署名 | |
| 111 | +| `cRLSign` | CRL署名 | |
| 112 | +| `encipherOnly` | 暗号化のみ(keyAgreementと併用) | |
| 113 | +| `decipherOnly` | 復号のみ(keyAgreementと併用) | |
| 114 | + |
| 115 | +例: |
| 116 | +```ini |
| 117 | +keyUsage = critical, digitalSignature, keyEncipherment |
| 118 | +keyUsage = keyCertSign, cRLSign |
| 119 | +``` |
| 120 | + |
| 121 | +### subjectKeyIdentifier |
| 122 | + |
| 123 | +証明書内の公開鍵を識別します。 |
| 124 | + |
| 125 | +| 値 | 説明 | |
| 126 | +|----|------| |
| 127 | +| `hash` | 公開鍵のハッシュを使用 | |
| 128 | + |
| 129 | +例: |
| 130 | +```ini |
| 131 | +subjectKeyIdentifier = hash |
| 132 | +``` |
| 133 | + |
| 134 | +### subjectAltName |
| 135 | + |
| 136 | +証明書サブジェクトの追加識別子を指定します。`@section_name` を使用して代替名を含むセクションを参照します。 |
| 137 | + |
| 138 | +例: |
| 139 | +```ini |
| 140 | +subjectAltName = @alt_names |
| 141 | +``` |
| 142 | + |
| 143 | +#### 代替名セクション |
| 144 | + |
| 145 | +| ディレクティブ | 説明 | |
| 146 | +|---------------|------| |
| 147 | +| `DNS.<n>` | DNS名(例:`DNS.1 = example.com`) | |
| 148 | +| `IP.<n>` | IPアドレス(例:`IP.1 = 192.168.1.1`) | |
| 149 | +| `URI.<n>` | URI(例:`URI.1 = https://example.com`) | |
| 150 | +| `email.<n>` | メールアドレス(例:`email.1 = admin@example.com`) | |
| 151 | +| `RID.<n>` | 登録ID / OID | |
| 152 | + |
| 153 | +例: |
| 154 | +```ini |
| 155 | +[alt_names] |
| 156 | +DNS.1 = example.com |
| 157 | +DNS.2 = www.example.com |
| 158 | +IP.1 = 192.168.1.1 |
| 159 | +email.1 = admin@example.com |
| 160 | +``` |
| 161 | + |
| 162 | +## CAコマンドの設定 |
| 163 | + |
| 164 | +### メインセクション |
| 165 | + |
| 166 | +`[ca]` セクションはデフォルトのCAセクションを指定します: |
| 167 | + |
| 168 | +```ini |
| 169 | +[ca] |
| 170 | +default_ca = CA_default |
| 171 | +``` |
| 172 | + |
| 173 | +### CAセクション |
| 174 | + |
| 175 | +CAセクション(例:`[CA_default]`)にはCA固有の設定が含まれます: |
| 176 | + |
| 177 | +| ディレクティブ | 説明 | |
| 178 | +|---------------|------| |
| 179 | +| `serial` | シリアル番号を含むファイル(16進形式) | |
| 180 | +| `new_certs_dir` | 新規証明書のディレクトリ | |
| 181 | +| `certificate` | CA証明書ファイル | |
| 182 | +| `private_key` | CA秘密鍵ファイル | |
| 183 | +| `default_days` | デフォルトの有効期間(日数) | |
| 184 | +| `default_md` | デフォルトのハッシュアルゴリズム | |
| 185 | +| `x509_extensions` | 拡張のセクション名 | |
| 186 | +| `policy` | DNポリシーのセクション名 | |
| 187 | +| `database` | 証明書データベースファイル | |
| 188 | +| `unique_subject` | 一意のサブジェクトを要求 | |
| 189 | +| `crl_dir` | CRLのディレクトリ | |
| 190 | +| `crl` | CRLファイル | |
| 191 | +| `RANDFILE` | 乱数シードファイル | |
| 192 | + |
| 193 | +## 設定例 |
| 194 | + |
| 195 | +### サーバー証明書リクエスト |
| 196 | + |
| 197 | +```ini |
| 198 | +[req] |
| 199 | +prompt = no |
| 200 | +default_bits = 2048 |
| 201 | +default_md = sha256 |
| 202 | +distinguished_name = req_dn |
| 203 | +x509_extensions = v3_server |
| 204 | + |
| 205 | +[req_dn] |
| 206 | +countryName = JP |
| 207 | +stateOrProvinceName = Tokyo |
| 208 | +localityName = Shinjuku |
| 209 | +organizationName = Example Corp |
| 210 | +commonName = example.com |
| 211 | +emailAddress = info@example.com |
| 212 | + |
| 213 | +[v3_server] |
| 214 | +basicConstraints = critical, CA:FALSE |
| 215 | +keyUsage = digitalSignature, keyEncipherment |
| 216 | +subjectKeyIdentifier = hash |
| 217 | +subjectAltName = @alt_names |
| 218 | + |
| 219 | +[alt_names] |
| 220 | +DNS.1 = example.com |
| 221 | +DNS.2 = www.example.com |
| 222 | +IP.1 = 192.168.1.1 |
| 223 | +``` |
| 224 | + |
| 225 | +使用方法: |
| 226 | +``` |
| 227 | +wolfssl req -new -config server.conf -key server.priv -out server.csr |
| 228 | +wolfssl req -new -x509 -config server.conf -key server.priv -out server.pem -days 365 |
| 229 | +``` |
| 230 | + |
| 231 | +### CA証明書 |
| 232 | + |
| 233 | +```ini |
| 234 | +[req] |
| 235 | +prompt = no |
| 236 | +default_bits = 4096 |
| 237 | +default_md = sha256 |
| 238 | +distinguished_name = ca_dn |
| 239 | +x509_extensions = v3_ca |
| 240 | + |
| 241 | +[ca_dn] |
| 242 | +countryName = JP |
| 243 | +stateOrProvinceName = Tokyo |
| 244 | +localityName = Shinjuku |
| 245 | +organizationName = Example Corp |
| 246 | +commonName = Example CA |
| 247 | + |
| 248 | +[v3_ca] |
| 249 | +basicConstraints = critical, CA:TRUE, pathlen:1 |
| 250 | +keyUsage = critical, keyCertSign, cRLSign |
| 251 | +subjectKeyIdentifier = hash |
| 252 | +``` |
| 253 | + |
| 254 | +使用方法: |
| 255 | +``` |
| 256 | +wolfssl req -new -x509 -config ca.conf -key ca.priv -out ca.pem -days 3650 |
| 257 | +``` |
| 258 | + |
| 259 | +### シンプルなCSR(最小構成) |
| 260 | + |
| 261 | +```ini |
| 262 | +[req] |
| 263 | +prompt = no |
| 264 | +distinguished_name = req_dn |
| 265 | + |
| 266 | +[req_dn] |
| 267 | +commonName = myserver |
| 268 | +``` |
| 269 | + |
| 270 | +使用方法: |
| 271 | +``` |
| 272 | +wolfssl req -new -config simple.conf -key server.priv -out server.csr |
| 273 | +``` |
| 274 | + |
| 275 | +## 制限事項 |
| 276 | + |
| 277 | +### シリアル番号ファイル |
| 278 | + |
| 279 | +`serial` ディレクティブは、16進形式のシリアル番号を含むファイルを指定します: |
| 280 | + |
| 281 | +``` |
| 282 | +01 |
| 283 | +``` |
| 284 | + |
| 285 | +**注意:** 現在のバージョン(v0.1.8)では、設定ファイルベースのシリアル番号管理にパス処理の問題があります。この問題が解決されるまで、コマンドライン引数を直接使用することを推奨します。設定ファイルを使用しない場合、wolfCLUは署名された各証明書にランダムなシリアル番号を生成します。 |
0 commit comments