繁体   English   中英

使用Java通过cmd进行svn结帐

[英]svn checkout via cmd using java

我正在svn上尝试通过命令提示符执行结帐操作。 这是我的命令

svn co --username=username --password=password "the url from where I want to checkout" "Path where I want to checkout"

运行此命令后,我将得到类似的输出

Error validating server certificate for 'https://muurlname':
 - The certificate is not issued by a trusted authority. Use the
   fingerprint to validate the certificate manually!
 - The certificate hostname does not match.
Certificate information:
 - Hostname: PKI
 - Valid: from Jul 21 06:11:01 2015 GMT until Jul 21 06:41:01 2017 GMT
 - Issuer: PKI
 - Fingerprint: FD:9B:96:09:E9:A3:A8:A8:81:78:7E:71:28:FE:BB:93:BF:D0:15:C7
(R)eject, accept (t)emporarily or accept (p)ermanently?

现在,在临时按(t)或永久按(p)之后,我的文件被签出。

Restored 'D:\Adapters Code SVN\SVN Adapter Test\testfile1.txt'
Restored 'D:\Adapters Code SVN\SVN Adapter Test\checkfile.txt'
Checked out revision 1465.

现在,我通过Java代码执行相同的操作,并通过processbuilder传递命令。 但是我收到一些SSL证书验证错误。

svn: E170013: Unable to connect to a repository at URL 'https://myurlname'
svn: E230001: Server SSL certificate verification failed: certificate issued for a different hostname, issuer is not trusted

svn中是否有任何命令可以传递用户名和密码,并且不会给出任何ssl证书错误?

这是我执行结帐操作的Java代码

String url = "https://myWorkingUrl";
        String checkoutPath = "D:\\Adapters Code SVN\\SVN Adapter Test";
        String command = "svn checkout " + "--trust-server-cert --non-interactive "
                + "--username=hoh7kor --password=emmawatson " + "\"" + url + "\"" + " " + "\"" + checkoutPath + "\"";
        ProcessBuilder pb = new ProcessBuilder();
        pb.command("cmd.exe", "/c", command);
        Process p = pb.start();
        p.waitFor();
        BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
        String line;
        while ((line = br.readLine()) != null) {
            System.out.println(line);
        }
        String line2;
        while ((line2 = br2.readLine()) != null) {
            System.out.println(line2);
        }

执行后,我得到错误流输出为

svn: E170013: Unable to connect to a repository at URL 'https://myUrl'
svn: E230001: Server SSL certificate verification failed: certificate issued for a different hostname, issuer is not trusted

尝试以下选项svn co --trust-server-cert --non-interactive ...

注意:一定要真正了解您的工作! 由于某种原因抛出此错误(可能是错误的证书,可能是自签名证书,可能是MITM!)

更新:此选项似乎仅适用于不受信任的CA(联机帮助: accept SSL server certificates from unknown certificate authorities

但您的证书无效(而不是“仅”不可信)。 有关更多提示,请参见Subversion中的绕过SSL证书验证。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM