#798  Option to trust self-signed certificates
Released
Maciej Grabowski opened 2 years ago

Currently, OneDev is unusable with Kubernetes executor (perhaps all of them) if OneDev is behind revers proxy with TLS termination made with certificate provided by non-public Certificate Authority. Even if configured to checkout code via SSH, OneDev still tries to pull job data via HTTPS, crashing on broken TLS chain. Only way to work in such setup is via fallback to insecure setup with HTTP.

It would be nice if it was possible to provide custom CA and / or to allow OneView to ignore TLS issues.

Robin Shen commented 2 years ago

Allowing OneDev to ignore TLS issues implies a major security issue. Why not use LetsEncrypt in this case?

Maciej Grabowski commented 2 years ago

It's internal installation and all other services are already deployed with PKI provided by internal CA. Also, cert-manager breaks a lot on Kubernetes.

Prabir Shrestha commented 1 year ago

I hit into the same issue but when setting up LDAP connection which is an internal service connected by docker and I want to ignore TLS verification but then provide my custom domain to verify cert against.

Here is an example how authelia does this and it works for me. I would like to have similar options for LDAP configurations in onedev. https://www.authelia.com/configuration/first-factor/ldap/

authentication_backend:
  ldap:
    implementation: custom
    url: ldaps://10.10.10.10
    timeout: 5s
    start_tls: false
    tls:
      server_name: ldap.example.com
      skip_verify: false
      minimum_version: TLS1.2
      maximum_version: TLS1.3
Timo Reichl commented 1 year ago

+1 for inserting custom SSL certificates. For Helm, I like the GitLab Runner approach: https://gitlab.com/gitlab-org/charts/gitlab-runner/-/blob/v0.49.0/values.yaml#L83

Essentially, they can be added to the Java trust store (or maybe the Ubuntu way: /usr/local/share/ca-certificates).

Update: Tried it the Ubuntu way, didn't work. So it has to be done at the application/JVM (executor) level itself.

jbauer commented 1 year ago

@thetredev Have you called update-ca-certificates? This will update /etc/ssl/ and only then it might work.

Timo Reichl commented 1 year ago

I did. I also updated the Java keystore in the container to no avail.

Marcos de Oliveira commented 1 year ago

I think Java reads cacerts on start and do not updated it, so you might restart Onedev with cacerts updated. I tried it this way and it worked:

Dockerfile:

FROM 1dev/server AS build
# Put your certs in a directory `certs` under current directory...
COPY certs /usr/local/share/ca-certificates
RUN update-ca-certificates

FROM scratch AS export
COPY --from=build /etc/ssl/certs/java/cacerts .

Then:

docker build --output=. .

Then, mount ./cacerts in /etc/ssl/certs/java/cacerts... Like: docker run -v $PWD/cacerts:/etc/ssl/certs/java/cacerts:ro or in compose:

services:
  onedev:
    image: 1dev/server:latest
    volumes:
    - "./cacerts:/etc/ssl/certs/java/cacerts:ro"
Timo Reichl commented 1 year ago

Thanks, I didn't know about how Java handles that stuff. Gotta try this at home later today!

Marcos de Oliveira commented 1 year ago

Just a heads up: --output required buildkit, so either enable buildkit or use docker buildx build...

Timo Reichl commented 1 year ago

I tried it and it worked. With Docker Compose it feels right at home actually. But using Kubernetes it's janky, because the Chart values don't have an option for additional mounts. I modified the deployment myself but that's a hack I'm not sure I want to live with. :)

@robin are there any plans for something like extraVolumeMounts and extraVolumes by any chance? That way we could work around that in a more sophisticated manner.

Robin Shen commented 1 year ago

@thetredev will add this improvement in a future release.

Timo Reichl commented 1 year ago

@robin very cool, thank you!

Robin Shen changed title 1 year ago
Previous Value Current Value
Add option to ignore SSL/TLS errors AND / OR add option to provide custom Certificate Authority (CA)
Option to trust self-signed certificates
OneDev changed state to 'Closed' 1 year ago
Previous Value Current Value
Open
Closed
OneDev commented 1 year ago

State changed as code fixing the issue is committed

Timo Reichl commented 1 year ago

Sorry to comment on the closed issue, but I can't seem to find the option. Where do I find documentation to trust my own CA? Thanks!

Robin Shen commented 1 year ago

The fix will be delivered in 8.0.0 which will be released mid this month.

Timo Reichl commented 1 year ago

Aahh okay cool.

OneDev changed state to 'Released' 1 year ago
Previous Value Current Value
Closed
Released
OneDev commented 1 year ago

State changed as build #3440 is successful

Robin Shen commented 1 year ago

Please follow below guide on how to trust self-signed CA/certificates:

https://docs.onedev.io/administration-guide/trust-self-signed-certificates

Timo Reichl commented 1 year ago

Very nice, thank you very much! I'll test this later today.

Referenced from commit 1 year ago
issue 1 of 1
Type
Improvement
Priority
Major
Assignee
Issue Votes (1)
Reference
onedev/server#798
Please wait...
Page is in error, reload to recover