2016-06-13 59 views
3

我需要使用gradle从github获取文件。我发现this plugin。下面的例子为我工作:使用Gradle任务从github下载文件时出现SSLPeerUnverifiedException

task downloadZipFile(type: Download) { 
    src 'https://github.com/michel-kraemer/gradle-download-task/archive/1.0.zip' 
    dest new File(buildDir, '1.0.zip') 
} 

但是,当我更换URL与一个我需要:(https://github.com/broadinstitute/cromwell/releases/download/0.19/cromwell-0.19.jar)我得到以下错误:

8:00:37 AM: Executing external task 'downloadZipFile'... 
:downloadZipFile 
Invalid cookie header: "Set-Cookie: logged_in=no; domain=.github.com; path=/; expires=Fri, 13 Jun 2036 12:00:38 -0000; secure; HttpOnly". Invalid 'expires' attribute: Fri, 13 Jun 2036 12:00:38 -0000 
:downloadZipFileFAILED 

FAILURE: Build failed with an exception. 

* What went wrong: 
Execution failed for task ':downloadZipFile'. 
> javax.net.ssl.SSLPeerUnverifiedException: Host name 'github-cloud.s3.amazonaws.com' does not match the certificate subject provided by the peer (CN=*.s3.amazonaws.com, O=Amazon.com Inc., L=Seattle, ST=Washington, C=US) 

* Try: 
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 

BUILD FAILED 

Total time: 1.91 secs 
Host name 'github-cloud.s3.amazonaws.com' does not match the certificate subject provided by the peer (CN=*.s3.amazonaws.com, O=Amazon.com Inc., L=Seattle, ST=Washington, C=US) 
8:00:39 AM: External task execution finished 'downloadZipFile'. 

什么可能是错的,我只需更换github上带有另一个github网址的网址。

+0

'acceptAnyCertificate true'帮了我一些忙,但它似乎并不安全解决方案:\ – Derp

+0

您是否在代理之后? – RaGe

+0

@RaGe nope。请注意,使用https github链接的原始任务可正常工作 – Derp

回答

2

this comment,以下内容添加到您的build.gradle脚本的开头:

// Temporary workaround, see 
// https://github.com/michel-kraemer/gradle-download-task/issues/56 
buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'de.undercouch:gradle-download-task:3.1.1' 
     classpath 'org.apache.httpcomponents:httpclient:4.5.2' 
    } 
} 

为我工作。

+0

解决方法不再是必需的。 gradle-download-task 3.1.2刚刚发布。 –