polhenarejos / acme_email

ACME Email Client for EmailReply-00 Challenge
https://acme.castle.cloud
GNU General Public License v3.0
46 stars 7 forks source link

Error message during successful certification request #8

Closed augjoh closed 2 years ago

augjoh commented 3 years ago

The following error is shown during a certification request.

$ python3 cli.py cert --passphrase passphrase --config-dir . --work-dir . --logs-dir ./logs -e address@mail --contact contact@${HOSTNAME} --imap --host mail --port 3143 --agree-tos --login address@mail --password address@mail --host mail --smtp-port 3025 --smtp-host mail --non-interactive
[...]
--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.9/imaplib.py", line 1173, in _get_tagged_response
    self._get_response()
  File "/usr/lib/python3.9/imaplib.py", line 1075, in _get_response
    resp = self._get_line()
  File "/usr/lib/python3.9/imaplib.py", line 1185, in _get_line
    raise self.abort('socket error: EOF')
imaplib.IMAP4.abort: socket error: EOF

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/logging/handlers.py", line 73, in emit
    if self.shouldRollover(record):
  File "/usr/lib/python3.9/logging/handlers.py", line 191, in shouldRollover
    msg = "%s\n" % self.format(record)
  File "/usr/lib/python3.9/logging/__init__.py", line 927, in format
    return fmt.format(record)
  File "/usr/lib/python3.9/logging/__init__.py", line 663, in format
    record.message = record.getMessage()
  File "/usr/lib/python3.9/logging/__init__.py", line 367, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "/builds/platynum/certification-authority/flows/acme_email/cli.py", line 166, in <module>
    main(args)
  File "/builds/platynum/certification-authority/flows/acme_email/cli.py", line 119, in main
    request_cert(args, config)
  File "/builds/platynum/certification-authority/flows/acme_email/cli.py", line 91, in request_cert
    cert_path, chain_path, fullchain_path = certbot_main._csr_get_and_save_cert(config, le_client)
  File "/usr/lib/python3.9/site-packages/certbot/_internal/main.py", line 1345, in _csr_get_and_save_cert
    cert, chain = le_client.obtain_certificate_from_csr(csr)
  File "/usr/lib/python3.9/site-packages/certbot/_internal/client.py", line 297, in obtain_certificate_from_csr
    orderr = self._get_order_and_authorizations(csr.data, best_effort=False)
  File "/usr/lib/python3.9/site-packages/certbot/_internal/client.py", line 436, in _get_order_and_authorizations
    authzr = self.auth_handler.handle_authorizations(orderr, self.config, best_effort)
  File "/usr/lib/python3.9/site-packages/certbot/_internal/auth_handler.py", line 98, in handle_authorizations
    return authzrs_validated
  File "/usr/lib/python3.9/site-packages/certbot/_internal/error_handler.py", line 106, in __exit__
    self._call_registered()
  File "/usr/lib/python3.9/site-packages/certbot/_internal/error_handler.py", line 124, in _call_registered
    self.funcs[-1]()
  File "/usr/lib/python3.9/site-packages/certbot/_internal/auth_handler.py", line 241, in _cleanup_challenges
    self.auth.cleanup(achalls)
  File "/builds/platynum/certification-authority/flows/acme_email/certbot_castle/plugins/imap.py", line 188, in cleanup
    self.imap.logout()
  File "/usr/lib/python3.9/site-packages/imapclient/imapclient.py", line 496, in logout
    typ, data = self._imap.logout()
  File "/usr/lib/python3.9/imaplib.py", line 642, in logout
    typ, dat = self._simple_command('LOGOUT')
  File "/usr/lib/python3.9/imaplib.py", line 1230, in _simple_command
    return self._command_complete(name, self._command(name, *args))
  File "/usr/lib/python3.9/imaplib.py", line 1047, in _command_complete
    typ, data = self._get_tagged_response(tag, expect_bye=logout)
  File "/usr/lib/python3.9/imaplib.py", line 1177, in _get_tagged_response
    self.print_log()
  File "/usr/lib/python3.9/imaplib.py", line 1274, in print_log
    self._mesg(*self._cmd_log[i])
Message: "< b'* OK IMAP4rev1 Server GreenMail v1.6.5 ready'"
Arguments: (1630233059.1909673,)
--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.9/imaplib.py", line 1173, in _get_tagged_response
    self._get_response()
  File "/usr/lib/python3.9/imaplib.py", line 1075, in _get_response
    resp = self._get_line()
  File "/usr/lib/python3.9/imaplib.py", line 1185, in _get_line
    raise self.abort('socket error: EOF')
imaplib.IMAP4.abort: socket error: EOF

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/logging/handlers.py", line 73, in emit
    if self.shouldRollover(record):
  File "/usr/lib/python3.9/logging/handlers.py", line 191, in shouldRollover
    msg = "%s\n" % self.format(record)
  File "/usr/lib/python3.9/logging/__init__.py", line 927, in format
    return fmt.format(record)
  File "/usr/lib/python3.9/logging/__init__.py", line 663, in format
    record.message = record.getMessage()
  File "/usr/lib/python3.9/logging/__init__.py", line 367, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "/builds/platynum/certification-authority/flows/acme_email/cli.py", line 166, in <module>
    main(args)
  File "/builds/platynum/certification-authority/flows/acme_email/cli.py", line 119, in main
    request_cert(args, config)
  File "/builds/platynum/certification-authority/flows/acme_email/cli.py", line 91, in request_cert
    cert_path, chain_path, fullchain_path = certbot_main._csr_get_and_save_cert(config, le_client)
  File "/usr/lib/python3.9/site-packages/certbot/_internal/main.py", line 1345, in _csr_get_and_save_cert
    cert, chain = le_client.obtain_certificate_from_csr(csr)
  File "/usr/lib/python3.9/site-packages/certbot/_internal/client.py", line 297, in obtain_certificate_from_csr
    orderr = self._get_order_and_authorizations(csr.data, best_effort=False)
  File "/usr/lib/python3.9/site-packages/certbot/_internal/client.py", line 436, in _get_order_and_authorizations
    authzr = self.auth_handler.handle_authorizations(orderr, self.config, best_effort)
  File "/usr/lib/python3.9/site-packages/certbot/_internal/auth_handler.py", line 98, in handle_authorizations
    return authzrs_validated
  File "/usr/lib/python3.9/site-packages/certbot/_internal/error_handler.py", line 106, in __exit__
    self._call_registered()
  File "/usr/lib/python3.9/site-packages/certbot/_internal/error_handler.py", line 124, in _call_registered
    self.funcs[-1]()
  File "/usr/lib/python3.9/site-packages/certbot/_internal/auth_handler.py", line 241, in _cleanup_challenges
    self.auth.cleanup(achalls)
  File "/builds/platynum/certification-authority/flows/acme_email/certbot_castle/plugins/imap.py", line 188, in cleanup
    self.imap.logout()
  File "/usr/lib/python3.9/site-packages/imapclient/imapclient.py", line 496, in logout
    typ, data = self._imap.logout()
  File "/usr/lib/python3.9/imaplib.py", line 642, in logout
    typ, dat = self._simple_command('LOGOUT')
  File "/usr/lib/python3.9/imaplib.py", line 1230, in _simple_command
    return self._command_complete(name, self._command(name, *args))
  File "/usr/lib/python3.9/imaplib.py", line 1047, in _command_complete
    typ, data = self._get_tagged_response(tag, expect_bye=logout)
  File "/usr/lib/python3.9/imaplib.py", line 1177, in _get_tagged_response
    self.print_log()
  File "/usr/lib/python3.9/imaplib.py", line 1274, in print_log
    self._mesg(*self._cmd_log[i])
Message: "> b'HFBC0 CAPABILITY'"
Arguments: (1630233059.191008,)
--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.9/imaplib.py", line 1173, in _get_tagged_response
    self._get_response()
  File "/usr/lib/python3.9/imaplib.py", line 1075, in _get_response
    resp = self._get_line()
  File "/usr/lib/python3.9/imaplib.py", line 1185, in _get_line
    raise self.abort('socket error: EOF')
imaplib.IMAP4.abort: socket error: EOF

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/logging/handlers.py", line 73, in emit
    if self.shouldRollover(record):
  File "/usr/lib/python3.9/logging/handlers.py", line 191, in shouldRollover
    msg = "%s\n" % self.format(record)
  File "/usr/lib/python3.9/logging/__init__.py", line 927, in format
    return fmt.format(record)
  File "/usr/lib/python3.9/logging/__init__.py", line 663, in format
    record.message = record.getMessage()
  File "/usr/lib/python3.9/logging/__init__.py", line 367, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "/builds/platynum/certification-authority/flows/acme_email/cli.py", line 166, in <module>
    main(args)
  File "/builds/platynum/certification-authority/flows/acme_email/cli.py", line 119, in main
    request_cert(args, config)
  File "/builds/platynum/certification-authority/flows/acme_email/cli.py", line 91, in request_cert
    cert_path, chain_path, fullchain_path = certbot_main._csr_get_and_save_cert(config, le_client)
  File "/usr/lib/python3.9/site-packages/certbot/_internal/main.py", line 1345, in _csr_get_and_save_cert
    cert, chain = le_client.obtain_certificate_from_csr(csr)
  File "/usr/lib/python3.9/site-packages/certbot/_internal/client.py", line 297, in obtain_certificate_from_csr
    orderr = self._get_order_and_authorizations(csr.data, best_effort=False)
  File "/usr/lib/python3.9/site-packages/certbot/_internal/client.py", line 436, in _get_order_and_authorizations
    authzr = self.auth_handler.handle_authorizations(orderr, self.config, best_effort)
  File "/usr/lib/python3.9/site-packages/certbot/_internal/auth_handler.py", line 98, in handle_authorizations
    return authzrs_validated
  File "/usr/lib/python3.9/site-packages/certbot/_internal/error_handler.py", line 106, in __exit__
    self._call_registered()
  File "/usr/lib/python3.9/site-packages/certbot/_internal/error_handler.py", line 124, in _call_registered
    self.funcs[-1]()
  File "/usr/lib/python3.9/site-packages/certbot/_internal/auth_handler.py", line 241, in _cleanup_challenges
    self.auth.cleanup(achalls)
  File "/builds/platynum/certification-authority/flows/acme_email/certbot_castle/plugins/imap.py", line 188, in cleanup
    self.imap.logout()
  File "/usr/lib/python3.9/site-packages/imapclient/imapclient.py", line 496, in logout
    typ, data = self._imap.logout()
  File "/usr/lib/python3.9/imaplib.py", line 642, in logout
    typ, dat = self._simple_command('LOGOUT')
  File "/usr/lib/python3.9/imaplib.py", line 1230, in _simple_command
    return self._command_complete(name, self._command(name, *args))
  File "/usr/lib/python3.9/imaplib.py", line 1047, in _command_complete
    typ, data = self._get_tagged_response(tag, expect_bye=logout)
  File "/usr/lib/python3.9/imaplib.py", line 1177, in _get_tagged_response
    self.print_log()
  File "/usr/lib/python3.9/imaplib.py", line 1274, in print_log
    self._mesg(*self._cmd_log[i])
Message: "< b'* CAPABILITY IMAP4rev1 LITERAL+ SORT UIDPLUS IDLE QUOTA'"
Arguments: (1630233059.1912873,)
--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.9/imaplib.py", line 1173, in _get_tagged_response
    self._get_response()
  File "/usr/lib/python3.9/imaplib.py", line 1075, in _get_response
    resp = self._get_line()
  File "/usr/lib/python3.9/imaplib.py", line 1185, in _get_line
    raise self.abort('socket error: EOF')
imaplib.IMAP4.abort: socket error: EOF

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/logging/handlers.py", line 73, in emit
    if self.shouldRollover(record):
  File "/usr/lib/python3.9/logging/handlers.py", line 191, in shouldRollover
    msg = "%s\n" % self.format(record)
  File "/usr/lib/python3.9/logging/__init__.py", line 927, in format
    return fmt.format(record)
  File "/usr/lib/python3.9/logging/__init__.py", line 663, in format
    record.message = record.getMessage()
  File "/usr/lib/python3.9/logging/__init__.py", line 367, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "/builds/platynum/certification-authority/flows/acme_email/cli.py", line 166, in <module>
    main(args)
  File "/builds/platynum/certification-authority/flows/acme_email/cli.py", line 119, in main
    request_cert(args, config)
  File "/builds/platynum/certification-authority/flows/acme_email/cli.py", line 91, in request_cert
    cert_path, chain_path, fullchain_path = certbot_main._csr_get_and_save_cert(config, le_client)
  File "/usr/lib/python3.9/site-packages/certbot/_internal/main.py", line 1345, in _csr_get_and_save_cert
    cert, chain = le_client.obtain_certificate_from_csr(csr)
  File "/usr/lib/python3.9/site-packages/certbot/_internal/client.py", line 297, in obtain_certificate_from_csr
    orderr = self._get_order_and_authorizations(csr.data, best_effort=False)
  File "/usr/lib/python3.9/site-packages/certbot/_internal/client.py", line 436, in _get_order_and_authorizations
    authzr = self.auth_handler.handle_authorizations(orderr, self.config, best_effort)
  File "/usr/lib/python3.9/site-packages/certbot/_internal/auth_handler.py", line 98, in handle_authorizations
    return authzrs_validated
  File "/usr/lib/python3.9/site-packages/certbot/_internal/error_handler.py", line 106, in __exit__
    self._call_registered()
  File "/usr/lib/python3.9/site-packages/certbot/_internal/error_handler.py", line 124, in _call_registered
    self.funcs[-1]()
  File "/usr/lib/python3.9/site-packages/certbot/_internal/auth_handler.py", line 241, in _cleanup_challenges
    self.auth.cleanup(achalls)
  File "/builds/platynum/certification-authority/flows/acme_email/certbot_castle/plugins/imap.py", line 188, in cleanup
    self.imap.logout()
  File "/usr/lib/python3.9/site-packages/imapclient/imapclient.py", line 496, in logout
    typ, data = self._imap.logout()
  File "/usr/lib/python3.9/imaplib.py", line 642, in logout
    typ, dat = self._simple_command('LOGOUT')
  File "/usr/lib/python3.9/imaplib.py", line 1230, in _simple_command
    return self._command_complete(name, self._command(name, *args))
  File "/usr/lib/python3.9/imaplib.py", line 1047, in _command_complete
    typ, data = self._get_tagged_response(tag, expect_bye=logout)
  File "/usr/lib/python3.9/imaplib.py", line 1177, in _get_tagged_response
    self.print_log()
  File "/usr/lib/python3.9/imaplib.py", line 1274, in print_log
    self._mesg(*self._cmd_log[i])
Message: "< b'HFBC0 OK CAPABILITY completed.'"
Arguments: (1630233059.1913066,)
Encountered exception during recovery: imaplib.IMAP4.abort: command: LOGOUT => socket error: EOF
polhenarejos commented 3 years ago

I cannot reproduce it. It seems an IMAP issue, which closes the connection abnormally on logout. Despite of this, please give a try to daf613b as it should pass this exception.

augjoh commented 3 years ago

I've updated the test to the version you've created (https://gitlab.com/platynum/certification-authority/flows/-/jobs/1555405523). The error still remains, perhaps this error should be fixed in the used IMAP library?

polhenarejos commented 3 years ago

IMAP library is in the Python's core and I bet it shouldn't be the problem. Which Python version do you use? May I could have an IMAP/SMTP account with your provider to test it directly?

augjoh commented 3 years ago

I've extracted the versions used from the link above:

IMAP/SMTP accounts can be created dynamically with it.

polhenarejos commented 2 years ago

Do you use Outlook? I added a third plugin to automate the process without setting up IMAP/SMTP servers.

augjoh commented 2 years ago

No, I have no outlook available. I'm using the software versions mentioned above.

polhenarejos commented 2 years ago

I'll give a try to GreenMail 1.6.5 to reproduce the error. May you share the config are you using?

polhenarejos commented 2 years ago

Finally I managed to reproduce the error. It is related with idle_done in case the challenge fails.