Commit 4c7bcf11 authored by Antoine Pitrou's avatar Antoine Pitrou

Issue #8086: In :func:`ssl.DER_cert_to_PEM_cert()`, fix missing newline

before the certificate footer.  Patch by Kyle VanderBeek.
parent 97514720
......@@ -365,7 +365,7 @@ def DER_cert_to_PEM_cert(der_cert_bytes):
# preferred because older API gets line-length wrong
f = base64.standard_b64encode(der_cert_bytes)
return (PEM_HEADER + '\n' +
textwrap.fill(f, 64) +
textwrap.fill(f, 64) + '\n' +
PEM_FOOTER + '\n')
else:
return (PEM_HEADER + '\n' +
......
......@@ -113,6 +113,10 @@ class BasicTests(unittest.TestCase):
p2 = ssl.DER_cert_to_PEM_cert(d1)
d2 = ssl.PEM_cert_to_DER_cert(p2)
self.assertEqual(d1, d2)
if not p2.startswith(ssl.PEM_HEADER + '\n'):
self.fail("DER-to-PEM didn't include correct header:\n%r\n" % p2)
if not p2.endswith('\n' + ssl.PEM_FOOTER + '\n'):
self.fail("DER-to-PEM didn't include correct footer:\n%r\n" % p2)
def test_openssl_version(self):
n = ssl.OPENSSL_VERSION_NUMBER
......
......@@ -780,6 +780,7 @@ Michael Urman
Hector Urtubia
Andi Vajda
Case Van Horsen
Kyle VanderBeek
Atul Varma
Dmitry Vasiliev
Alexandre Vassalotti
......
......@@ -27,6 +27,9 @@ Core and Builtins
Library
-------
- Issue #8086: In :func:`ssl.DER_cert_to_PEM_cert()`, fix missing newline
before the certificate footer. Patch by Kyle VanderBeek.
- Issue #8546: Reject None given as the buffering argument to _pyio.open.
- Issue #8549: Fix compiling the _ssl extension under AIX. Patch by
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment