## June 14, 2008

### CalDAV

Like most people, I want to be able to access my data from multiple locations, and to be able to share it, securely, with others. Hence my interest in using WebDAV fileshares, in wiki’s for note-taking and collaboration.

When Apple introduced iCal, in Tiger, I was initially quite excited by the ability to publish calendars to a WebDAV server. The calendars on my home computer were accessible from the offices, and vice versa. My wife could “subscribe” to my calendar, and I to hers. Unfortunately the publish/subscribe model isn’t as great in practice as it sounded in theory.

What happens when I find out that the meeting I entered into my office calendar has been cancelled? If I’m at home, I can read my office calendar, but I can’t write to it. Much better than Publish/Subscribe would be calendars that are readable and writeable from anywhere. So I was pretty interested that iCal, in Leopard, supports CalDAV.

I finally got around to setting up a CalDAV Server. I decided to go with Apple’s Calendar Server. Perhaps there’s another choice that would have been better, but — at least initially — things seemed to go very smoothly.

Check out the Python source via SVN. Type

./run -s

The next task was to configure a Directory Service. The are four choices listed in the documentation: XMLDirectoryService, OpenDirectoryService, BasicDirectoryService and DigestDirectoryService.

XMLDirectoryService
This is the “default” configuration in the Darwin Calendar Server. It stores cleartext passwords in an XML file. Moving right along…
OpenDirectoryService
This, apparently, is what the Calendar Server in Leopard Server uses. I tried. But, unfortunately, setting up OpenDirectory, in a fashion that makes the Calendar Server happy, in the consumer version of Leopard, is a skill beyond my abilities.
BasicDirectoryService and DigestDirectoryService
These use the same authentication mechanisms as Apache. Indeed, they can be configured to use the same user/group files as my Apache Webserver. That seemed ideal. I decided to go with Digest Authentication.

The conf/caldavd-test.plist has sample settings for all four types of Directory Services. Unfortunately, neither BasicDirectoryService nor DigestDirectoryService actually works.

The reason can be found in the twistedcaldav/config.py file. There are defaults set for XMLDirectoryService, OpenDirectoryService (these can be overridden in the conf/caldavd.plist), but not for the others. No defaults, no workee. Easy enough to fix, though:

--- twistedcaldav/config.py     (revision 2553)
+++ twistedcaldav/config.py     (working copy)
@@ -30,6 +30,16 @@
"twistedcaldav.directory.xmlfile.XMLDirectoryService": {
"xmlFile": "/etc/caldavd/accounts.xml",
},
+    "twistedcaldav.directory.apache.DigestDirectoryService": {
+        "userFile": "/etc/caldavd/digestusers",
+        "groupFile": "/etc/caldavd/groups",
+        "realmName": "caldav",
+    },
+    "twistedcaldav.directory.apache.BasicDirectoryService": {
+        "userFile": "/etc/caldavd/users",
+        "groupFile": "/etc/caldavd/groups",
+        "realmName": "caldav",
+    },
"twistedcaldav.directory.appleopendirectory.OpenDirectoryService": {
"node": "/Search",
"requireComputerRecord": True,

This was enough to let me start up the server, and connect to it with iCal. Unfortunately, authentication would always fail. Hmmmm…. I wonder why.

In twistedcaldav/directory/apache.py, we find:

class DigestUserRecord(AbstractUserRecord):
"""
Apache DigestUserFile implementation of L{IDirectoryRecord}.
"""
def verifyCredentials(self, credentials):
raise NotImplementedError()

Okay …

How about Basic Authentication? Since both the server and iCal 3.0 support SSL connections, sending cleartext passwords over the wire would not be so bad.

That finally worked. So I now have a CalDAV server, with calendars that I can access from anywhere.

#### Transferring Data

Create a new CalDAV account in the iCal preferences, and connecting to the server for the first time creates a new (blank) calendar. This, and any other calendars that you create in this account are fully readable and writeable from any CalDAV client.

Transferring the data from old calendars to the new CalDAV calendars is easy: export the old calendar to a .ics file, and then drag the file onto the new calendar. You can even drag several .ics files onto the new calendar, thereby consolidating calendars which previously were maintained separately.

#### Sharing

My wife, alas, is still on Tiger.

• iCal 2.0 doesn’t support SSL connections.
• iCal 2.0 can only subscribe to calendars stored as single .ics files, rather than as directories (one .ics file per event), which is the CalDAV format used by iCal 3.0.
• And, thoughtfully, the ability to publish CalDAV calendars to (another) WebDAV server has been removed from iCal 3.0.

My solution? I found a project that merges a directory of .ics files into a single calendar, modified it a bit, and now run it as a cron job to merge my CalDAV calendars into the format my wife can subscribe to.

#### Update (6/18/2008):

On a side note, it appears that Snow Leopard Server will sport a similar CardDAV Server, for sharing contact (vCard) information.
Posted by distler at June 14, 2008 5:39 PM

TrackBack URL for this Entry:   http://golem.ph.utexas.edu/cgi-bin/MT-3.0/dxy-tb.fcgi/1715

### Re: CalDAV

Regarding the Sharing section, we have apparently both invented the same wheel ;-) I’ve done very much the same thing, also based on merge_ics:

http://www.demon.cx/icaldavmerge/

However in my case there was some extra work to build the single ics file for all accounts on the CalDAV server (and the list of accounts is dynamic with people joining & leaving the company).

Posted by: JJ Spreij on February 22, 2009 8:31 AM | Permalink | Reply to this

### icaldavmerge and phpical?

Hi,

I’m going to take a chance and comment on a post that’s over a year old. I’m trying to figure out how to publish a CalDAV calendar on a webpage; would it be possible to use icaldavmerge to merge one caldav calendar to an .ics file and use phpicalendar to publish it on a webpage?

thanks!

Posted by: Deks on August 25, 2010 8:09 PM | Permalink | Reply to this

### Re: icaldavmerge and phpical?

I haven’t used phpicalendar in years, but I imagine that would work fine.

Once upon a time (before CalDAV), I used to “share” my iCal calendar with my wife, by uploading the .ics file(s) to phpicalendar.

Posted by: Jacques Distler on August 25, 2010 9:22 PM | Permalink | PGP Sig | Reply to this

Post a New Comment