Cloning into '/builds/***/***'...fatal: unable to access 'https://gitlab-ci-token:xxxxxx@***/***/***/': server certificate verification failed.CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: noneBuild failed with exit code 128
We have GitLab and GitLab CI running on the same server with self signed certificates and the GitLab CI multi-runner on another server that talks to both without any issues.
What does not work however is cloning the repositories inside of a Docker executor since the Docker image does not contain our self-signed certificates. (see output above)
Is there a way to inject our self-signed certificates automatically into the container that is created by the runner? I have found the tls_cert_path option, but that seems to be unrelated to our current issue.
Possible solution:
new injected_certificates option
create temporary, shared volume on container creation
move configured certificates into /usr/share/ca-certificates/ (container) via that volume
add certificates to /etc/ca-certificates.conf (i.e. echo "gitlab-ci.crt" >> /etc/ca-certificates.conf)
run update-ca-certificates
This solution might only work for Debian/Ubuntu-based images though. It might make sense to use a more generic after_creation option instead, that can be used to run those commands mentioned above.
Designs
Child items
...
Show closed items
Linked items
0
Link issues together to show that they're related or that one is blocking others.
Learn more.
I am having a slightly different issue where my tests clone a bunch of repos for fixture data but the git repos are private so it requires a deploy key in the container. While I could create the docker image with my deploy key I would prefer to run a script before job execution that would inject whatever I need. I could keep this in the build script but I don't want to expose the keys in every git repo and want it specified in the runner config.toml.
I'm having a similar issue and haven't found a solution. We have an internal root certificate authority installed on our servers, but Docker does not inherit the system certificates which causes it throw a fatal error:
fatal: unable to access 'https://gitlab-ci-token:...@gitlab.../...git/': server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none
Using shell executor works, but it makes it difficult to manage installing dependencies via apt-get and npm install -g that are easier to deal with within Docker.
adding environment = ["GIT_SSL_NO_VERIFY=1"] to the runner instead of the host volume works well too. since we are running the servers in the same controlled network this should not be a big security issue for us.
I believe that I hit a road block on this issue as well. Has there been a fix other than the various workarounds proposed?
My opinion on this issue:
Ideally, the solution would modify config.toml, but not a modify .gitlab-ci.yml. I believe that cloning the repository, including passing the certificate information to docker, should be the responsibility of the runner and should be detached from the .gitlab-ci.yml file. I always assumed that the .gitlab-ci.yml file should not be dependent upon the configuration of the runner.
Potential issues with using before_clone to pass the certificate:
Anyone that clones a repository from a private gitlab server with a private gitlab ci runner would need to modify the .gitlab-ci.yml file to work with their runner. Since this is committed to the repository, I think requiring modification is a bad idea.
If there are multiple runners that each require their own unique configuration, a single before_clone section would not be able to elegantly handle this. What happens if one runner uses docker but another does not?
For this reason, I don't like the solution of using a before_clone step or the variables: section in .gitlab-ci.yml.
Instead, shouldn't the configuration of the docker container be delegated to the runner?
@ayufan Would it be possible to configure this completely within config.toml? Specifically the runners.docker section seems appropriate. Some type of before_clone section there would make more sense to me.
This issue seems related to #129 (closed). I think the idea 2 proposed here may be better if it means no modification necessary to .gitlab-ci.yml.
My idea is to not require any config.toml configuration at all. Since we connect to server already we do have all TLS certificates. We can read these certificates and inject them into build environment. Then use env variables to configure git clone and artifacts uploader.
We can do it this way, because we trust that runner can do secure connection and runner did verify the certificate already.
@ayufan Oh, I see. So that would make this completely automated without any extra configuration in either config.toml or .gitlab-ci.yml.
I had completely forgotten that the git repo could just use the same TLS certificate that the runner uses to connect, such as the one provided by tls-ca-file.
If this is the case, please disregard my entire previous post. What you described sounds perfect. I look forward to this change! Thanks for clearing that up for me and for all your hard work!
@ayufan I'm struggling to find the code or branch that has certificate injection. Is it in master? Do you know, in which version of the runner this will be released?
I also have problems with this. Is this in all runners for all executors?
I am basically using shell executor and the clone fails also with
Cloning into '/builds/***/***'...fatal: unable to access 'https://gitlab-ci-token:xxxxxx@***/***/***/': server certificate verification failed.CAfile: /etc/ssl/certs/ca-certificates.crt
When I add my intermediate(?) Comodo Cert to /etc/ssl/certs/ca-certificates.crt the clone works, but how can I make this more generic?
I am not using a self-signed cert, so I believe there has to be a a way to import these certs somehow.
The file you are manually adding is an intermediate CA ("COMODO RSA Domain Validation Secure Server CA"). If the ROOT CA ("COMODO RSA Certification Authority" aka "COMODO SECURE™") which signed the intermediate CA is installed you should not need to manually add the intermediate as trusted but instead tell the https server to send the intermediate cert to connecting clients.
@t-munk that looks good. However my computer has "COMODO RSA Certification Authority" installed as self signed root, but your chain depends on another ROOT CA ("AddTrust External CA Root"). Also your chain has an interesting order, maybe changing the order fixes issues but I'm not sure. (see http://stackoverflow.com/questions/20409534/how-does-an-ssl-certificate-chain-bundle-work )
@p-schneider Thank you for the links. I'll try this again if I find the time.
I also found issues about certificate chain ordering but had no luck in solving it this way.
What made me wonder is the fact that onlygit on trusty complained about the cert. I also tried to tell git the cert path and so on.