mTLS(双向 TLS)与 JGit

问题描述 投票:0回答:0

我正在尝试使用 JGit 在我的 Spring Boot java 应用程序和 git 存储库之间设置 mTLS

这里是 Git bean 设置:

       Git git = Git.init()
                .setDirectory(new File(localRepoFullPath))
                .setBare(false)
                .call();
        git.remoteAdd()
                .setUri(new URIish(repoRemotePath)).setName("origin")
                .call();
        StoredConfig config = git.getRepository().getConfig();
        //http.sslCAInfo,sslCAPath,sslCert,sslKey sections are not parsed by JGit - more details below
        config.setString("http",null,"sslCAInfo" , gitMTLSProperties.getServerCertificatePath());
        config.setString("http",null,"sslCAPath" , gitMTLSProperties.getServerCertificatePath());
        config.setString("http",null,"sslCert" , gitMTLSProperties.getClientCertificatePath());
        config.setString("http",null,"sslKey" , gitMTLSProperties.getClientKeyPath());
        //the only way that works, but this disables all SSL checking and is absolutely not what I need
        config.setBoolean( "http", null, "sslVerify", false );
        config.save();
        git.checkout()
                .setCredentialsProvider(new UsernamePasswordCredentialsProvider("token", pat))
                .setCreateBranch(true)
                .setName("master")
                .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK)
                .setStartPoint("origin/master")
                .call();

根据 eclipse.org 论坛和 Christian HalstrickFriend 的帖子 和 Matthias SohnFriend 其中提到了 2 个拉取请求:
https://git.eclipse.org/r/c/jgit/jgit/+/3199
https://git.eclipse.org/r/c/jgit/jgit/+/3200/
但他们仍然没有批准。

有人知道解决这个问题的替代方法吗?
也许有关于何时在 JGit 中实现此功能的信息?

提前感谢您的回答!

java jgit
© www.soinside.com 2019 - 2024. All rights reserved.