@@ -185,7 +185,9 @@ def read_certs(*fnames):
185
185
"""
186
186
for fname in fnames :
187
187
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 ):
189
191
yield i
190
192
elif os .path .isfile (fname ):
191
193
try :
@@ -201,9 +203,10 @@ def read_certs(*fnames):
201
203
202
204
def stringify_cert_files (cert ):
203
205
"""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 :
205
207
return ', ' .join ([str (c ) for c in cert ])
206
- elif type (cert ) is file :
208
+ elif hasattr (cert , 'name' ):
209
+ # probably a file handle
207
210
return cert .name
208
211
return str (cert )
209
212
@@ -343,6 +346,7 @@ def __init__(self, public_crt, ca_crt):
343
346
log_level = log .critical
344
347
elif status == STATUS .UNKNOWN :
345
348
log_level = log .error
349
+ str_public = stringify_cert_files (public_crt )
346
350
log_level ('public cert | file: "%s" | status: %s | digest: "%s" | X509 error code: %s | depth: %s | message: "%s"' ,
347
351
str_public , status , digest , code , depth , message )
348
352
0 commit comments