@@ -114,6 +114,7 @@ def split_certs(fh):
114
114
else :
115
115
ret += line
116
116
if line .startswith ('----' ):
117
+ ret = ret .encode ()
117
118
try :
118
119
yield ossl .load_certificate (ossl .FILETYPE_PEM , ret )
119
120
except Exception as e :
@@ -186,7 +187,7 @@ def __init__(self, public_crt, ca_crt):
186
187
if d in already :
187
188
continue
188
189
already .add (d )
189
- d += " " + stringify_ossl_cert (c )
190
+ d = d . decode () + " " + stringify_ossl_cert (c )
190
191
log .debug ('adding %s as a trusted certificate approver' , d )
191
192
self .store .add_cert (c )
192
193
self .trusted .append (d )
@@ -196,7 +197,7 @@ def __init__(self, public_crt, ca_crt):
196
197
if d in already :
197
198
continue
198
199
already .add (d )
199
- d += " " + stringify_ossl_cert (c )
200
+ d = d . decode () + " " + stringify_ossl_cert (c )
200
201
log .debug ('checking to see if %s is trustworthy' , d )
201
202
try :
202
203
ossl .X509StoreContext (self .store , c ).verify_certificate ()
@@ -213,7 +214,7 @@ def __init__(self, public_crt, ca_crt):
213
214
if d in already :
214
215
continue
215
216
already .add (d )
216
- d += " " + stringify_ossl_cert (c )
217
+ d = d . decode () + " " + stringify_ossl_cert (c )
217
218
log .debug ('checking to see if %s is a valid leaf cert' , d )
218
219
try :
219
220
ossl .X509StoreContext (self .store , c ).verify_certificate ()
@@ -245,7 +246,7 @@ def __init__(self, public_crt, ca_crt):
245
246
def stringify_ossl_cert (c ):
246
247
if isinstance (c , (list ,tuple )):
247
248
return ', ' .join ([ stringify_ossl_cert (x ) for x in c ])
248
- return '/' .join ([ '=' .join (x ) for x in c .get_subject ().get_components () ])
249
+ return '/' .join ([ '=' .join ([ x_ . decode () for x_ in x ] ) for x in c .get_subject ().get_components () ])
249
250
250
251
def jsonify (obj , indent = 2 ):
251
252
return json .dumps (obj , indent = indent )
@@ -285,7 +286,7 @@ def hash_target(fname, obj_mode=False, chosen_hash=None):
285
286
if obj_mode :
286
287
return hasher , chosen_hash
287
288
digest = hasher .finalize ()
288
- hd = '' .join ([ '{:02x}' .format (ord ( x ) ) for x in digest ])
289
+ hd = '' .join ([ '{:02x}' .format (x ) for x in digest ])
289
290
log .debug ('hashed %s: %s' , fname , hd )
290
291
return hd
291
292
@@ -453,7 +454,7 @@ def verify_files(targets, mfname='MANIFEST', sfname='SIGNATURE', public_crt='pub
453
454
# without a matching SIGNATURE
454
455
ret [vfname ] = STATUS .FAIL
455
456
# fix any normalized names so the caller gets back their specified targets
456
- for k ,v in xlate .iteritems ():
457
+ for k ,v in xlate .items ():
457
458
ret [v ] = ret .pop (k )
458
459
return ret
459
460
0 commit comments