0

If I use jgit clone to clone repository from remote instance docker, I am getting this error:

org.eclipse.jgit.api.errors.TransportException: https://<repo url>: Secure connection to https://<repo url> could not be established because of SSL problems 
Caused by: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

So I am trying to bypass SSL check as mentioned here: Turn SSL verification off for JGit clone command As given in the above link, I am trying to use jgit fetch(), instead of jgit clone:

public void fetchRepository(Git git) throws GitAPIException {

    FetchCommand fetchCommand =
            git.fetch()
                    .setCredentialsProvider(
                            new UsernamePasswordCredentialsProvider(
                                    user, getSecretAuthTokenProvider(accountName)));
    fetchCommand.call();
}

but getting this exception: 'org.eclipse.jgit.api.errors.InvalidRemoteException: Invalid remote: origin Caused by: org.eclipse.jgit.errors.NoRemoteRepositoryException: origin: not found.'

How should I clone entire repository using jgit fetch?/ How should I bypass SSL certification check?/ How should I resolve SSL certification issue for docker?

  • See https://stackoverflow.com/questions/19045556/git-clone-https-ssl-error if it solves SSL problems. `git init & git fetch` can simulate `git clone`. But here `origin` is not set yet, you need to `git remote add origin ` before `git fetch origin`. You can also use `git fetch ` directly. – ElpieKay Jun 04 '21 at 02:05
  • 1
    "clone" literally means "create new empty repository, add remote, run fetch, and run checkout". The step that needs security is the access to some other repository to do the fetch operation. Using fetch instead of clone is thus a bit like borrowing someone else's car, instead of getting and using your own, in order to avoid having to drive somewhere: it doesn't actually help any as you've only skipped the steps that were actually *working*. – torek Jun 04 '21 at 02:27
  • Your call to `FetchCommand` is missing `setRemote` (if not set it defaults to `origin`). You can either pass the URL directly, or configure the just initialized repository with a remote that points to the URL (see also `RemoteAddCommand`). – Rüdiger Herrmann Jun 04 '21 at 08:06

0 Answers0