mirror of
https://github.com/moghtech/komodo.git
synced 2026-05-06 08:55:40 -05:00
[GH-ISSUE #130] Self signed certificates for OIDC #4690
Reference in New Issue
Block a user
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 @tedstriker on GitHub (Oct 16, 2024).
Original GitHub issue: https://github.com/moghtech/komodo/issues/130
Is there a way to use accept self signed certificates of the authentication server when using OIDC?
Usually a CA certificate chain can be added with reference to the file with environment variables like
SSL_CERT_FILE: /etc/ssl/certs/ca-certificates.crtfor PHP based projects orNODE_EXTRA_CA_CERTS=/etc/ssl/certs/ca-certificates.crtfor NodeJS based ones.With Komodo all those known variables don't work and I get the following error:
Any ideas how to make the self signed CA known to the app?
@mbecker20 commented on GitHub (Oct 16, 2024):
Hey, you can package your root CA certificate into the container with some simple modifications. Currently from setup you should have two files
{database}.compose.yamlandcompose.env.Add your root cert
root.crtnext to these ones, and create an an additional file calledcore.Dockerfilewith these contents:Now modify the
core:service in{database}.compose.yaml:This will also allow
gitto work with an internal git provider behind an internal CA. Users running Periphery in container can do the same thing for Periphery to allow it to reach internal git provider. Periphery running insystemdwill just use the host certs, so the root CA needs to be added to/etc/ssl/certsand runupdate-ca-certificates(basically what is happening in the Dockerfile)From https://stackoverflow.com/questions/26028971/docker-container-ssl-certificates
@tedstriker commented on GitHub (Nov 4, 2024):
Thank you for your elaborate explanation.
Usually something like this:
is enough to introduce a new certificates to the system.
The 2nd line is just the same file as in the first line. For some reason
update-ca-certificatesuses the files hash as its filename. Most times it is neccesary to reference those certificates in specific ENV vars like mentioned initially.update-ca-certificatesrun on the host in that case.Is there a possibility to just bind the ca certificate file via
volumesin thedocker-compose.yamlinstead of creating an entire image just to add a certificate file in the appropriate place?@tedstriker commented on GitHub (Nov 4, 2024):
I got
update-ca-certificatesrunning inside the container. It added the certificate properly, but unfortunately it is not recognized by Komodo.These changes to the compose file seemed to work.
Do you have another idea what could be tried next?
here's the log excerpt after a fresh container start:
@mbecker20 commented on GitHub (Jan 3, 2025):
Hey, apologies for the long delay. There is a reason I mention to do it via custom build. I went through same process as you, and it didn't work like you notice. But finally I tried the method I recommended to you, because I saw it mentioned in that stack overflow link before. I think it makes a difference whether the crt is added as a layer via custom build, versus mounted into container.
You can avoid a dedicated dockerfile by using
dockerfile_inline:Please let me know how it works out for you, or whether you already got it to work another way. I definitely didn't try everything possible using mounts instead of custom build, figuring out this method would also be appreciated!
@tedstriker commented on GitHub (Jan 13, 2025):
No worries, and thank you for taking the time to elaborate on your approach and provide an example.
I gave it a try and confirmed that the certificate has been successfully copied and populated using
update-ca-certificateswithwgetin the console. It worked forwget.Unfortunately, the outcome remains the same as when mounting the certificate files directly, when it comes to enabling OIDC. They just get ignored.
It seems like the module responsible for establishing the HTTPS connection has its own certificate store. So I had a look around.
This might have something to do with the
reqwestmodule and the issue discussed here.Key Note from the Linked Issue
The post mentions using the
rustls-tls-native-rootsfeature withreqwestto enable the use of OS-native root certificates:This is further explained in the documentation here.
Its successor, rustls-platform-verifier, is the recommended package to replace
rustls-tls-native-roots.To summarize, while I’m not a Rust developer, it might be worth trying to modify line 50 in Cargo.toml to use the following configuration:
This would use
rustls-platform-verifierinstead.What do you think about this approach?
@mbecker20 commented on GitHub (Jan 15, 2025):
Thanks for looking into that, I think you are correct about the issue being reqwest crate using rustls not picking up certs.
Komodo uses the
openidconnect-rsrust crate for the OIDC implementation: https://github.com/ramosbugs/openidconnect-rs. It depends on this OIDC crate's features, given here:5632960ea9/Cargo.toml (L27)The OIDC crate then depends on a lower level
oauth2-rscrate (made by same author), this is the crate which chooses the features which reqwest uses:9a2b746f76/Cargo.toml (L23)I think those crates need to be updated to allow crate consumers to choose
rustls-native-rootsfeature ofreqwestcrate:3099f30f08/Cargo.toml (L52). Maybe this issue could be brought to @ramosbugs attention?@tedstriker commented on GitHub (Jan 16, 2025):
Tried to get in touch and it got declined. From what I've seen it seems that no change on the oauth2-rs side is necessary.
Regarding the why I'm lost.
Maybe the reasoning and explanation in the related closed merge request tells you more than it does for me?
@tylerhunt commented on GitHub (Jan 20, 2025):
@mbecker20 This comment makes it sounds like this can be done by the application without requiring the libraries in the middle to be updated: https://github.com/ramosbugs/oauth2-rs/pull/287#issuecomment-2380046784
@tylerhunt commented on GitHub (Jan 28, 2025):
I had to make a couple changes to the suggested inline
Dockerfileto get the certificate registered properly:I'm now able to access the OIDC server from within the container:
I also updated the
Cargo.tomlfiles with therustls-tls-native-rootsfeature and rebuilt the project.But this still doesn't solve the
invalid peer certificate: UnknownIssuererror when the OIDC client tries to connect.Docker log output
@tedstriker commented on GitHub (Feb 1, 2025):
The problem wasn't that the certificates weren't registered properly on OS level, because this works alright.
Issue is, they don't get recognized by komodo itself, due to the discussed behavior of
reqwest.I wonder what happend, if the usage of
rustls-tlsfeature gets replaced entirely withrustls-tls-native-roots(or its successor: rustls-platform-verifier)From there on, no
reqwestcall should be possible without supporting OS level ca-certificates, or did I miss something?@tylerhunt commented on GitHub (Feb 1, 2025):
rustls-tls-native-rootsisn't a Cargo package, it's a feature ofreqwest. It looks like what this does is configure use of the packagerustls-native-certs.I'm not sure
rustls-platform-verifieris the answer here, as it looks to be designed to solve this problem on non-Linux platforms. Their README itself seems to suggest that if you're using Linux, thenrustle-native-certs+webpkiis the right choice.@draeron commented on GitHub (Feb 1, 2025):
Definitly not an expert on rust, but my understanding is that pretty much all other languages either support native CA loading (ex: go) or can be set through somekind of ENV (ex: java, nodejs).
@mbecker20 commented on GitHub (Mar 6, 2025):
This should be fixed in 1.17.0-dev-4 release: https://github.com/moghtech/komodo/releases/tag/v1.17.0-dev-4. It now uses reqwest with
rustls-tls-native-rootsfeature.I tested with self hosted Zitadel behind TLS with internal certs and it worked.
@tylerhunt commented on GitHub (Mar 7, 2025):
@mbecker20 Works for me,
although the email address doesn't seem to be coming through when auto-registering a user. I'll create a new issue for that. (Never mind. It looks like my OIDC provider is passing through an empty email address.)@somerandomguy17 commented on GitHub (Apr 6, 2025):
I'm on v1.17.0 and followed all the steps in this chain (adding the certificate via dockerfile_inline) and am still not able to get self-signed certs to work. It looks like the certificate is recognized inside the container
but the container fails to start with the following error:
It looks like komodo doesn't believe the cert is valid (bad signature) but this same certificate is used for other services with no issue, so I don't think its a certificate issue. Any idea on what I need to do to get this working?
Happy to create a new issue if necessary!
@tedstriker commented on GitHub (Apr 12, 2025):
I think the issue is a new error.
My impression is, that the ca certificate added to your os cert store and the certifcate presented from your OIDC provider aren't matching up properly.
Did you make 100% sure,
@somerandomguy17 commented on GitHub (Apr 12, 2025):
There is a reverse proxy involved but it uses acertificate signed by the same root CA. I have confirmed the URL to the OIDC is valid (the url in the "error sending request" is my OIDC provider's config and I can rezzsolve it via curl inside the container).
@somerandomguy17 commented on GitHub (Apr 27, 2025):
I spent a bunch of time debugging this weekend and have figured out the issue is somewhere with how rustls-tls-native-roots validates certificates. I rebuilt the image using the native-tls feature of reqwest and it works perfectly. From what I'm reading (and I don't claim to be an expert on rust or tls) rustls does additional verification beyond the native tls verication
@Mr3ase commented on GitHub (Jul 8, 2025):
Regarding the original issue, I managed to get it to work without an additional file, in the .yml :
Pass your root cert to the core container through volumes
- /path/to/cert.crt:/usr/local/share/ca-certificates/cert.crt:roOverride the launch command to update CA certs first then start Komodo Core normally. Add this to core:
docker logs <core container name>@yujqiao commented on GitHub (Dec 1, 2025):
For anyone following this patch, the image name should be updated to ghcr.io/moghtech/komodo-core
@SapuSeven commented on GitHub (Dec 2, 2025):
What ended up working for me was the following (either as Dockerfile or inline):
@b3nw commented on GitHub (Dec 18, 2025):
was this fixed both in core and periphery? running into this issue Komodo Periphery version: v1.19.5
@Dnny44 commented on GitHub (Dec 31, 2025):
I also just started running into this issue with v1.19.5 but with Lets Encrypt Certs, not Self Signed.
@yungtechboy1 commented on GitHub (Mar 19, 2026):
Make sure you have the correct certificates installed on the system then add this to the Env Var for Core.
DENO_TLS_CA_STORE=system,mozillaV2.0.0-dev-124