Where to tell caldav.DavClient to use self-signed SSL certificate? (405 Method Not Allowed)

191 Views Asked by At

XY problem

While trying to make syncall sync taskwarrior locally with Nextcloud over https at https://localhost:6780 I encounter error:

requests.exceptions.SSLError: HTTPSConnectionPool(host='localhost', port=7995): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)')))

Because I do not provide syncall with a private SSL certificate, nor with the self-signed root ca.

Adding the SSL certificate

To ensure syncall is able to verify the self-signed public root ca, I would like to give the filepath to the /home/some_name/public_root_ca.pem to the Python caldav pip package. I expect this can be done at either in caldav_side.py:

self._client = client.principal()

or in tw_caldav_sync.py:

client = caldav.DAVClient(url=caldav_url, username=caldav_user, password=caldav_passwd)
    caldav_side = CaldavSide(client=client, calendar_name=caldav_calendar)

However, I did not find any arguments in either of those 3 methods yet, that accept the (path towards the) self-signed root ca SSL. Hence, I would like to ask:

Question

How can I tell the caldav pip package to use a self-signed root ca SSL certificate whilst contacting the CalDav/Nextcloud server?

Approach I

The documentation suggests one can add: `ssl_verify_cert="some_path.ca" in:

client = caldav.DAVClient(url=caldav_url, username=caldav_user, password=caldav_passwd,ssl_verify_cert=False)

However, when I include: ssl_verify_cert=False or ssl_verify_cert=/home/some_name/ca.pem, I get error:

Traceback (most recent call last):
  File "/home/name/miniconda/bin/tw_caldav_sync", line 8, in <module>
    sys.exit(main())
  File "/home/name/miniconda/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/name/miniconda/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/name/miniconda/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/name/miniconda/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/name/miniconda/lib/python3.10/site-packages/syncall/scripts/tw_caldav_sync.py", line 199, in main
    caldav_side = CaldavSide(client=client, calendar_name=caldav_calendar)
  File "/home/name/miniconda/lib/python3.10/site-packages/syncall/caldav/caldav_side.py", line 37, in __init__
    self._client = client.principal()
  File "/home/name/miniconda/lib/python3.10/site-packages/caldav/davclient.py", line 411, in principal
    self._principal = Principal(client=self, *largs, **kwargs)
  File "/home/name/miniconda/lib/python3.10/site-packages/caldav/objects.py", line 470, in __init__
    cup = self.get_property(dav.CurrentUserPrincipal())
  File "/home/name/miniconda/lib/python3.10/site-packages/caldav/objects.py", line 202, in get_property
    foo = self.get_properties([prop], **passthrough)
  File "/home/name/miniconda/lib/python3.10/site-packages/caldav/objects.py", line 227, in get_properties
    response = self._query_properties(props, depth)
  File "/home/name/miniconda/lib/python3.10/site-packages/caldav/objects.py", line 163, in _query_properties
    return self._query(root, depth)
  File "/home/name/miniconda/lib/python3.10/site-packages/caldav/objects.py", line 194, in _query
    raise error.exception_by_method[query_method](errmsg(ret))
caldav.lib.error.PropfindError: PropfindError at '405 Method Not Allowed

b''', reason no reason

I am unsure whether this is because Nextcloud declines access, or whether the caldav has some issue with passing the certificate, or whether syncall has an unexpected difficulty with this.

0

There are 0 best solutions below