Closed hakong closed 3 years ago
Different than the other issue you mentioned, but for a similar reason.
For Python 2.7.5 return 'DNS:{0}'.format(name.value)
should be return u'DNS:{0}'.format(name.value)
to handle Unicode correctly.
I think @felixfontein is the better person to provide a solution however.
Yes, adding the u
prefix should do the trick. Testing this is somewhat tricky, since it only works with cryptography < 2.1 - newer versions don't automatically encode/decode IDNs. I've created a PR (#313), let's see what CI says.
Is there a workaround I can use while waiting for the fix to be released?
What you could do is:
Ok, thank you for that. The platform is pretty tied down in regards to using newer versions of python packages (Red Hat Satellite 6.9 on Red Hat Enterprise Linux 7.9). I will create a case with Red Hat and see what they say, but based on my experience that's going to take months to solve, if at all.
For the time being as a workaround I've just dumped the new revision in place. This seems to work.
wget https://raw.githubusercontent.com/ansible-collections/community.crypto/eb8dabce84302621351b409e7e52594e03937a17/plugins/module_utils/crypto/cryptography_support.py -O /usr/share/foreman-proxy/.ansible/collections/ansible_collections/community/crypto/plugins/module_utils/crypto/cryptography_support.py
community.crypto 1.9.6 is now out with a fix for this.
SUMMARY
Using x509_certificate_info on certificates with unicode SANs fails.
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe6'
Could this be a similar issue to https://github.com/ansible-collections/community.crypto/issues/270?
ISSUE TYPE
COMPONENT NAME
x509_certificate_info
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
STEPS TO REPRODUCE
I created a certificate with acme.sh that contained an encoded Internationalized domain name (IDNA encoding). Tried to read it with _openssl_certificateinfo but that failed, so I installed the latest collection and tried with
community.crypto.x509_certificate_info
but that fails too.The task I first used:
The error that resulted:
After that I did
ansible-galaxy collection install community.crypto
and changed the task:The error that resulted:
EXPECTED RESULTS
Expected it to parse successfully.
ACTUAL RESULTS
Give a unicode error:
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe6'