Caldav to icalendar issues

Hello!
I have begun to migrate my openHAB system from 2.5 to 3. So far i have been able to figure out most of the changes needed just by searching and reading the forums, but i am having a bit of truble getting icalendar to work.
When i use the same information i used for caldav i get a cuple of errors when it tries to retrieve the calendar from my self hosted nextcloud calendar.
I enabled DEBUG for icalendar and these are the errors i get:

==> /var/log/openhab/openhab.log <==

2021-05-18 12:15:23.122 [DEBUG] [ar.internal.handler.ICalendarHandler] - The calendar is currently offline as no local copy exists. It will go online as soon as a valid valid calendar is retrieved.

2021-05-18 12:15:23.210 [WARN ] [g.icalendar.internal.handler.PullJob] - Download of calendar failed.

2021-05-18 12:15:23.212 [DEBUG] [g.icalendar.internal.handler.PullJob] - ExecutionException message is: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

==> /var/log/openhab/events.log <==

2021-05-18 12:15:23.107 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'icalendar:calendar:Nextcloudy' changed from UNINITIALIZED (DISABLED) to INITIALIZING

2021-05-18 12:15:23.123 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'icalendar:calendar:Nextcloudy' changed from INITIALIZING to OFFLINE

==> /var/log/openhab/openhab.log <==

2021-05-18 12:16:23.299 [WARN ] [g.icalendar.internal.handler.PullJob] - Download of calendar failed.

2021-05-18 12:16:23.300 [DEBUG] [g.icalendar.internal.handler.PullJob] - ExecutionException message is: HttpConnectionOverHTTP@2b2424::DecryptedEndPoint@1dfe299{/192.168.2.3:8443<->/192.168.2.2:38920,CLOSED,fill=-,flush=C,to=0/0}

It seems to be a certificate issue? Im not that adept at understanding the debug messages so im hoping one of you can point me in the right direction.

Some more information:
Openhab is on its own rpi while i have nextcloud on a second rpi as a docker image, along with pihole(non docker), pivpn(non docker).
On my old 2.5 setup caldav still pulls the calendar without issues.

As you’ve correctly pointed out, this is a certificate issue. Seems like you are not using a publicly trusted certificate. In that case the certificate or the corresponding Root-certificate has to be added to the keystore and be trusted.

1 Like

Thanks for the info!
I probably should have mentioned that both openhab and nextcloud are accessed outside of the local network through a vpn, so i have to rely on the self-signed certificates.

Unfortunately i don’t have as much time to work on this as I’d like. I have located the nextcloud certificates .pem and .key files and copied them over to the openhab pi.
Now i just got to figure out how to add it to the openhab keystore and see if that solves the problem.

If i succeed i’ll post the process of how i did it, incase anyone else runs into the same problem, or for future me that will forget how i did it the first time. :sweat_smile:

So I finally took some time to try again and get it working.

A few things I learned while figuring this out:

The certificate has to be added to the java keystore.
In my case for OpenHAB 3 this was located at:
“/opt/jdk/zulu11.48.21-ca-jdk11.0.11-linux_aarch32hf/lib/security/cacerts”

For nextcloud, I had to make a new self signed certificate with the IP address of the host pi added to “Subject Alt Names” in the certificate.
Then I had to copy the certificate .key into the docker container to the location “/etc/ssl/private/”
And also the .pem file to “/etc/ssl/certs/”
Afterwards I had to edit the “nextcloud.conf” file located at “/etc/apache2/sites-available/”
I edited “SSLCertificateFile” and “SSLCertificateKeyFile” to point to my new certificate.

After restarting the nextcloud container and also OpenHAB, icalendar finally started working!

Thats about it for the short version, due to how hectic it is at work right now I’m too tired to work on my OpenHAB system when i’m home, so this took a while to get back to.

I plan to write a more detailed tutorial on how to do this once I get some time off at end of july/beginning of august.
Though I must admit, it felt really good when I finally got this working on my own.

Thanks to OpenHAB, I’ve learned more about linux then I ever thought I would!

1 Like