3

SSLの作成を自動化するためにFabricを使用していますが、次のようなものを実行すると

local('openssl genrsa  -out /etc/ssl/'+hostname+'/'+hostname+'.key 2048')

国、州、電子メールアドレスなどの入力を求められます。これらのプロンプトでユーザーが入力する必要がないようにするために (おそらく openssl.cnf を使用して) できることはありますか? または、通常、次のようなものを使用してハッキングするだけですか?期待する?

アップデート:

prompt=noopenssl.cnfcdをに入れたら/ssdhome/development/server、次を実行します。

sudo openssl req -new -key './server.key' -out './server.csr' -config='./openssl.cnf'

helpopensslは、上記のコマンドを実行する代わりに情報を出力します。どこで間違ったのですか?

更新 2 : -config には「=」記号ではなく、スペースが必要です。解決しました。私のopenssl.cnfのこのコピーにもリンクして、動作させます:

https://help.ubuntu.com/community/OpenSSL

4

2 に答える 2

2

python fabric でプロンプトに自動的に答える方法を参照してください。

from ilogue.fexpect import expect, expecting, run

def sample():

    private_key = "password"
    hostname = "ubuntu"
    output_dir = '/etc/ssl/' + hostname
    prompts = []
    prompts += expect('Enter pass phrase for private.key:',private_key)
    prompts += expect('Verifying - Enter pass phrase for private.key:private_key',private_key)
    prompts += expect('Enter pass phrase for %s/server.key:' % output_dir, private_key)
    prompts += expect('Country Name \(2 letter code\) \[AU\]:','AU')
    prompts += expect('State or Province Name \(full name\) \[Some-State\]:','State')
    prompts += expect('Locality Name \(eg, city\) \[\]:','City')
    prompts += expect('Organization Name \(eg, company\) \[Internet Widgits Pty Ltd\]:','Company')
    prompts += expect('Organizational Unit Name \(eg, section\) \[\]:','Section')
    prompts += expect('Common Name \(e.g. server FQDN or YOUR name\) \[\]:','FQDN')
    prompts += expect('Email Address \[\]:','email@foo.com')
    prompts += expect('A challenge password \[\]:','challenge_password')
    prompts += expect('An optional company name \[\]:','optional_company')

    with expecting(prompts):
        run('openssl genrsa -des3 -out %s/server.key 2048' % output_dir)
        run('openssl req -new -key %s/server.key -out %s/server.csr' % (output_dir, output_dir))

# fab sample -H localhost

正規表現がexpect()に適用されるため、[、]、(、) ...をエスケープする必要があります。

于 2013-07-22T15:54:54.827 に答える
1

https://help.ubuntu.com/community/OpenSSLを使用してprompt=no、エラーのスローを停止-config ./openssl.cnfし、ユーザー alecxe のおかげでプロンプトを自動化しました。

于 2013-07-22T00:47:23.527 に答える