[systemd-devel] SSL handshake error from offlineimap when using systemd to initialize

Yubin Ruan ablacktshirt at gmail.com
Sun Jan 21 11:12:14 UTC 2018


Hi,

I use offlineimap to synchronize my emails. I want it to do a synchronization
at system startup so recently I add a systemd service for it. However I always
get error like this:

   EOF occurred in violation of protocol (_ssl.c:590)
  *** Finished account 'BLACK' in 0:00
 ERROR: Exceptions occurred during the run!
 ERROR: While attempting to sync account 'BLACK'
   EOF occurred in violation of protocol (_ssl.c:590)
 Traceback:
   File "/usr/share/offlineimap/offlineimap/accounts.py", line 263, in syncrunner
     self.__sync()
   File "/usr/share/offlineimap/offlineimap/accounts.py", line 326, in __sync
     remoterepos.getfolders()
   File "/usr/share/offlineimap/offlineimap/repository/IMAP.py", line 384, in getfolders
     imapobj = self.imapserver.acquireconnection()
   File "/usr/share/offlineimap/offlineimap/imapserver.py", line 483, in acquireconnection
     tls_level=self.tlslevel,
   File "/usr/share/offlineimap/offlineimap/imaplibutil.py", line 186, in __init__
     super(WrappedIMAP4_SSL, self).__init__(*args, **kwargs)
   File "/usr/lib/python2.7/dist-packages/imaplib2.py", line 2138, in __init__
     IMAP4.__init__(self, host, port, debug, debug_file, identifier, timeout, debug_buf_lvl)
   File "/usr/lib/python2.7/dist-packages/imaplib2.py", line 357, in __init__
     self.open(host, port)
   File "/usr/share/offlineimap/offlineimap/imaplibutil.py", line 194, in open
     super(WrappedIMAP4_SSL, self).open(host, port)
   File "/usr/lib/python2.7/dist-packages/imaplib2.py", line 2151, in open
     self.ssl_wrap_socket()
   File "/usr/lib/python2.7/dist-packages/imaplib2.py", line 522, in ssl_wrap_socket
     self.sock = ssl.wrap_socket(self.sock, self.keyfile, self.certfile, ca_certs=self.ca_certs, cert_reqs=cert_reqs, ssl_version=ssl_version)
   File "/usr/lib/python2.7/ssl.py", line 933, in wrap_socket
     ciphers=ciphers)
   File "/usr/lib/python2.7/ssl.py", line 601, in __init__
     self.do_handshake()
   File "/usr/lib/python2.7/ssl.py", line 830, in do_handshake
     self._sslobj.do_handshake()

Currently I don't know what the problem is, but:

    1. usually (after system startup) the same service is invoked by a timer
    and it works well so there is no problem with the script.

    2. I believe the network is reachable, because the system will
    auto-connect WIFI after system startup. Maybe the initialization order is
    not configured properly? If so please see my mail service file below.

I heard that to perform a SSL handshake the system have to contain some
randomness (such that some random keys can be generated), so maybe a SSL
handshake at system startup is deemed to fail?

FYI, this is my systemd mail service file:

# ~/.config/systemd/user/mail.service
# this file is enabled with "systemctl --user enable mail.service
[Unit]
Description=Sync mail
After=network.target

[Service]
Type=oneshot
ExecStart=/path/to/the/script/mmail
TimeoutStartSec=1min30s

[Install]
WantedBy=default.target

--
Yubin


More information about the systemd-devel mailing list