0

EDITED

I am cloning git project using jgit library, and I need to clone this as ssh disabled. So I tried the Following method

Git result = Git.init().setDirectory(localPath).call();

StoredConfig config = result.getRepository().getConfig(); config.setBoolean( "http", null, "sslVerify", false ); config.setString("remote", "origin", "url", gitUrl); config.save();

result.fetch().setRemote("origin").call();

But still, I am getting

org.eclipse.jgit.errors.TransportException: https://XXXX:XXX/root/XXXX.git: cannot open git-upload-pack

Is there a better way to clone git project with SSL disabled?

1 Answers1

1

You are missing to save the config

Git git = new Git(localRepository);
StoredConfig config = git.getRepository().getConfig();
config.setString("remote", "origin", "url", "http://github.com/user/repo");
config.setBoolean( "http", null, "sslVerify", false );
config.save();

More info on this here : -

https://newbedev.com/turn-ssl-verification-off-for-jgit-clone-command

Aravind.HU
  • 9,194
  • 5
  • 38
  • 50
  • I tried that method as well, but still, get this error "TransportException occur while cloning the project, cannot open git-upload-pack" – Milinda Kasun Aug 26 '21 at 14:35
  • It is not a problem with your code, such an error occurs only if there is a problem in the Git Remote you have and also I have seen this error if there is a network proxy issue or firewall issue as well. I the easiest way to confirm that would be to clone some thing from github and try . – Aravind.HU Aug 27 '21 at 08:54