unable to find valid certification path to requested target

错误提示

   unable to find valid certification path to requested target

     unable to find valid certification path to requested target

这是 java 对https 验证导致的错误 因为地址不被信任

 

解决办法

查看当前 gradle 所用的 java 环境  ( 如果是纯java程序 那么跳过这一步 )

    unable to find valid certification path to requested target

 

第一步 打开要访问的地址 将证书导出
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.0/gradle-3.5.0.pom
删除后面的 新地址为
    https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.0
打开浏览器

    unable to find valid certification path to requested target

开始导出证书

    unable to find valid certification path to requested target

    

unable to find valid certification path to requested target

   unable to find valid certification path to requested target

    unable to find valid certification path to requested target

导出成功 在对应目录会存在证书 

   

将这个证书导入
切换到  就是 gradle所用的java环境
    cd /d %javaHome%\jre\lib\security
开始导入
    keytool -import -file 要导入证书的地址 -keystore cacerts -alias 别名
    -alias 指定别名(推荐和证书同名)
    -keystore 指定存储文件(此处固定)
    -file 指定证书文件全路径(证书文件所在的目录)

    库**口令输入:changeit
    是否信任:Y

查看证书
    keytool -list -keystore cacerts -alias 别名
    显示如下代表导入成功

unable to find valid certification path to requested target

然后重新导入即可

    unable to find valid certification path to requested target

    unable to find valid certification path to requested target

 

如果嫌麻烦 我会上传已经写好的 cacerts (2019 12 19 开始审核资源)

https://download.csdn.net/download/azazazazaz123456/12040013