我正在尝试通过我的Java应用程序列出远程git服务器中的分支,即时消息使用jgit org.eclipse.jgit-3.7.0.201502260915-r.jar,但是当我运行时,我遇到了ans ssl异常,我想自定义mu git connection禁用sslVerify
public List<String> GetProductBranches(String prductUrl) throws IOException {
List<String> versions = new ArrayList<String>();
System.out.println("User: " + this.gitUser);
System.out.println("Pwd: " + this.gitPwd);
String gitPrductUrl="https://"+this.gitUser+"@"+prductUrl;
System.out.println("Pwd: " + gitPrductUrl);
try {
Collection<Ref> remoteRefs = Git.lsRemoteRepository()
.setHeads(false)
.setTags(false)
.setRemote(gitPrductUrl)
.setCredentialsProvider(new UsernamePasswordCredentialsProvider(this.gitUser, this.gitPwd))
.call();
for( Ref ref : remoteRefs ) {
if (ref.getName().contains("refs/heads/"))
{
System.out.println("Ref: " + ref.getName().replace("refs/heads/", ""));
versions.add(ref.getName().replace("refs/heads/", ""));
}
}
} catch (GitAPIException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
return versions;
}
这是例外
`org.eclipse.jgit.api.errors.TransportException: https://***.git: cannot open git-upload-pack
at org.eclipse.jgit.api.LsRemoteCommand.execute(LsRemoteCommand.java:223)
at org.eclipse.jgit.api.LsRemoteCommand.call(LsRemoteCommand.java:159)
at testGit.Authenticate.GetProductBranches(Authenticate.java:69)
at testGit.Authenticate.main(Authenticate.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: org.eclipse.jgit.errors.TransportException: https://T***.git: cannot open git-upload-pack
at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:524)
at org.eclipse.jgit.transport.TransportHttp.openFetch(TransportHttp.java:309)
at org.eclipse.jgit.api.LsRemoteCommand.execute(LsRemoteCommand.java:202)
... 8 more
Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.Alerts.getSSLException(Alerts.java:154)
at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1961)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1077)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1323)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:515)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1299)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338)
at org.eclipse.jgit.transport.http.JDKHttpConnection.getResponseCode(JDKHttpConnection.java:98)
at org.eclipse.jgit.util.HttpSupport.response(HttpSupport.java:168)
at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:475)
... 10 more`