Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
108 views
in Technique[技术] by (71.8m points)

java - Eclipse 2020.12 Now includes a JVM. How do you add a corporate certificate to it?

Eclipse 2020.12 now includes Oracle JDK 14 with the installation. This breaks Maven integration if your corporation has a CA (which most large places do).

How does one add a corporate certificate to the Eclipse JDK? I tried the following:

find /Applications/Eclipse.app -iname cacerts -exec keytool -importcert -alias emoneyusa-ecdsa -keystore {} -storepass changeit -file ~/Documents/certs/corp-ca.crt -trustcacerts -noprompt ;

However, I still get this problem when attempting to perform Maven functions inside Eclipse:

org.eclipse.core.runtime.CoreException: Could not resolve artifact xalan:xalan:jar:sources:2.7.2
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.lambda$4(MavenImpl.java:804)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:179)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:114)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:101)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.resolve(MavenImpl.java:772)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.resolve(MavenImpl.java:749)
    at org.eclipse.m2e.jdt.internal.DownloadSourcesJob.download(DownloadSourcesJob.java:330)
    at org.eclipse.m2e.jdt.internal.DownloadSourcesJob.downloadAttachments(DownloadSourcesJob.java:304)
    at org.eclipse.m2e.jdt.internal.DownloadSourcesJob.downloadMaven(DownloadSourcesJob.java:269)
    at org.eclipse.m2e.jdt.internal.DownloadSourcesJob.downloadFilesAndPopulateToUpdate(DownloadSourcesJob.java:233)
    at org.eclipse.m2e.jdt.internal.DownloadSourcesJob.lambda$0(DownloadSourcesJob.java:161)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:179)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:153)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:101)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1374)
    at org.eclipse.m2e.jdt.internal.DownloadSourcesJob.run(DownloadSourcesJob.java:161)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Contains: Failure to transfer xalan:xalan:jar:sources:2.7.2 from https://nexus.xxx.com/repository/xxx-all was cached in the local repository, resolution will not be reattempted until the update interval of xxx-all has elapsed or updates are forced. Original error: Could not transfer artifact xalan:xalan:jar:sources:2.7.2 from/to xxx-all (https://nexus.xxx.com/repository/xxx-all): PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
org.eclipse.aether.transfer.ArtifactTransferException: Failure to transfer xalan:xalan:jar:sources:2.7.2 from https://nexus.xxx.com/repository/xxx-all was cached in the local repository, resolution will not be reattempted until the update interval of xxx-all has elapsed or updates are forced. Original error: Could not transfer artifact xalan:xalan:jar:sources:2.7.2 from/to xxx-all (https://nexus.xxx.com/repository/xxx-all): PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.newException(DefaultUpdateCheckManager.java:225)
    at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.checkArtifact(DefaultUpdateCheckManager.java:193)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.gatherDownloads(DefaultArtifactResolver.java:559)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:483)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:401)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:229)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:207)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:262)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.lambda$4(MavenImpl.java:781)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:179)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:114)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:101)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.resolve(MavenImpl.java:772)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.resolve(MavenImpl.java:749)
    at org.eclipse.m2e.jdt.internal.DownloadSourcesJob.download(DownloadSourcesJob.java:330)
    at org.eclipse.m2e.jdt.internal.DownloadSourcesJob.downloadAttachments(DownloadSourcesJob.java:304)
    at org.eclipse.m2e.jdt.internal.DownloadSourcesJob.downloadMaven(DownloadSourcesJob.java:269)
    at org.eclipse.m2e.jdt.internal.DownloadSourcesJob.downloadFilesAndPopulateToUpdate(DownloadSourcesJob.java:233)
    at org.eclipse.m2e.jdt.internal.DownloadSourcesJob.lambda$0(DownloadSourcesJob.java:161)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:179)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:153)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:101)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1374)
    at org.eclipse.m2e.jdt.internal.DownloadSourcesJob.run(DownloadSourcesJob.java:161)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

What clued me in was Eclipse reports this JDK, which is funny because I only have AdoptOpenJDK11 installed:

eclipse.buildId=4.17.0.I20200902-1800
java.version=14.0.2
java.vendor=Oracle Corporation
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.jee.product -keyring /Users/xxx/.eclipse_keyring
Command-line arguments:  -os macosx -ws cocoa -arch x86_64 -product org.eclipse.epp.package.jee.product -keyring /Users/xxx/.eclipse_keyring
question from:https://stackoverflow.com/questions/65599113/eclipse-2020-12-now-includes-a-jvm-how-do-you-add-a-corporate-certificate-to-it

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Some time back I had the same problem and I struggled a lot and tried almost everything. The actual problem is and rally strange is, 1. First of all your valid cert should have been installed in your JRE/JDK. 2. Even if you have installed cert in your jdk which you are using, sometime it still doesn't work because if there are multiple jre installed on your machine, eclipse randomly pick one of the jre aand try to connect with your org's Nexus. And now here is the problem. If eclipse would pick up a jre which does not have the cert, it will fail to connect with repo. The solution is 1. Install certs in all your jres on your machine. 2. Delete other jres ecept one whihc you are using and having valid cert. In my team, many team members had this problems, and we had solved with the solutions what I suggested. Try this and let me know if still there is any problem.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...