polhenarejos / acme_email

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

IMAP error blocks certificate issuance #25

Closed augjoh closed 3 years ago

augjoh commented 3 years ago

When requesting a certificate with cli.py, an IMAP exception blocks certificate issuance:

$ 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
/builds/platynum/certification-authority/flows/acme_email/cli.py:47: DeprecationWarning: IConfig attribute in certbot.interfaces module is deprecated and will be removed soon.
  zope.component.provideUtility(config, interfaces.IConfig)
Saving debug log to /builds/platynum/certification-authority/flows/acme_email/logs/letsencrypt.log
/builds/platynum/certification-authority/flows/acme_email/cli.py:185: DeprecationWarning: IReporter attribute in certbot.interfaces module is deprecated and will be removed soon.
  zope.component.provideUtility(report, interfaces.IReporter)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
You are requesting a S/MIME certificate to CASTLE ACME server. Remember to add
the root certificate into your trust store for proper operation.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Account registered.
Requesting a certificate for address@mail

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
A challenge request for S/MIME certificate has been sent. In few minutes, ACME
server will send a challenge e-mail to requested recipient address@mail. You do
not need to take ANY action, as it will be replied automatically.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
16 Nov 21:13:42 - [info] [function:Send E-Mail] to: "address@mail", msg-id: <f43881fd-3497-e6be-abfb-738f059df136@mail>
--- 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 248, in <module>
    main(args)
  File "/builds/platynum/certification-authority/flows/acme_email/cli.py", line 191, in main
    request_cert(args, config)
  File "/builds/platynum/certification-authority/flows/acme_email/cli.py", line 110, 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 1353, 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 300, 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 439, 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 70, in handle_authorizations
    resps = self.auth.perform(achalls)
  File "/builds/platynum/certification-authority/flows/acme_email/certbot_castle/plugins/imap.py", line 85, in perform
    return [self._perform_emailreply00(achall) for achall in achalls]
  File "/builds/platynum/certification-authority/flows/acme_email/certbot_castle/plugins/imap.py", line 85, in <listcomp>
    return [self._perform_emailreply00(achall) for achall in achalls]
  File "/builds/platynum/certification-authority/flows/acme_email/certbot_castle/plugins/imap.py", line 98, in _perform_emailreply00
    respo = self.imap.fetch(uid, ['RFC822'])
  File "/usr/lib/python3.9/site-packages/imapclient/imapclient.py", line 1367, in fetch
    typ, data = self._imap._command_complete("FETCH", tag)
  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 v2.0.0-alpha-2 ready'"
Arguments: (1637097221.3968813,)
--- 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 248, in <module>
    main(args)
  File "/builds/platynum/certification-authority/flows/acme_email/cli.py", line 191, in main
    request_cert(args, config)
  File "/builds/platynum/certification-authority/flows/acme_email/cli.py", line 110, 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 1353, 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 300, 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 439, 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 70, in handle_authorizations
    resps = self.auth.perform(achalls)
  File "/builds/platynum/certification-authority/flows/acme_email/certbot_castle/plugins/imap.py", line 85, in perform
    return [self._perform_emailreply00(achall) for achall in achalls]
  File "/builds/platynum/certification-authority/flows/acme_email/certbot_castle/plugins/imap.py", line 85, in <listcomp>
    return [self._perform_emailreply00(achall) for achall in achalls]
  File "/builds/platynum/certification-authority/flows/acme_email/certbot_castle/plugins/imap.py", line 98, in _perform_emailreply00
    respo = self.imap.fetch(uid, ['RFC822'])
  File "/usr/lib/python3.9/site-packages/imapclient/imapclient.py", line 1367, in fetch
    typ, data = self._imap._command_complete("FETCH", tag)
  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'CDEJ0 CAPABILITY'"
Arguments: (1637097221.3969378,)
--- 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 248, in <module>
    main(args)
  File "/builds/platynum/certification-authority/flows/acme_email/cli.py", line 191, in main
    request_cert(args, config)
  File "/builds/platynum/certification-authority/flows/acme_email/cli.py", line 110, 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 1353, 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 300, 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 439, 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 70, in handle_authorizations
    resps = self.auth.perform(achalls)
  File "/builds/platynum/certification-authority/flows/acme_email/certbot_castle/plugins/imap.py", line 85, in perform
    return [self._perform_emailreply00(achall) for achall in achalls]
  File "/builds/platynum/certification-authority/flows/acme_email/certbot_castle/plugins/imap.py", line 85, in <listcomp>
    return [self._perform_emailreply00(achall) for achall in achalls]
  File "/builds/platynum/certification-authority/flows/acme_email/certbot_castle/plugins/imap.py", line 98, in _perform_emailreply00
    respo = self.imap.fetch(uid, ['RFC822'])
  File "/usr/lib/python3.9/site-packages/imapclient/imapclient.py", line 1367, in fetch
    typ, data = self._imap._command_complete("FETCH", tag)
  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: (1637097221.3994844,)
--- 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 248, in <module>
    main(args)
  File "/builds/platynum/certification-authority/flows/acme_email/cli.py", line 191, in main
    request_cert(args, config)
  File "/builds/platynum/certification-authority/flows/acme_email/cli.py", line 110, 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 1353, 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 300, 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 439, 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 70, in handle_authorizations
    resps = self.auth.perform(achalls)
  File "/builds/platynum/certification-authority/flows/acme_email/certbot_castle/plugins/imap.py", line 85, in perform
    return [self._perform_emailreply00(achall) for achall in achalls]
  File "/builds/platynum/certification-authority/flows/acme_email/certbot_castle/plugins/imap.py", line 85, in <listcomp>
    return [self._perform_emailreply00(achall) for achall in achalls]
  File "/builds/platynum/certification-authority/flows/acme_email/certbot_castle/plugins/imap.py", line 98, in _perform_emailreply00
    respo = self.imap.fetch(uid, ['RFC822'])
  File "/usr/lib/python3.9/site-packages/imapclient/imapclient.py", line 1367, in fetch
    typ, data = self._imap._command_complete("FETCH", tag)
  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'CDEJ0 OK CAPABILITY completed.'"
Arguments: (1637097221.3996263,)
An unexpected error occurred:
imaplib.IMAP4.abort: command: FETCH => socket error: EOF
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /builds/platynum/certification-authority/flows/acme_email/logs/letsencrypt.log or re-run Certbot with -v for more details.
polhenarejos commented 3 years ago

Which commit? Still Greenmail?

polhenarejos commented 3 years ago

All these errors are related with idle mode. I added a deeper control of the idle state. I hope it'll fix all related issues.