-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: allow self-signed qBittorrent server certificates. #1753
base: dev
Are you sure you want to change the base?
Conversation
Here's the code health analysis summary for commits Analysis Summary
|
Not sure if we should allow |
An environment variable could also govern this. People could accept the risk optionally. A full trust chain would be nice too but it's a bit more work and most people are going to have insecure certs if any at all imo. Especially given it uses the internal routes, most are going to be the self signed since it's a security implication to use a real ca. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As described in my comment, I do not agree with this change as it impacts the security significantly and should not be used in production.
For what it's worth, I've been using I'm talking about securing from socket <-> socket internally. When you're hosting things, you shouldnt use your real domain cert everywhere either. That could expose your key and is also another security implication. I'm operating on the impression that this is optional, and in general, something is better than nothing. When people come to homarr in my instance, they go to a reverse proxy with a LE encryption. How Same with any app. But internally, I am also implementing more of a zero trust. It would seem nice if homarr could talk to qbittorrent via that, especially considering all the arrs, and everything else does. |
Yes, because the library
You're talking about... what? Qbittorrent exposes a socket that a client can connect to. In this case, Homarr is the client. Certificates also apply to this connection though, similar as they do for normal HTTP.
Could you elaborate on this? I do not agree. You never need the private key to verify SSL encryption. Maybe https://www.cloudflare.com/learning/ssl/what-is-ssl/ and https://www.cloudflare.com/learning/ssl/what-is-asymmetric-encryption/ would be interesting reads for you.
Yes, something is indeed better than nothing. However, with untrusted certs you break many tools and you should not allow direct requests to your reverse proxy targets anyway. You should either trust this certificate on all of your clients (which will be hard, especially if you run more tools like Homarr) or use a trusted authority (like Let's Encrypt).
I'm assuming you're referencing to the Servarr apps. They will also break if you use selfsigned certs. See https://forums.sonarr.tv/t/sonarr-v3-self-signed-ssl-cert-error-when-adding-download-client/25476/2 . I strongly recommend you create an isolated network, that does not accept any direct requests, except from your reverse proxy - regardless whether it's accessed from local network, VPN or externally. That way you also have the same certificates, access logs, access policies and proxy being used for all requests. It also simplifies certificate renewal and eliminates dangerous point of failures. |
I'm talking
Alot of people are used to mounting their I have an isolated network. Like I said before, I am running Authelia as an IdP and everything is reverse proxied with a LE cert. I'm trying to add internal certificates for docker network traffic. Let me turn the tables. Why would I not want to use HTTPS on my qBt instance and my reverse proxy? Assume they cannot access the qBt instance or whatever anyways, if my firewall isn't a joke. That qBt https instance lives in its own docker subnet (almost) alone. Nginx, Homarr have IP's. But it would be great if it talked via homarr via ssl. No ports are exposed beyond the reverse proxy. OIDC , etc, etc,. I agree that Authelia should be using a valid cert. But I dont care if qBt is. And for the reasons I stated, I prefer it not. But I prefer not to use HTTP. |
Then is there any reason, why you'd not want Homarr to go over the proxy as well? It just seems to complicate things more.
Obviously you should not mount or give your private keys to any third person. Same applies to the Docker Socket as you said 👍
Thanks for explaining. As mentioned, this can be easily fixed by using a trusted certificate or trusting a self-signed certificate inside Homarr (and every of your clients, including Nginx). Your solution outlined in this PR will fix this problem as well, but it also disables any certificate checks. It is still better than using plain HTTP (or any unencrypted protocol for this matter) but the integrity & safety of the connection is no longer guaranteed. I strongly vote that we allow the user to mount / upload their own certificate (mount seems safer to me, can be used in automated systems, such as Kubernetes clusters, where certificates are renewed or replaced automatically). |
Summary of Changes
|
Thank you so much for the change. I'm wondering whether we should create a wrapper for
This way, self signed certificates are handeled in a common & known way. Error handling can be centralized and we only need to write tests once for the same code. We also avoid code duplication and multiple behaviours for the same functionality. @Meierschlumpf / @SeDemal / @voc0der what do you think? |
I only kind of agree. IMO it makes sense to have a centralized function 👍🏼 |
Good idea, but maybe we can add this in a second iteration? Or do you have any concrete proposal how we could implement this? I agree with OP; we need some kind of solution for this problem soon-ish. |
Would this new view accept file paths from the environment as an override? Might I propose not storing it in the database but having the UI work similar to that? Most cert users are not manually going to want to renew. Both my LE and Self signed chains are managed by scripts. This would be the first and only application that tries to take over my certs and manage them itself. Which, please don't take offense.. 😅 is kind of the reason using a real cert everywhere is bad towards my original point. Maybe if the env variables exist, additional UI controls exist to verify the cert? That being said I now need to learn how to do that with the homarr codebase.. |
I think we should discuss this further before implementing it 😉 |
I think the problem with storing it in the database will be certificate renewals. As an example. I automatically fetch certificates in my Kubernetes cluster by referencing them in my ingress. They are usually valid for a short amount of time (e.g. 30 days) and will expire. Uploading them into a database will eventually lead to expiry. I would vote that we mount a certificate instead. We could check whether they can conflict (e.g. make requests to other sites, like |
You mean one specific directory where you can place all your certificates in and then it makes the fetch request to all the integrations with that as |
Yes, that would be my suggestion. We could list the certificates in a dropdown on the integration create / edit page to let the user select them. That way, a certificate issuer (e.g. a script, an issuer in a cluster or just a manual file update) can update the certificate on the fly. If the certificate was deleted in the mean time, just log a warning and not use any custom certificate to verify. What do you think, @voc0der ? Would you also be willing to implement this? From my point of view, the priority for this isn't too high, so it's likely we would prioritize it for a release after 1.0. |
I like the ideas and I think I can do it. I'll take a look at how the templating works. If I'm understanding it correctly, each app will have a Failing to load that file (e.g. say the CA dir is missing), it will try to load insecurely. If no certificate is selected, and they save that configuration, they ignore the SSL altogether. |
Homarr
Thank you for your contribution. Please ensure that your pull request meets the following pull request:
pnpm buid
, autofix withpnpm format:fix
)dev
branchx
,y
,i
or any abbrevation)Summary
This update improves the
getClient
method in theQBitTorrentIntegration
class to support qBittorrent servers with self-signed SSL certificates. The implementation adds anhttps.Agent
configuration to bypass certificate validation when connecting via HTTPS.Changes
https.Agent
withrejectUnauthorized: false
to allow self-signed certificates.https.Agent
to therequestConfig
parameter of theQBittorrent
client.Benefits
Example Usage
The client now automatically works with:
https.Agent
handles certificate validation bypass.This is my first PR for this project so I haven't actually built or tested this.
I can't get the beta to work with OIDC, so this is just speculative.