OK for me it works after hours of struggling. Let's make a long story short. I hope it is clear enough.
My config is:
OSX Server 10.8
Roundcube 0.9.3
Carddav plugin 0.5.1 (found here: https://github.com/graviox/Roundcube-CardDAV)
Symptom 1)
Could not add an Addressbook server because it reported that "CarDAV server cannot be connected" or something similar.
Solution:
Comment out the following line within your carddav_backend.php file:
// curl_setopt($this->curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
Actually we face an authentication issue here. Since my mail server is the same as my roundcube server I do not mind if it will use plaintext, digest or something else.
Symptom 2)
After finally being able to connect I could not sync.
Solution
I found the solution somewhere on the net. (Sorry I cannot cite the name of the site but if you are interested of the source google is your friend.) My credits for those guys of course.
Replace this line in carddav_backend.php:
$response = $this->query($this->url, 'PROPFIND');
With these lines:
$content = '<?xml version="1.0" encoding="utf-8" ?>
<D:sync-collection xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:carddav">
<D:sync-token></D:sync-token>
<D:sync-level>1</D:sync-level>
<D:prop><D:getcontenttype/><D:getetag/><D:allprop/>
<C:address-data><C:allprop/></C:address-data></D:prop>
<C:filter/></D:sync-collection>';
$content_type = 'application/xml';
$response = $this->query($this->url, 'REPORT', $content, $content_type);
Symptom 3)
After being able to sync I could edit and delete existing contacts but I was unable to create a new one. Reason is that OSX server expects UID inside a new vcard. To achieve:
Modify function add($vcard) inside carddav_backend.php by adding below this line:
$vcard_id = $this->generate_vcard_id();
The following line:
$vcard = str_replace('END:VCARD' , 'UID:' . $vcard_id . "\n" . 'END:VCARD', $vcard);
Symptom 4)
Even I could create a new contact after saving the card I still received an error message. The card WAS created but still a save error occured.
So I lost my patience and I made a bit of hack here.
To remove that error message change the following line within carddav_addressbook.php inside carddav_add($vcard) function:
$rcmail->db->insert_id(get_table_name('carddav_contacts'));
to this:
return true;
Now it works pretty well! Syncs, adds, deletes, modifies contacts.
And sorry for my English.