2012-09-28 25 views
5

秘密鍵と公開鍵を生成します。私はOpenSSLが秘密鍵と公開鍵を生成するためのコマンド以下のいるOpenSSLの

openssl genrsa –aes-128-cbc –out priv.pem –passout pass:[privateKeyPass] 2048 

openssl req –x509 –new –key priv.pem –passin pass:[privateKeyPass] -days 3650 –out cert.cer 

をしかし、インクルードは、私が手に最初のコマンドのため を働いていません次のエラー:

usage: genrsa [args] [numbits] 
-des   encrypt the generated key with DES in cbc mode 
-des3   encrypt the generated key with DES in ede cbc mode (168 bit key) 
-seed 
       encrypt PEM output with cbc seed 
-aes128, -aes192, -aes256 
       encrypt PEM output with cbc aes 
-camellia128, -camellia192, -camellia256 
       encrypt PEM output with cbc camellia 
-out file  output the key to 'file 
-passout arg output file pass phrase source 
-f4    use F4 (0x10001) for the E value 
-3    use 3 for the E value 
-engine e  use engine e, possibly a hardware device. 
-rand file:file:... 
       load the file (or the files in the directory) into 
       the random number generator 

私は間違っていますか?

編集: 私は最初のコマンドを解か:

openssl genrsa -aes128 -out privkey.pem 2048 

は、今私はsecoundでエラーを取得:

unknown option –x509 
+0

パラメータの順序が重要なのだろうか? –

答えて

9

'genrsa'はRSAキーを生成します。

'req'は、そのキーを使用してx509スタイルのリクエストを行います。

rsa鍵ペアが必要な場合は、genrsaを使用します。

鍵ペアと署名付きx509要求が必要な場合は、「genrsa」と「req」を使用します。 。

必要に応じて 'REQ' も、あなたのためにそのキー(すなわち、それは 'genrsa' コマンドをカプセル化(およびgendh)を生成することができます

だから:

openssl genrsa -aes128 -out privkey.pem 2048 
openssl req -new -x509 -key privkey.pem 

とほぼ同等です
openssl req -new -x509 -keyout privkey.pem -newkey rsa:2048 

'genrsa'とは異なり、 'req'では暗号化としてaes128を指定できません。

多くのエンタープライズ設定では、適用されるキー暗号化を十分に制御するために、2つのステップで1つの処理を行います。

+0

このコマンドはトリックを行いました:openssl req -new -x509 -key new.pem -days 3650 -out cert.crt多くありがとう – kozla13

+2

-x509は自己署名証明書を生成することに注意してください。証明書要求を生成する場合は、このオプションを省略します。 – Todd

1

私は出力からわかるように、間違ったアルゴリズムを選択します。 -aes-128-cbcの代わりに-aes128を渡すべきではありませんか?

マニュアルから私はがopenssl encの適切なパラメータであると仮定していますが、それがgenrsaで動作する必要があるかどうかはわかりません。

関連する問題