openssl この「テンプレートがありません。テンプレートを設定してください」というCSRテンプレートエラーを生成します。

openssl この「テンプレートがありません。テンプレートを設定してください」というCSRテンプレートエラーを生成します。

Amazon Linux AMI 2017.03.0イメージからCSRを作成しようとしています。 test.key を生成するには、次のコマンドを実行します。

[root]# openssl genrsa -out test.key 2048
Generating RSA private key, 2048 bit long modulus
............+++
.........................+++
e is 65537 (0x10001)
[root]#

次に、次のコマンドを実行します。

[root]# openssl req -new -sha256 -key test.key -out test.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
No template, please set one up.
problems making Certificate Request
[root]#

「テンプレートがありません。1つを設定してください」はopenssl.confファイルに関連しているようです。

私のopenssl設定は次のとおりです。

[root]# pwd
/etc/ssl
[root]# ls -al
total 12
drwxr-xr-x  2 root root 4096 Apr  3 22:53 .
drwxr-xr-x 82 root root 4096 Apr 21 10:54 ..
lrwxrwxrwx  1 root root   16 Jan 20 23:25 certs -> ../pki/tls/certs
-rw-r--r--  1 root root  138 Apr  3 22:53 openssl.cnf
[root]# cat openssl.cnf
[ ssl_client ]
basicConstraints = CA:FALSE
nsCertType = client
keyUsage = digitalSignature, keyEncipherment
extendedKeyUsage = clientAuth
[root]# rpm -q -a |grep openssl
openssl-1.0.1k-15.99.amzn1.x86_64
[root]#

openssl テンプレートの作成に関する情報が多くないようです。誰でも私を助けたり、例やチュートリアルへのリンクを提供したりできますか?

ベストアンサー1

csr の作成時に ssl_client セクションの内容は適用されません。これは、CSRに署名したときにCAが証明書に追加し、セクション名で参照されるx509v3拡張属性です。

openssl x509 ... -extensions ssl_client

件名フィールドを作成する必要がある場合は、次の方法を使用する必要があります。

openssl req -new -sha256 -key test.key -out test.csr -subj "/C=SM/ST=somecountry/L=someloc/O=someorg/OU=somedept/CN=exa‌​mple.com"

reqまた、セクションでreq_distinguished_nameデフォルト値を指定する方法もあります。に指定して、コマンドのデフォルト値をreq設定できます。openssl req ...仕様を使用req_distinguished_nameすると、トピックDNコンポーネントの制限を設定し、通常呼び出される対話型CSR生成のデフォルト値を設定できますopenssl req -new ...

デフォルト値は次のように設定できます。

[ req_distinguished_name ]
countryName_default             = SM
stateOrProvinceName_default     = somecountry
localityName_default            = someloc
...

コマンドラインopensslを使用してタスクを実行するときに一般的に参照する2つの素晴らしいページがあります。

https://jamielinux.com/docs/openssl-certificate-authority/appendix/root-configuration-file.html

https://www.phildev.net/ssl/opensslconf.html

おすすめ記事