mirror of
https://github.com/lldap/lldap.git
synced 2026-04-25 08:15:52 +03:00
[GH-ISSUE #740] [FEATURE REQUEST] Accept .pem input for CERT_FILE and KEY_FILE #270
Labels
No labels
backend
blocked
bug
cleanup
dependencies
docker
documentation
duplicate
enhancement
enhancement
frontend
github_actions
good first issue
help wanted
help wanted
integration
invalid
ldap
pull-request
question
rust
rust
tests
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/lldap-lldap#270
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @crealte on GitHub (Nov 18, 2023).
Original GitHub issue: https://github.com/lldap/lldap/issues/740
Motivation
Certbot and other tools generate .pem file types but LLDAP expects .crt and .key file types.
Describe the solution you'd like
Accept .pem format for CERT_FILE and KEY_FILE
Describe alternatives you've considered
A simple renaming of the file type works but it is an additional step, especially when it comes to renewal.
cp privkey.pem privkey.key
cp fullchain.pem fullchain.crt
Additional context
Environment Variables:
- LLDAP_LDAPS_OPTIONS__ENABLED=true
- LLDAP_LDAPS_OPTIONS__CERT_FILE=/certs/fullchain.pem
- LLDAP_LDAPS_OPTIONS__KEY_FILE=/certs/privkey.pem
Error Logs:
Loading configuration from /data/lldap_config.toml
2023-11-18T22:58:52.896096119+00:00 INFO set_up_server [ 4.10ms | 100.00% ]
2023-11-18T22:58:52.896128426+00:00 INFO ┝━ i [info]: Starting LLDAP version 0.5.1-alpha
2023-11-18T22:58:52.929989375+00:00 INFO ┕━ i [info]: Starting the LDAP server on port 3890
2023-11-18T22:58:52.930173015+00:00 ERROR 🚨 [error]: Could not bring up the servers: while binding the LDAP server: while setting up the SSL certificate: No such file or directory (os error 2)
2023-11-18T22:58:52.930450496+00:00 INFO i [info]: End.
@nitnelave commented on GitHub (Jan 22, 2024):
Sorry, I'm just now having another look at the bug: there's nothing that cares about the file extension, it's not about .pem or .key or .crt. In both cases, I open the file myself and just pass the bytes to a function that extracts the key. I don't understand how copying can solve the issue.
Are you sure it's not a misconfiguration and you didn't mount the correct files into the container? In particular, I would expect a very different error message if it was an unsupported format.
@crealte commented on GitHub (Mar 20, 2024):
Apologies for the late reply but indeed what I posted in my original post is indeed what I am still observing. I tried it again and renamed the file to privkey.pem and fullchain.pem and the container fails with the same error. I rename to .key and .crt and it works again. Permissions are unchanged.
@nitnelave commented on GitHub (Mar 20, 2024):
How do you configure it? How do you set the environment variables, or the values in the config file?
@crealte commented on GitHub (Mar 22, 2024):
Full environment variables and volume mounts below. For testing permissions were set to 777.
@nitnelave commented on GitHub (Apr 3, 2024):
See the key reading code here:
github.com/lldap/lldap@6f905b1ca9/server/src/infra/ldap_server.rs (L107-L149)Most importantly, all the functions trying to read a key are called with
&mut BufReader::new(File::open(&ldaps_options.cert_file)?)as an argument: they don't receive the file name, just the contents. As such, they cannot be filename-sensitive. I would encourage you to double-check your settings.Regarding your initial error, the "No such file or directory" is from
File::open, and it means that the file doesn't exist (or cannot be read, maybe?) Make sure the file exists, is mounted in the correct folder, go inside the container to check that the path that you give in the env variable exists. You can also check the verbose logs to see the config values that were actually read by LLDAP, and make sure that the path is the one you expect.