Index: Lib/ssl.py =================================================================== --- Lib/ssl.py (revision 79453) +++ Lib/ssl.py (working copy) @@ -359,7 +359,7 @@ # 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' + Index: Lib/test/test_ssl.py =================================================================== --- Lib/test/test_ssl.py (revision 79453) +++ Lib/test/test_ssl.py (working copy) @@ -110,6 +110,12 @@ if (d1 != d2): raise test_support.TestFailed("PEM-to-DER or DER-to-PEM translation failed") + if not p2.startswith(ssl.PEM_HEADER + '\n'): + raise test_support.TestFailed("DER-to-PEM didn't include correct header") + + if not p2.endswith('\n' + ssl.PEM_FOOTER + '\n'): + raise test_support.TestFailed("DER-to-PEM didn't include correct footer" + p2) + class NetworkedTests(unittest.TestCase): def testConnect(self):