2017-05-31 93 views
0

我正在使用svn并尝试通过命令提示符执行结帐操作。这是我的命令svn通过cmd使用java结帐

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

现在按(T)之后运行此命令我得到的输出像

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? 

后emporarily或(P)ermanently我的文件结账。

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); 
     } 

在执行我收到errorstream输出

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 
+0

您是否尝试过使用java库,例如https://svnkit.com/? 证书问题将无法解决,但也许你可以调整客户端来抑制该警告。 – ipper

回答

0

请尝试以下方法svn co --trust-server-cert --non-interactive ...

注意: 肯定真正知道你在做什么!出于某种原因引发此错误(可能是一个错误的证书,可能是自签名的证书,可能是一个MITM!)

UPDATE:这个选项似乎只对不受信任的CA(手册页:accept SSL server certificates from unknown certificate authorities)工作

但您的证书无效(而不是“只”不可信)。 有关更多提示,请参阅bypass ssl certificate validation in subversion

+0

仍然收到相同的错误。 svn:E230001:服务器SSL证书验证失败:证书颁发给不同的主机名,颁发者不可信 –

+0

对不起,我的不好。 这些选项似乎只适用于不受信任的CA(manpage:'接受来自未知证书颁发机构的SSL服务器证书) – Fabian