Matthias Güntert wrote:
M2Crypto has a couple of bugs open related that, with potential
workarounds that I haven't yet deemed polished enough to checkin, but
which might help you out:
https://bugzilla.osafoundation.org/show_bug.cgi?id=7530
https://bugzilla.osafoundation.org/show_bug.cgi?id=12151
... Generating the 'subjectKeyIdentifier':
> ...
def get_public_key_fingerprint(self):
h = hashlib.new('sha1')
h.update(self.keypair.as_der())
client_serial = h.hexdigest().upper()
client_serial_hex = ''
for byte in xrange(20):
client_serial_hex += client_serial[byte*2] + client_serial[byte*2
+1]
if byte < 19:
client_serial_hex += ':'
return client_serial_hex
...
More tersely (code golf?):
def get_public_key_fingerprint(self):
digest = hashlib.sha1(self.keypair.as_der()).hexdigest().upper()
return ':'.join(digest[pos : pos+2] for pos in range(0, 40, 2))
--Scott David Daniels
[email protected]
--Scott David Daniels
[email protected]
--
http://mail.python.org/mailman/listinfo/python-list