oGGy990 / certbot-dns-inwx

INWX DNS authenticator plugin for certbot
Apache License 2.0
105 stars 16 forks source link

High ascii char error #13

Closed YoSiJo closed 5 years ago

YoSiJo commented 5 years ago

I used a password with high ascii chars. Unfortunately I get the following error.

Cleaning up challenges
Encountered exception during recovery: 
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/certbot/auth_handler.py", line 69, in handle_authorizations
    resps = self.auth.perform(achalls)
  File "/usr/lib/python3.7/site-packages/certbot/plugins/dns_common.py", line 58, in perform
    self._perform(domain, validation_domain_name, validation)
  File "/usr/lib/python3.7/site-packages/certbot_dns_inwx/dns_inwx.py", line 95, in _perform
    self._get_inwx_client().add_txt_record(domain, resolved, validation, self.ttl)
  File "/usr/lib/python3.7/site-packages/certbot_dns_inwx/dns_inwx.py", line 109, in _get_inwx_client
    self.credentials.conf('shared_secret'))
  File "/usr/lib/python3.7/site-packages/certbot_dns_inwx/dns_inwx.py", line 124, in __init__
    'pass': password
  File "/usr/lib/python3.7/xmlrpc/client.py", line 1112, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python3.7/site-packages/certbot_dns_inwx/inwx.py", line 52, in __request
    req = urllib.request.Request(self.url, bytearray(requestContent, 'ascii'), headers)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 299-300: ordinal not in range(128)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/certbot/error_handler.py", line 124, in _call_registered
    self.funcs[-1]()
  File "/usr/lib/python3.7/site-packages/certbot/auth_handler.py", line 220, in _cleanup_challenges
    self.auth.cleanup(achalls)
  File "/usr/lib/python3.7/site-packages/certbot/plugins/dns_common.py", line 77, in cleanup
    self._cleanup(domain, validation_domain_name, validation)
  File "/usr/lib/python3.7/site-packages/certbot_dns_inwx/dns_inwx.py", line 99, in _cleanup
    self._get_inwx_client().del_txt_record(domain, resolved, validation)
  File "/usr/lib/python3.7/site-packages/certbot_dns_inwx/dns_inwx.py", line 109, in _get_inwx_client
    self.credentials.conf('shared_secret'))
  File "/usr/lib/python3.7/site-packages/certbot_dns_inwx/dns_inwx.py", line 124, in __init__
    'pass': password
  File "/usr/lib/python3.7/xmlrpc/client.py", line 1112, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python3.7/site-packages/certbot_dns_inwx/inwx.py", line 52, in __request
    req = urllib.request.Request(self.url, bytearray(requestContent, 'ascii'), headers)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 299-300: ordinal not in range(128)
An unexpected error occurred:
UnicodeEncodeError: 'ascii' codec can't encode characters in position 299-300: ordinal not in range(128)
Please see the logfiles in /var/log/letsencrypt for more details.
oGGy990 commented 5 years ago

Hey YoSiJo!

The issue is obviously that the UTF-8 output of requestContent = xmlrpc.client.dumps(tuple_params, methodname) is given to req = urllib.request.Request(self.url, bytearray(requestContent, 'ascii'), headers) with ASCII encoding. This is within the INWX XML-RPC reference implementation (see also here).

I'm willing to fix this on my end, but are you actually using a different codepage or simply a UTF-8 character? This most likely depends on the encoding of your saved configuration file. It needs to be saved in UTF-8 encoding as the XML which is exchanged with INWX uses this encoding - regardless of any fix.

YoSiJo commented 5 years ago

I have now changed my password. This makes it currently charset=us-ascii, but as soon as I enter my old password it automatically changes to charset=utf-8. I can then reproduce the error again. But I really can't say where it's best to fix it. This unfortunately exceeds my Python knowledge a bit. But I'm always for the right, even if longer way to have.

oGGy990 commented 5 years ago

I have just released a new version v2.1.2 which should fix your issue. Please try it and provide some feedback. :-)

YoSiJo commented 5 years ago

I change to my old and a new password and for both of them, it worked.

IMPORTANT NOTES:
 - The dry run was successful.

nice that went fast.

oGGy990 commented 5 years ago

Glad I could help you :-)

Considering this as solved then!