[issue31659] ssl module should not use textwrap for wrapping PEM format.
INADA Naoki
report at bugs.python.org
Sun Oct 1 20:47:35 EDT 2017
New submission from INADA Naoki <songofacandy at gmail.com>:
Current DER_cert_to_PEM_cert() uses textwrap like this:
def DER_cert_to_PEM_cert(der_cert_bytes):
"""Takes a certificate in binary DER format and returns the
PEM version of it as a string."""
f = str(base64.standard_b64encode(der_cert_bytes), 'ASCII', 'strict')
return (PEM_HEADER + '\n' +
textwrap.fill(f, 64) + '\n' +
PEM_FOOTER + '\n')
But textwrap is designed to break lines at word boundary.
So textwrap.fill for base64 text may be slow.
And `import textwrap` is little slow too.
We can use simple slicing instead of textwrap.
----------
messages: 303505
nosy: inada.naoki
priority: normal
severity: normal
status: open
title: ssl module should not use textwrap for wrapping PEM format.
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31659>
_______________________________________
More information about the Python-bugs-list
mailing list