Bug 52766 - Kelvin API doesn't work if apache2 is configured to use a non-UCS-CA certificate
Kelvin API doesn't work if apache2 is configured to use a non-UCS-CA certificate
Status: CLOSED FIXED
Product: UCS@school
Classification: Unclassified
Component: HTTP-API (Kelvin)
UCS@school 4.4
Other Windows NT
: P5 normal (vote)
: ---
Assigned To: Tobias Wenzel
Daniel Tröder
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2021-02-10 21:45 CET by Michael Grandjean
Modified: 2022-05-12 11:06 CEST (History)
5 users (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 5: Major Usability: Impairs usability in key scenarios
Who will be affected by this bug?: 2: Will only affect a few installed domains
How will those affected feel about the bug?: 3: A User would likely not purchase the product
User Pain: 0.171
Enterprise Customer affected?:
School Customer affected?: Yes
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Grandjean univentionstaff 2021-02-10 21:45:10 CET
root@ucs01:~# univention-app info
UCS: 4.4-7 errata887
Installed: prometheus-node-exporter=1.1 self-service=4.0 self-service-backend=4.0 ucsschool=4.4 v8 ucsschool-kelvin-rest-api=1.2.0 4.3/admin-dashboard=1.2 4.3/prometheus=1.1
Upgradable:

Expected behaviour: 
I can configure apache2 to use a different certificate than the default via UCRVs apache2/ssl/{ca,certificate,key} and the Kelvin API still works.

Observed behaviour:
If I configure apache2 to use a certificate that is not signed by the local UCS CA (e.g. a Let's Encrypt certificate), the Kelvin API returns an "Internal Server Error" while trying to read from or write to LDAP.


As far as I understand, the Kelvin REST API server utilises a UDM REST API client which then talks to the UDM REST API server to create/modify/delete LDAP objects (see https://docs.software-univention.de/ucsschool-kelvin-rest-api/overview.html). The UDM REST API client now tries to verify the SSL certificate when talking to the UDM REST API server. Since the UDM REST API server is provided via apache2, it uses the certificate configured via UCRVs apache2/ssl/{ca,certificate,key}.
Unfortunately, Kelvin has the UCS CA certificate hardcoded for ssl verification and passes this on to the UDM REST API client:
https://git.knut.univention.de/univention/ucsschool/-/blob/feature/kelvin/kelvin-api/ucsschool/kelvin/constants.py#L77
https://git.knut.univention.de/univention/ucsschool/-/blob/feature/kelvin/kelvin-api/ucsschool/kelvin/ldap_access.py#L69

This leads to a situation where the certificate can't be verified, if it's not signed by the local UCS CA. The operation aborts with a traceback that can be found in /var/log/univention/ucsschool-kelvin-rest-api/http.log (see attachment) and Kelvin returns "Internal Server Error".

I propose that it should be possible to:
a) easily configure other CA certificates for the verification
b) easily replace the copy of the UCS CA certificate inside the Kelvin Docker container, because certificates tend to expire at some point

Maybe this can be done via the Kelvin App Settings?
Comment 5 Tobias Wenzel univentionstaff 2021-06-17 12:19:33 CEST
QA Checklist

1. Certificates other than a UCS CA signed certificate can be used.
2. The scenario is tested with a different (e.g. Let's Encrypt) certificate.
3. Documentation exists and is comprehensive
4. Tests exist and pass
5. Kelvin is released
Comment 6 Tobias Wenzel univentionstaff 2021-06-21 17:06:29 CEST
The fix, including tests was implemented in

[juern/52766_kelvin_certs] 0420122b5 Bug #52766: add documentation
[juern/52766_kelvin_certs] df34d30ea Bug #52766: add custom crt support
Comment 7 Daniel Tröder univentionstaff 2021-06-29 16:19:34 CEST
OK: code review
OK: changelog
OK: manual tests
OK: automated test by Jenkins
Comment 8 Daniel Tröder univentionstaff 2021-06-29 16:31:41 CEST
Documentation update is online.
Comment 9 Daniel Tröder univentionstaff 2021-06-30 16:11:22 CEST
Kelvin 1.4.4 has been released.