[issue37079] PEM cadata causes ssl.SSLError: nested asn1 error

2019-05-28 Thread Jizhou Yang


Jizhou Yang  added the comment:

Thanks a lot for the quick answer! Verified that the proposed solution works 
with PEM certificates in both Python 2 and 3.

--
stage:  -> resolved
status: pending -> closed

___
Python tracker 
<https://bugs.python.org/issue37079>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37079] PEM cadata causes ssl.SSLError: nested asn1 error

2019-05-28 Thread Jizhou Yang


New submission from Jizhou Yang :

Loading cadata in PEM format results in a nested asn1 error. Workaround is to 
convert cadata to unicode.

Minimum code for reproducing the issue:
>>>import ssl
>>> with open('ca.crt') as f:
... ca_crt = f.read()
...
>>> c = ssl.create_default_context()
>>> c.load_verify_locations(cadata=ca_crt)
Traceback (most recent call last):
  File "", line 1, in 
ssl.SSLError: nested asn1 error (_ssl.c:2902)

With workaround to make it work:
>>>import ssl
>>> with open('ca.crt') as f:
... ca_crt = f.read()
...
>>> c = ssl.create_default_context()
>>> c.load_verify_locations(cadata=unicode(ca_crt))

The issue is annoying as the documentation explicitly states cadata to be 
"either an ASCII string of one or more PEM-encoded certificates...". 
Furthermore the unicode function is not present in Python 3.x, making the 
workaround version-dependent.

--
title: PEM cadata causes ssl.SSLError: nested ans1 error -> PEM cadata causes 
ssl.SSLError: nested asn1 error
Added file: https://bugs.python.org/file48373/ca.crt

___
Python tracker 
<https://bugs.python.org/issue37079>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37079] PEM cadata causes ssl.SSLError: nested ans1 error

2019-05-28 Thread Jizhou Yang


Change by Jizhou Yang :


--
assignee: christian.heimes
components: SSL
nosy: Jizhou Yang, christian.heimes
priority: normal
severity: normal
status: open
title: PEM cadata causes ssl.SSLError: nested ans1 error
type: crash
versions: Python 2.7

___
Python tracker 
<https://bugs.python.org/issue37079>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com