Skip to content
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

Optional TLS cert for Git over HTTPS #93

Closed
stefanprodan opened this issue Jul 17, 2020 · 10 comments
Closed

Optional TLS cert for Git over HTTPS #93

stefanprodan opened this issue Jul 17, 2020 · 10 comments
Assignees
Labels
area/git Git related issues and pull requests enhancement New feature or request

Comments

@stefanprodan
Copy link
Member

stefanprodan commented Jul 17, 2020

When using Git over HTTPS, the controller should look for the cert files inside the credential secret, the same way we do for Helm repositories.

apiVersion: source.fluxcd.io/v1alpha1
kind: GitRepository
metadata:
  name: podinfo
  namespace: default
spec:
  url: https://github.com/stefanprodan/podinfo
  secretRef:
    name: https-credentials
---
apiVersion: v1
kind: Secret
metadata:
  name: https-credentials
  namespace: default
type: Opaque
data:
  username: <BASE64> 
  password: <BASE64> 
  certFile: <BASE64>
  keyFile:  <BASE64>
  caFile:   <BASE64>

The certFile, keyFile and caFile should be optional, when present, the controller will use them to connect to the Git HTTPS server.

@stefanprodan stefanprodan added enhancement New feature or request area/git Git related issues and pull requests labels Jul 17, 2020
@hiddeco
Copy link
Member

hiddeco commented Jul 20, 2020

This is not going to be the easiest to solve due to the fact that the go-git/go-git HTTP client is runtime shared based on the protocol of the remote URL.

https://github.com/go-git/go-git/blob/641ee1dd69d3b8616127623e4b9341f4f4196d12/remote.go#L368
https://github.com/go-git/go-git/blob/641ee1dd69d3b8616127623e4b9341f4f4196d12/plumbing/transport/client/client.go#L16

@stefanprodan
Copy link
Member Author

This can be implemented using libgit2 as this library allows us to handle the TLS handshake.

@phillebaba
Copy link
Member

I just got a question about using mutual TLS. It might be worth implementing support for that if possible also, which we are at it.

@CermakM
Copy link

CermakM commented Jan 23, 2021

Is there any temporary workaround for this?

@aidmax
Copy link

aidmax commented Jan 26, 2021

Hi, also interested in adding self-signed git source (GitHub Enterprise) using https.

@stealthybox
Copy link
Member

stealthybox commented Jan 28, 2021

This is not going to be the easiest to solve due to the fact that the go-git/go-git HTTP client is runtime shared based on the protocol of the remote URL.

@hiddeco perhaps this is solvable by wrapping a Client with host specific behavior.
Maybe we would override a Connect() method

@hiddeco
Copy link
Member

hiddeco commented Jan 29, 2021

perhaps this is solvable by wrapping a Client with host specific behavior. Maybe we would override a Connect() method

What worries me is the management of the host specific behavior and credentials.

It would require something like a host <-> credential pool with a TTL so that credentials for resources that "magically disappear" are evicted from the pool.

Also: using the host is not a 100% fool proof, as multiple resources could point to the same host but with a different (m)TLS configuration.

@phillebaba
Copy link
Member

I have started working on an implementation that would work with the libgit2 provider FYI. Still a need to figure out how one would do this with go-git.

@stefanprodan
Copy link
Member Author

I think it's acceptable to having this feature implemented for libgit2 only.

@stefanprodan
Copy link
Member Author

Implemented in #283

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/git Git related issues and pull requests enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants