简体   繁体   中英

svn checkout via cmd using java

I am working on svn and trying to perform checkout operation via command prompt. Here is my command

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

After running this command I am getting output like that

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?

Now after pressing (t)emporarily or (p)ermanently my files are checkout.

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

Now I am performing same via my java code and passing the command via processbuilder. But I am getting some SSL certificate verification error.

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

Is there any command in svn where we can pass username and password and will not give any ssl certificate errrors?

Here is my java code to perform checkout operation

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

Upon executing I am getting the errorstream output as

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

try the following options svn co --trust-server-cert --non-interactive ...

Caution: be sure to really know what you do! for some reason this error is thrown (probably a wrong certificate, probably a self-signed certificate, probably a MITM!)

UPDATE: this options seems only to work for untrusted CAs (manpage: accept SSL server certificates from unknown certificate authorities )

but your certificate is invalid (instead of "just" not trusted). see bypass ssl certificate validation in subversion for further hints

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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