Skip to content

Commit 2fd4f76

Browse files
authored
Merge pull request #822 from jettero/4.0-pr815-fixes
Minor fixes relating to PR815
2 parents e7f6aec + 6175b58 commit 2fd4f76

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

hubblestack/utils/signing.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ def read_certs(*fnames):
185185
"""
186186
for fname in fnames:
187187
if fname.strip().startswith('--') and '\x0a' in fname:
188-
for i in split_certs(cStringIO.StringIO(fname)):
188+
siofh = cStringIO.StringIO(fname)
189+
siofh.name = '<a string>'
190+
for i in split_certs(siofh):
189191
yield i
190192
elif os.path.isfile(fname):
191193
try:
@@ -201,9 +203,10 @@ def read_certs(*fnames):
201203

202204
def stringify_cert_files(cert):
203205
"""this function returns a string version of cert(s) for returner"""
204-
if type(cert) is list and len(cert) >= 1:
206+
if isinstance(cert, (tuple,list)) and cert:
205207
return ', '.join([str(c) for c in cert])
206-
elif type(cert) is file:
208+
elif hasattr(cert, 'name'):
209+
# probably a file handle
207210
return cert.name
208211
return str(cert)
209212

@@ -343,6 +346,7 @@ def __init__(self, public_crt, ca_crt):
343346
log_level = log.critical
344347
elif status == STATUS.UNKNOWN:
345348
log_level = log.error
349+
str_public = stringify_cert_files(public_crt)
346350
log_level('public cert | file: "%s" | status: %s | digest: "%s" | X509 error code: %s | depth: %s | message: "%s"',
347351
str_public, status, digest, code, depth, message)
348352

0 commit comments

Comments
 (0)