Note that there are some explanatory texts on larger screens.

plurals
  1. POusing pexpect to automate openssl req -new -key server.key -out server.csr
    primarykey
    data
    text
    <p>I am trying to automate the below dialgoue. I dojnt care what is entered expect for the first password. I am having an hard time tying to get pexpect to work.</p> <pre><code>root@ffffff:/home/ubuntu# openssl req -new -key server.key -out server.csr Enter pass phrase for server.key: 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. ----- Country Name (2 letter code) [AU]: State or Province Name (full name) [Some-State]: Locality Name (eg, city) []: Organization Name (eg, company) [Internet Widgits Pty Ltd]: Organizational Unit Name (eg, section) []: Common Name (e.g. server FQDN or YOUR name) []: Email Address []: Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: </code></pre> <p>Below is my pexpect code:</p> <pre><code> import pexpect child = pexpect.spawn ('openssl req -new -key server.key -out server.csr') child.expect ('key*') child.sendline ('YYYY') child.expect ("Country Name (2 letter code) [AU]:") child.sendline ('US') child.expect ("State or Province Name (full name) [Some-State]:") child.sendline ('HI') child.expect ("Locality Name (eg, city) []:") child.sendline ('US') child.expect ("Organization Name (eg, company) [Internet Widgits Pty Ltd]:") child.sendline ('US') child.expect ("Organizational Unit Name (eg, section) []:") child.sendline ('US') child.expect ("Common Name (e.g. server FQDN or YOUR name) []:") child.sendline ('US') child.expect ("Email Address []:") child.sendline ('US') child.expect ("A challenge password []:") child.sendline ("yy") child.expect ("An optional company name []:") child.sendline ("yy") child.expect(pexpect.EOF) </code></pre> <p>Below is my error:</p> <pre><code>challenge password []: An optional company name []: root@li494-175:/home/ubuntu# clear root@li494-175:/home/ubuntu# python vv.py Traceback (most recent call last): File "vv.py", line 5, in &lt;module&gt; child.expect ("Country Name (2 letter code) [AU]:") File "/usr/local/lib/python2.7/dist-packages/pexpect-2.4-py2.7.egg/pexpect.py", line 1316, in expect return self.expect_list(compiled_pattern_list, timeout, searchwindowsize) File "/usr/local/lib/python2.7/dist-packages/pexpect-2.4-py2.7.egg/pexpect.py", line 1330, in expect_list return self.expect_loop(searcher_re(pattern_list), timeout, searchwindowsize) File "/usr/local/lib/python2.7/dist-packages/pexpect-2.4-py2.7.egg/pexpect.py", line 1401, in expect_loop raise EOF (str(e) + '\n' + str(self)) pexpect.EOF: End Of File (EOF) in read_nonblocking(). Exception style platform. &lt;pexpect.spawn object at 0x2083850&gt; version: 2.4 ($Revision: 516 $) command: /usr/bin/openssl args: ['/usr/bin/openssl', 'req', '-new', '-key', 'server.key', '-out', 'server.csr'] searcher: searcher_re: 0: re.compile("Country Name (2 letter code) [AU]:") buffer (last 100 chars): before (last 100 chars): p_enc.c:539: 140006640854688:error:0906A065:PEM routines:PEM_do_header:bad decrypt:pem_lib.c:476: after: &lt;class 'pexpect.EOF'&gt; match: None </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload