Trust Self Signed Certificates with Immich - OAuth Setup #18614
Replies: 5 comments 7 replies
|
To get this to work correctly, I had to also configure a DNS for the immich_server service so that the oauth2 endpoint both the certificate and the immich service itself knew where to go to talk to the OAuth service. services:
immich-server:
...
dns:
- ${DNS_SERVER}
... |
|
Hi, Thank you a lot for this, but despite doing precisely what you said, I'm still having the same error : To provide you with some context, everything is running on a proxmox host with two interfaces (vmbr0 : 192.168.1.20/24 & vmbr1 : 10.10.10.254/24) I have one domain controller VM (samba) at 10.10.10.1 and I have configured authelia (at 10.10.10.4:9091) to authenticate against the ldap. It works fine. I have enabled TLS using a trusted chain with the domain's CA certificate and authelia'CA certificate and key. I have an NGINX Reverse Proxy Manager at 192.168.1.X and 10.10.10.253. I have forwarded the authelia and immich hosts and I can access the both of them. However, I can't get immich to work with authelia.
I believe that the issue occurs because while my DC (which I set as the DNS in the docker-compose.yaml) resolves auth.home.lan at 10.10.10.4, NPM redirects auth.home.lan at 10.10.10.4:9091 directly. However, I do not know how to fix this. I can share both my Authelia and Immich configs if need be. I don't know what to try next... Any chance you could help ? Thanks ! |
|
I would argue that the proper fix here is to use the publicly exposed endpoint of Authentik as the OAuth URL in Immich. In OPs case, that would be the Authentik-URL exposed via nginx. This of course assumes that this endpoint is using a public cert (via nginx). It's quicker, and also more secure (as you don't have to trust any self-signed certs that you also have to renew). |
|
Getting the same problem with Authentik and NPMPlus. I can curl the authentik https address fine from the server, but from within the immich container I get: I have tried to use various certificates:
but still get the same result. Can anyone advise exactly which certificate I need? For Sectigo I have tried the full certificate bundle .crt and the wildcard crt. For letsencrypt I have fullchain1.pem - but it expires and gets renewed every week so this doesn't seem like a good solution... Why can't we have an option built into the gui to help with this, like the mobile app. Any way to work out which certificate is missing? Many thanks M |
|
I tried following the instructions, but I am still getting Error in OAuth discovery: TypeError: fetch failed (Immich Server Error) on Immich The communication works if I switch the OAuth URL to HTTP (non-HTTPS). However, I want it to run over HTTPS (I am fine with the container-to-container communication to run via HTTP, but if I set the HTTP URL in the OAuth setting issuer_url in in Immich it also uses it to redirect the user when logging in, and I want the user->authentik connection to go over HTTPS). I am using Authentik with a self-signed certificate: In the Authentik admin interface, I generated a new certificate pair (System > Certificates) with common name and alt name authentik.abc-def.ts.net, and configured it to be used as Web Certificate in System > Brands > Other global settings. I downloaded this certificate and stored it in Both Authentik and Immich are deployed as containers in the same host. Authentik is running on ports 9000 (HTTP) and 9443 (HTTPS), and binding the same ports in the host machine, and it is exposed via Tailscale at authentik.abc-def.ts.net (also both ports). Since the Immich container does not have the Tailscale client, I added an extra host to Immich container mapping the authentik Tailscale domain to the host machine ( services:
immich-server:
...
environment:
NODE_EXTRA_CA_CERTS: /certs/authentik.abc-def.ts.net_certificate.pem
extra_hosts:
- "authentik.abc-def.ts.net:host-gateway"Extra sanity checksInside the Immich container, I checked that the certificate in /certs is the same exposed by Authentik and seen by Immich: # Install OpenSSL in Immich container
$ apt update && apt install -y openssl
# Download SSL certificate exposed by Authentik and saves in tmp folder
$ echo | openssl s_client -showcerts -connect authentik.abc-def.ts.net:9443 2>/dev/null | openssl x509 > /tmp/cert.pem
# Compares certificates
$ md5sum /tmp/cert.pem /certs/authentik.abc-def.ts.net_certificate.pem
c313ea8a6856c9f0987f42b9590ae579 /tmp/cert.pem
c313ea8a6856c9f0987f42b9590ae579 /certs/authentik.abc-def.ts.net_certificate.pemAnother sanity check that the certificate is working: # Curl fails because it doesn't trust certificate
$ curl https://authentik.abc-def.ts.net:9443
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.se/docs/sslcerts.html
curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the webpage mentioned above.
# Adds the certificate from /certs to curl's trust store
$ cat /certs/authentik.abc-def.ts.net_certificate.pem >> /etc/ssl/certs/ca-certificates.crt
# Test curl again, now it succeeds
$ curl -v https://authentik.abc-def.ts.net:9443
* Host authentik.abc-def.ts.net:9443 was resolved.
...
* subjectAltName: host "authentik.abc-def.ts.net" matched cert's "authentik.abc-def.ts.net"
* issuer: CN=authentik 2026.5.3
* SSL certificate verify ok.
...
< HTTP/1.1 302 Found
...I did these tests to confirm the container is able to reach Authentik via the host mapping and received the correct certificate. However, I am still seeing the HTTP 500 error on Immich logs. |
Uh oh!
There was an error while loading. Please reload this page.
I was setting up Authentik to function as an OAuth2/OpenID provider for Immich, but ran into a problem where I'd get the following, somewhat vague error.
This is despite the fact that I could
curlmy Authentik server just fine at theISSUER_URLendpoint I have saved in Immich. However, if I pointed at the HTTP endpoint for Authentik instead, OAuth worked just fine.Turns out that Immich was having issues with the self-signed CA I used to issue the HTTPS cert for Authentik, which is using a reverse proxy I set up with NGINX. It would work at the HTTP endpoint, because I'd point directly to port 9000, which is what the Authentik container exposes by default.
Fortunately, this is a relatively easy fix for Immich!
/etc/pki/ca-trust/source/anchors/a. man page for update-ca-trust.
docker-compose.ymlfile, and for theimmich-serverservice, and add a mount to the/certsdirectory. In my case, I point directly to where my custom CA files are at on my Enterprise Linux distribution (my case Rocky Linux). Don't add theZflag if you don't have SELinux on your system.environmentblock and point to the specific CA file that issued your OAuth server's HTTPS cert.docker compose down && docker compose up -d, and try logging in via OAuth again. Fixed!Here's the full reference for the
immich-serverservice:All reactions