diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-04-27 22:03:37 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-04-27 22:03:37 (GMT) |
commit | 4c7bcf119431c1752b2f0c41e347b6cd18907fc3 (patch) | |
tree | 09956ebcfa3bbdb28a479905d4a2411ff8ee13ba /Lib | |
parent | 9751472001bbe25095ac6635353606c2fe443d1f (diff) | |
download | cpython-4c7bcf119431c1752b2f0c41e347b6cd18907fc3.zip cpython-4c7bcf119431c1752b2f0c41e347b6cd18907fc3.tar.gz cpython-4c7bcf119431c1752b2f0c41e347b6cd18907fc3.tar.bz2 |
Issue #8086: In :func:`ssl.DER_cert_to_PEM_cert()`, fix missing newline
before the certificate footer. Patch by Kyle VanderBeek.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/ssl.py | 2 | ||||
-rw-r--r-- | Lib/test/test_ssl.py | 4 |
2 files changed, 5 insertions, 1 deletions
@@ -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' + diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index 7c32c1b..feb6f50 100644 --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -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 |