keyUsageコマンドが見つかりません(非対話型モードで証明書を生成するために使用されます)

keyUsageコマンドが見つかりません(非対話型モードで証明書を生成するために使用されます)

私のウェブサイトの証明書ファイルを作成したいと思います。

以前は、この作業には非対話型スクリプトを使用していましたが、うまくいきました。

これでこのスクリプトを再利用したいのですが、次の行で停止します。 keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment 次のエラーが発生します。

./scripts/generate-ssl-certificat.sh: 行 16: keyUsage: コマンドが見つかりません

Ubuntu 18システムに次のパッケージをインストールしました。

  • sudo apt-get インストール openssl SSL-cert
  • sudo apt-get インストール ca 証明書 -y

keyUsageを実装するにはどのパッケージが必要ですか?


以下は、自動生成された証明書スクリプトです。

mkdir ~/certs
cd ~/certs

### Certificat Authority
openssl genrsa -des3 -out myCA.key 2048 # generate Certificat Authority key
openssl req -x509 -new -nodes -key myCA.key -sha256 -days 1825 -out myCA.pem # generate root certificat

### Certificat webSite
openssl genrsa -out compty-tmp.key 2048
openssl req -new -key compty-tmp.key -out compty-tmp.csr


### create compty-tmp.ext
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names

[alt_names]
DNS.1 = compty-tmp

### create the certificate: using our CSR, the CA private key, the CA certificate, and the config file:
openssl x509 -req -in compty-tmp.csr -CA myCA.pem -CAkey myCA.key \
-CAcreateserial -out compty-tmp.crt -days 825 -sha256 -extfile compty-tmp.ext

ベストアンサー1

次のセクション:

### create compty-tmp.ext
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names

[alt_names]
DNS.1 = compty-tmp

compty-tmp.ext最後の行のオプションは、OpenSSLに渡される別のファイル()に生成されることを意味します。-ext compty-tmp.ext上記の部分はスクリプトではなく、OpenSSL設定ファイル形式です。

最初の2行には等号の前にスペースがないため、シェルはそれを変数の割り当てとして解釈します。 3行目には、等号(OpenSSL構成ファイルで許可されています)の前にスペースが含まれているため、シェルはそれを好きではありません。

したがって、上記のセクションを新しいファイルに切り捨て、次をスクリプトとして保持します。

mkdir ~/certs
cd ~/certs

### Certificat Authority
openssl genrsa -des3 -out myCA.key 2048 # generate Certificat Authority key
openssl req -x509 -new -nodes -key myCA.key -sha256 -days 1825 -out myCA.pem # generate root certificat

### Certificat webSite
openssl genrsa -out compty-tmp.key 2048
openssl req -new -key compty-tmp.key -out compty-tmp.csr

### create the certificate: using our CSR, the CA private key, the CA certificate, and the config file:
openssl x509 -req -in compty-tmp.csr -CA myCA.pem -CAkey myCA.key \
-CAcreateserial -out compty-tmp.crt -days 825 -sha256 -extfile compty-tmp.ext

おすすめ記事