interface: fix cert handling
notably os.unlink cannot be inside the "with open"
This commit is contained in:
@@ -103,19 +103,19 @@ class Interface(PrintError):
|
|||||||
if exists:
|
if exists:
|
||||||
with open(self.cert_path, 'r') as f:
|
with open(self.cert_path, 'r') as f:
|
||||||
contents = f.read()
|
contents = f.read()
|
||||||
if contents != '': # if not CA signed
|
if contents != '': # if not CA signed
|
||||||
|
try:
|
||||||
|
b = pem.dePem(contents, 'CERTIFICATE')
|
||||||
|
except SyntaxError:
|
||||||
|
exists = False
|
||||||
|
else:
|
||||||
|
x = x509.X509(b)
|
||||||
try:
|
try:
|
||||||
b = pem.dePem(contents, 'CERTIFICATE')
|
x.check_date()
|
||||||
except SyntaxError:
|
except x509.CertificateError as e:
|
||||||
|
self.print_error("certificate problem", e)
|
||||||
|
os.unlink(self.cert_path)
|
||||||
exists = False
|
exists = False
|
||||||
else:
|
|
||||||
x = x509.X509(b)
|
|
||||||
try:
|
|
||||||
x.check_date()
|
|
||||||
except x509.CertificateError as e:
|
|
||||||
self.print_error("certificate problem", e)
|
|
||||||
os.unlink(self.cert_path)
|
|
||||||
exists = False
|
|
||||||
if not exists:
|
if not exists:
|
||||||
ca_signed = await self.is_server_ca_signed(ca_sslc)
|
ca_signed = await self.is_server_ca_signed(ca_sslc)
|
||||||
if ca_signed:
|
if ca_signed:
|
||||||
|
|||||||
Reference in New Issue
Block a user