Open williamcroberts opened 4 years ago
In it's in the code that returns the substrate is returning an empty string.
def readPemBlocksFromFile(fileObj, *markers):
startMarkers = dict(map(lambda x: (x[1], x[0]),
enumerate(map(lambda y: y[0], markers))))
stopMarkers = dict(map(lambda x: (x[1], x[0]),
enumerate(map(lambda y: y[1], markers))))
idx = -1
substrate = ''
certLines = []
state = stSpam
while True:
certLine = fileObj.readline()
The line:
certLine = fileObj.readline()
never picks up the -----BEGIN CERTIFICATE-----
scissor line because the mode flags on the file are 'rb' and readline() returns binary data. This seems very brittle, we probably want to ensure that the mode flags wouldn't cause these issues. Maybe call encode() or str() on the returned data from read? Not really a python guru, so not sure what the best fix for that would be.
Interesting! Thank you for troubleshooting this issue! Error message is misleading.
I will push a patch and report back.
@etingof the other issue, is when even when we get past this the data returned later on when accessing the ASN1 sub fields of the cert is str, where we would probably want byte array.
I think a better fix would be ensuring that after we decode base64 we ensure that its a bytes and not str.... this py2to3 str/bytes stuff has been fun (not).
I'm seeing an issue in cert decoding on python3 that I am not seeing on python2:
Which I can reproduce with this certificate:
OpenSSL seems to be fine with the cert:
As well as various SSL cert checker websites, like https://www.sslchecker.com/certdecoder
I've tried a few different versions of python3 (3.5.2 and 3.6.8) and can reproduce with both. Ive also tried different versions of pyasn1 and pyasn1_modules with no luck.