When I try to clone an existing remote git repository using JGit api, I get the below error.
Exception:org.eclipse.jgit.api.errors.TransportException: http://admin@localhost:7990/scm/cp/myrepo.git Secure connection to https://admin@localhost:7990/scm/cp/myrepo.git could not be stablished because of SSL problems
In my class I have the below method which I use to clone the repository.
public static void cloneRepoTemp(String cloneRepoUrl, String username, String password)
throws FileNotFoundException, IOException {
Git git;
try {
git = Git.cloneRepository().setURI(cloneRepoUrl)
.setCredentialsProvider(new UsernamePasswordCredentialsProvider(username, password))
.setDirectory(new File("C:/temp/testrepo")).setBranch("integration").call();
git.close();
} catch (GitAPIException e) {
System.out.println("Exception:" + e);
}
I know I can address this issue by using the below command,
git config --global http.sslVerify false
But, since I am using JGit api I want to enable that via the api itself rather than making the setting explicit on the host machine. Also, I intend to have the library distributed in multiple machines so do not make the change in users' machine to make that change for my code to work.
Is there a way to achieve this in code without adding a entry in git configuration file.