2016-06-13 57 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剛剛發佈。 –