Commit 5d877896 authored by Tom Niget's avatar Tom Niget

Properly close popen

parent 57f204ca
...@@ -77,11 +77,12 @@ def main(): ...@@ -77,11 +77,12 @@ def main():
print("WARNING: it is strongly recommended to use --fingerprint option.") print("WARNING: it is strongly recommended to use --fingerprint option.")
network = x509.networkFromCa(ca) network = x509.networkFromCa(ca)
if config.is_needed: if config.is_needed:
route, err = subprocess.Popen(('ip', '-6', '-o', 'route', 'get', with subprocess.Popen(('ip', '-6', '-o', 'route', 'get',
utils.ipFromBin(network)), utils.ipFromBin(network)),
stdout=subprocess.PIPE).communicate() stdout=subprocess.PIPE) as proc:
sys.exit(err or route and route, err = proc.communicate()
utils.binFromIp(route.split()[8]).startswith(network)) sys.exit(err or route and
utils.binFromIp(route.split()[8]).startswith(network))
create(ca_path, crypto.dump_certificate(crypto.FILETYPE_PEM, ca)) create(ca_path, crypto.dump_certificate(crypto.FILETYPE_PEM, ca))
if config.ca_only: if config.ca_only:
...@@ -90,7 +91,7 @@ def main(): ...@@ -90,7 +91,7 @@ def main():
reserved = 'CN', 'serial' reserved = 'CN', 'serial'
req = crypto.X509Req() req = crypto.X509Req()
try: try:
with open(cert_path) as f: with open(cert_path, "rb") as f:
cert = loadCert(f.read()) cert = loadCert(f.read())
components = dict(cert.get_subject().get_components()) components = dict(cert.get_subject().get_components())
components = {k.decode(): v for k, v in components.items()} components = {k.decode(): v for k, v in components.items()}
......
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