Commit ccc5b6b5 authored by Laurent Peuch's avatar Laurent Peuch
Browse files

[fix] simplify code and work without a term environment

parent 3b27770b
...@@ -46,29 +46,25 @@ def renew(login, password): ...@@ -46,29 +46,25 @@ def renew(login, password):
client = response.json()[0] client = response.json()[0]
openssl = pexpect.spawn("openssl req -out CSR.csr -new -newkey rsa:4096 -nodes -keyout client.key", cwd=working_dir, timeout=120) openssl_config = """
[ req ]
openssl.expect("Country Name \(2 letter code\) \[AU\]:") prompt = no
openssl.sendline(".") distinguished_name = req_distinguished_name
openssl.expect("State or Province Name \(full name\) \[Some-State\]:")
openssl.sendline(".") [ req_distinguished_name ]
openssl.expect("Locality Name \(eg, city\) \[\]:") 0.organizationName = .
openssl.sendline(".") organizationalUnitName = .
openssl.expect("Organization Name \(eg, company\) \[Internet Widgits Pty Ltd\]:") emailAddress = %(login)s
openssl.sendline(".") localityName = .
openssl.expect("Organizational Unit Name \(eg, section\) \[\]:") stateOrProvinceName = .
openssl.sendline(".") countryName = BE
openssl.expect("Common Name \(e.g. server FQDN or YOUR name\) \[\]:") commonName = certificate for %(login)s
openssl.sendline("certificate for %s" % login) """ % {"login": login}
openssl.expect("Email Address \[\]:")
openssl.sendline(".") open(os.path.join(working_dir, "config"), "w").write(openssl_config)
openssl.expect("A challenge password \[\]:")
openssl.sendline("")
openssl.expect("An optional company name \[\]:")
openssl.sendline("")
with debug("Generate new cert using openssl"): with debug("Generate new cert using openssl"):
openssl.interact() assert os.system("cd '%s' && openssl req -out CSR.csr -new -newkey rsa:4096 -nodes -keyout client.key -config config" % working_dir) == 0
with debug("See if I already have a cert"): with debug("See if I already have a cert"):
with retry(): with retry():
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment