Turn SSL verification off for JGit clone command

前端 未结 3 2261
我寻月下人不归
我寻月下人不归 2020-12-06 12:07

I am trying to a clone of a Git Repository via the CloneCommand. With this piece of code

`Git.cloneRepo         


        
3条回答
  •  -上瘾入骨i
    2020-12-06 12:58

    I have inferred from all answers above for the snippet below;

    private void disableSSLVerify(URI gitServer) throws Exception {
        if (gitServer.getScheme().equals("https")) {
            FileBasedConfig config = SystemReader.getInstance().openUserConfig(null, FS.DETECTED);
            synchronized (config) {
                config.load();
                config.setBoolean(
                    "http",
                    "https://" + gitServer.getHost() + ':' + (gitServer.getPort() == -1 ? 443 : gitServer.getPort()),
                    "sslVerify", false);
                config.save();
            }
        }
    }
    

    This option is safer because it allows sslVerify to false for the gitServer alone.

    Please take a look at this link which shares other options.

提交回复
热议问题