Getting Cyrus CalDAV to work with Evolution

Bugs in the Spec are the most expensive

When upgrading to Debian Jessie I discovered that our Cyrus mailer now supports CalDAV. This was easily installed. The cyrus server did have a self signed certificate anyway, so all there was to do was to apt-get install cyrus-caldav and to uncomment the https line in cyrus.conf. Since I use basic authentication http is not an option.

Configuring Evolution

Configuring Evolution was not as easy as claimed in the otherwise highly useful documentation. Calendar auto detection requires more than just the server name. This is what works:




Ouch

After finding this Evolution could read the calendar, but complained about it being read only when trying to add an appointment. It seems that Evolution considers a the calendar read only if it does not announce PUT. The hard question is, if that is correct. Unfortunately RFC 2518 is missing a section “OPTIONS for collections”. I could not find any specification that says, wether announcing PUT for a collection as Evolution expects it is correct.

Apaches mod_dav at least does not announce PUT for collections.

if (!resource->collection)
    apr_table_addn(methods, "PUT", ""); 

Apache to the rescue

Apache actually has what it takes to work around this. So I am now running cyrus http on localhost

# Only localhost is allowed unencrypted
http            cmd="httpd -U 30" listen="localhost:8008" prefork=0 maxchild=100

and proxying it through an Apache virtual host

Listen 8443

<VirtualHost *:8443>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/html
    ServerName   mail.heute-morgen.de

    ProxyPreserveHost On
    ProxyPass "/" "http://localhost:8008/"
    ProxyPassReverse "/" "http://localhost:8008/"

    # This avoids 408 + 502 errors.
    # Seems that cyrus HTTP 1.0 is not net 100% correct
    SetEnv force-proxy-request-1.0 1
    SetEnv proxy-nokeepalive 1

    BrowserMatch    Evolution                       fake-write-coll
    SetEnvIfNoCase  Request_Method "^OPTIONS$"      is-options
    SetEnvIf        is-options "^$"                 !fake-write-coll
    <Location /dav/calendars/user/*/Default/>
        Header append Allow "PUT, DELETE" env=fake-write-coll
    </Location>
    <Location /dav/addressbooks/user/*/Default/>
        Header append Allow "PUT, DELETE" env=fake-write-coll
    </Location>

    ErrorLog ${APACHE_LOG_DIR}/mail.heute-morgen.de-error.log
    CustomLog ${APACHE_LOG_DIR}/mail.heute-morgen.de-access.log mh

    #   SSL Engine Switch:
    #   Enable/Disable SSL for this virtual host.
    SSLEngine on

    #   SSLCertificateFile directive is needed.
    SSLCertificateFile      /etc/ssl/certs/cyrus.pem
    SSLCertificateKeyFile   /etc/ssl/private/cyrus.key

</VirtualHost>

to add PUT and DELETE for the calendar collections. Note that this workaround lets Evolution display all calendars as writable, no matter what their actual status is.