Unable to add self-hosted git repo as Data source #12774
Replies: 9 comments 9 replies
-
The simple and secure solution would be to give your local gitlab server a valid certificate signed by LetsEncrypt. If it has a public IP (v4 or v6) and accepts inbound HTTP connections on port 80, then it's easy - use a client like certbot or dehydrated with the HTTP01 challenge. If not, it becomes a bit more difficult as you have to set up the DNS01 challenge, either by integrating with your authoritative nameserver's API or by running a separate one like acme-dns. Of course, once you have this working, you can sign all the certs you like for your domains - and automatically fetch new ones every 60-90 days. Also consider certgrinder which is good if you want a single host to perform all the certificate fetching work on behalf of your other hosts; those other hosts don't need any Internet connectivity at all. The other option would be to attempt to get your Netbox installation to trust the (private) certificate authority that you used to sign your gitlab server's certificate - which may be the server certificate itself, if it's self-signed. For these use cases it might be nice if the "data sources" in Netbox had the option to specify a different CA certificate for each data source when using https URLs. Since Netbox doesn't have this feature, the only other option would be to try and install the root CA certificate, but there are several places you might need to put the CA cert to get it trusted, including your system certificate store, and the python certifi package inside the Netbox virtualenv. Certificate stores vary significantly between OSes and I'm not going to guess how it might be done on yours. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your answer. To precise my issue, it is not a self-signed certificate but an internal PKI signed certificate. The ertificate authority is already trusted by the netbox server. From the server I can git clone successfully and I can also git clone from the venv. The only "git clone" that does not worked is from the Data source feature. I was thinking about trust the certificate authority inside the certifi store but I am not confident on how to do it. Can you confirm it is the good way to resolve this issue ? But I think by default the Data source features should trust the system certificate store. |
Beta Was this translation helpful? Give feedback.
-
I added all my certificate chain (Root + sub CA) into certifi trust store, I got the same error. |
Beta Was this translation helpful? Give feedback.
-
Does anyone have an idea how to fix this problem? I still do not know if I am doing somthing wrong or if it is just not possible in this netbox release. |
Beta Was this translation helpful? Give feedback.
-
Hi There, porcelain lib read the sslCAInfo in the gitconfig of the user to operate. So you should use it to set your custum bundle CA: |
Beta Was this translation helpful? Give feedback.
-
Hi, |
Beta Was this translation helpful? Give feedback.
-
I am also facing this problem and opened the feature proposal Data Sources | Git | Allow to select customized CA Cert file for HTTPS URLs #13989 |
Beta Was this translation helpful? Give feedback.
-
As under the hood
|
Beta Was this translation helpful? Give feedback.
-
So, was this ever resolved? I'm facing the same situation where my data source refuses to work because of certificate verification issues. |
Beta Was this translation helpful? Give feedback.
-
NetBox version
v3.5.1
Python version
3.9
Steps to Reproduce
Expected Behavior
Synchro of self-hosted git repo as Data source.
Observed Behavior
Logs return an ssl error whereas custom CA certificate are installed. I try to git clone directly from the netbox worker and it is OK, only git clone using Data source does not work.
In the log we got this error:
17:14:24 default: core.jobs.sync_datasource(job=<Job: 64d84b92-962a-4f1c-8a21-0d03cc1f5670>) (64d84b92-962a-4f1c-8a21-0d03cc1f5670)
ERROR:root:Fetching remote data failed (MaxRetryError): HTTPSConnectionPool(host='mygitlab.mydomain', port=443): Max retries exceeded with url: /myproject.git/info/refs?service=git-upload-pack (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get issuer certificate (_ssl.c:1123)')))
INFO:rq.worker:default: Job OK (64d84b92-962a-4f1c-8a21-0d03cc1f5670)
17:14:24 default: Job OK (64d84b92-962a-4f1c-8a21-0d03cc1f5670)
INFO:rq.worker:Result is kept for 500 seconds
Beta Was this translation helpful? Give feedback.
All reactions