Maven编译过程中下载失败报错PKIX:unable to find valid certification path to requested target

在编译Flink源码时报如下错误,通过错误结合网上一些解决方法看得出来是因为访问网站需要证书验证,因此解决方法就是在网站上下载下来证书,再安装到jdk的jre/lib/security中。

Downloading: https://repo.hortonworks.com/content/repositories/jetty-hadoop/com/microsoft/azure/azure-mgmt-trafficmanager/1.16.0/azure-mgmt-trafficmanager-1.16.0.pom
[ERROR] Failed to execute goal on project flink-swift-fs-hadoop: Could not resolve dependencies for project org.apache.flink:flink-swift-fs-hadoop:jar:1.9.1: The following artifacts could not be resolved: org.apache.hadoop:hadoop-client:jar:2.8.1, org.apache.hadoop:hadoop-common:jar:2.8.1, org.mortbay.jetty:jetty-sslengine:jar:6.1.26, commons-beanutils:commons-beanutils:jar:1.8.3, com.google.code.gson:gson:jar:2.2.4, org.apache.hadoop:hadoop-auth:jar:2.8.1, com.nimbusds:nimbus-jose-jwt:jar:3.9, net.jcip:jcip-annotations:jar:1.0, net.minidev:json-smart:jar:1.1.1, org.apache.htrace:htrace-core4:jar:4.0.1-incubating, org.apache.hadoop:hadoop-hdfs:jar:2.8.1, org.apache.hadoop:hadoop-hdfs-client:jar:2.8.1, com.squareup.okhttp:okhttp:jar:2.4.0, com.squareup.okio:okio:jar:1.4.0, org.apache.hadoop:hadoop-annotations:jar:2.8.1, org.apache.hadoop:hadoop-openstack:jar:2.8.1: Could not transfer artifact org.apache.hadoop:hadoop-client:jar:2.8.1 from/to mapr-releases (https://repository.mapr.com/maven/): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn  -rf :flink-swift-fs-hadoop

1. Windows参考:
https://blog.csdn.net/gabriel576282253/article/details/81531746

2. CentOS 7:

  • 下载证书:
    Maven编译过程中下载失败报错PKIX:unable to find valid certification path to requested target_第1张图片
    Maven编译过程中下载失败报错PKIX:unable to find valid certification path to requested target_第2张图片
    Maven编译过程中下载失败报错PKIX:unable to find valid certification path to requested target_第3张图片

  • 将下载的证书上传到CentOS:

sftp> cd /opt/software/
sftp> put -r "C:\Users\Administrator\Documents\maven.cer"
Uploading maven.cer to /opt/software/maven.cer
  100% 2KB      2KB/s 00:00:00     
C:\Users\Administrator\Downloads\maven.cer: 2404 bytes transferred in 0 seconds (2404 bytes/s)
  • 安装证书:
    注意:一定要在${JAVA_HOME}/jre/lib/security/目录下安装证书。
    库密钥口令输入:changeit,是否信任输入:Y。
[root@node01 ~]# cd /opt/module/jdk1.8.0_231/jre/lib/security/
[root@node01 security]# keytool -import -alias maven -keystore cacerts -file /opt/software/maven.cer
Enter keystore password:  
Owner: CN=*.mapr.com, OU=Domain Control Validated
Issuer: CN=Go Daddy Secure Certificate Authority - G2, OU=http://certs.godaddy.com/repository/, O="GoDaddy.com, Inc.", L=Scottsdale, ST=Arizona, C=US
Serial number: f70a2d4d97a0a9a3
Valid from: Thu May 03 01:12:31 CST 2018 until: Sun May 03 01:12:31 CST 2020
Certificate fingerprints:
         MD5:  7E:66:74:CB:CC:C3:6F:5D:FC:8C:3E:9C:84:67:D2:84
         SHA1: 80:E2:BB:5B:08:5C:F0:A9:BE:B7:DE:6E:4D:76:B4:33:2D:C1:8B:F1
         SHA256: 4F:5D:68:91:67:96:D3:17:62:50:71:EE:B7:8B:B9:4B:C2:2A:DE:A8:60:25:C4:C9:1D:3C:84:F9:0E:94:19:86
Signature algorithm name: SHA256withRSA
Subject Public Key Algorithm: 2048-bit RSA key
Version: 3

Extensions: 

#1: ObjectId: 1.3.6.1.4.1.11129.2.4.2 Criticality=false
0000: 04 82 01 6B 01 69 00 76   00 A4 B9 09 90 B4 18 58  ...k.i.v.......X
0010: 14 87 BB 13 A2 CC 67 70   0A 3C 35 98 04 F9 1B DF  ......gp.<5.....
0020: B8 E3 77 CD 0E C8 0D DC   10 00 00 01 63 21 D7 BE  ..w.........c!..
0030: C7 00 00 04 03 00 47 30   45 02 21 00 C2 D5 96 56  ......G0E.!....V
0040: 60 5C C5 FD FD E1 08 7A   9A 1D 9E F1 9F 15 CC 0D  `\.....z........
0050: 96 90 38 70 1A D1 11 07   E9 9C C2 28 02 20 77 B6  ..8p.......(. w.
0060: C1 1B 32 0E 54 2D 4C BF   A7 3A 7A A0 3C 90 33 66  ..2.T-L..:z.<.3f
0070: BF 6E B8 0E 3C 03 DA FC   44 E5 E1 A8 B7 D7 00 76  .n..<...D......v
0080: 00 EE 4B BD B7 75 CE 60   BA E1 42 69 1F AB E1 9E  ..K..u.`..Bi....
0090: 66 A3 0F 7E 5F B0 72 D8   83 00 C4 7B 89 7A A8 FD  f..._.r......z..
00A0: CB 00 00 01 63 21 D7 C8   8D 00 00 04 03 00 47 30  ....c!........G0
00B0: 45 02 21 00 D7 03 93 BC   34 5E 49 2E B7 03 DC CD  E.!.....4^I.....
00C0: B9 A5 8E 16 14 C9 71 2F   3D E8 73 D3 CB 5C 34 6C  ......q/=.s..\4l
00D0: 65 A2 F7 F8 02 20 3B 4A   31 E4 2C 05 66 CD FB 0F  e.... ;J1.,.f...
00E0: 3D 75 EB 16 B2 2B CC 00   DD E6 12 6E 52 0D 06 80  =u...+.....nR...
00F0: 89 43 C5 98 88 8C 00 77   00 5E A7 73 F9 DF 56 C0  .C.....w.^.s..V.
0100: E7 B5 36 48 7D D0 49 E0   32 7A 91 9A 0C 84 A1 12  ..6H..I.2z......
0110: 12 84 18 75 96 81 71 45   58 00 00 01 63 21 D7 C9  ...u..qEX...c!..
0120: F6 00 00 04 03 00 48 30   46 02 21 00 8A D6 00 02  ......H0F.!.....
0130: 79 D2 61 AA D0 47 E7 76   9F 75 C9 22 93 EB 7E F7  y.a..G.v.u."....
0140: C5 90 95 9D 9F C5 76 C4   D5 61 8D 69 02 21 00 B8  ......v..a.i.!..
0150: 31 99 A6 1F B5 60 12 62   20 1F 72 5A 91 CA DA F0  1....`.b .rZ....
0160: C9 4F 8E D8 82 2A 68 C5   7F BB 7F 9F 8B 27 CC     .O...*h......'.


#2: ObjectId: 1.3.6.1.5.5.7.1.1 Criticality=false
AuthorityInfoAccess [
  [
   accessMethod: ocsp
   accessLocation: URIName: http://ocsp.godaddy.com/
, 
   accessMethod: caIssuers
   accessLocation: URIName: http://certificates.godaddy.com/repository/gdig2.crt
]
]

#3: ObjectId: 2.5.29.35 Criticality=false
AuthorityKeyIdentifier [
KeyIdentifier [
0000: 40 C2 BD 27 8E CC 34 83   30 A2 33 D7 FB 6C B3 F0  @..'..4.0.3..l..
0010: B4 2C 80 CE                                        .,..
]
]

#4: ObjectId: 2.5.29.19 Criticality=true
BasicConstraints:[
  CA:false
  PathLen: undefined
]

#5: ObjectId: 2.5.29.31 Criticality=false
CRLDistributionPoints [
  [DistributionPoint:
     [URIName: http://crl.godaddy.com/gdig2s1-826.crl]
]]

#6: ObjectId: 2.5.29.32 Criticality=false
CertificatePolicies [
  [CertificatePolicyId: [2.16.840.1.114413.1.7.23.1]
[PolicyQualifierInfo: [
  qualifierID: 1.3.6.1.5.5.7.2.1
  qualifier: 0000: 16 2B 68 74 74 70 3A 2F   2F 63 65 72 74 69 66 69  .+http://certifi
0010: 63 61 74 65 73 2E 67 6F   64 61 64 64 79 2E 63 6F  cates.godaddy.co
0020: 6D 2F 72 65 70 6F 73 69   74 6F 72 79 2F           m/repository/

]]  ]
  [CertificatePolicyId: [2.23.140.1.2.1]
[]  ]
]

#7: ObjectId: 2.5.29.37 Criticality=false
ExtendedKeyUsages [
  serverAuth
  clientAuth
]

#8: ObjectId: 2.5.29.15 Criticality=true
KeyUsage [
  DigitalSignature
  Key_Encipherment
]

#9: ObjectId: 2.5.29.17 Criticality=false
SubjectAlternativeName [
  DNSName: *.mapr.com
  DNSName: mapr.com
]

#10: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: 4C F8 30 9D 18 1D 50 0E   0A FC DA 44 DF BA 79 D8  L.0...P....D..y.
0010: AF 74 BE 47                                        .t.G
]
]

Trust this certificate? [no]:  Y
Certificate was added to keystore

安装完成后查看证书,密钥仍然是changeit

keytool -list -keystore cacerts -alias maven

至此证书安装导入成功。

你可能感兴趣的:(Maven)