rewrite: Do not eagerly resolve Maven repositories, to prevent `SSLHandshakeException` stacktrace from `maven.java.net`
I have noticed several warnings lately when updating various projects related to repositories not being available or not up to date.
As far as I can see, it’s usually dependencies coming with exotic repositories declared and it seems that OpenRewrite resolves all of them (not sure if it’s new but I noticed it only lately).
It generates big warnings in the output such as:
(This is just an example, I had another issue with some dependency in the classpath registering central.maven.org as a repository…)
[WARNING] Failed to access maven repository https://maven.java.net/content/repositories/snapshots
[WARNING] javax.net.ssl.SSLHandshakeException: PKIX path validation failed: java.security.cert.CertPathValidatorException: validity check failed
[WARNING] at sun.security.ssl.Alert.createSSLException (Alert.java:131)
[WARNING] at sun.security.ssl.TransportContext.fatal (TransportContext.java:378)
[WARNING] at sun.security.ssl.TransportContext.fatal (TransportContext.java:321)
[WARNING] at sun.security.ssl.TransportContext.fatal (TransportContext.java:316)
[WARNING] at sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts (CertificateMessage.java:654)
[WARNING] at sun.security.ssl.CertificateMessage$T12CertificateConsumer.onCertificate (CertificateMessage.java:473)
[WARNING] at sun.security.ssl.CertificateMessage$T12CertificateConsumer.consume (CertificateMessage.java:369)
[WARNING] at sun.security.ssl.SSLHandshake.consume (SSLHandshake.java:396)
[WARNING] at sun.security.ssl.HandshakeContext.dispatch (HandshakeContext.java:480)
[WARNING] at sun.security.ssl.HandshakeContext.dispatch (HandshakeContext.java:458)
[WARNING] at sun.security.ssl.TransportContext.dispatch (TransportContext.java:201)
[WARNING] at sun.security.ssl.SSLTransport.decode (SSLTransport.java:172)
[WARNING] at sun.security.ssl.SSLSocketImpl.decode (SSLSocketImpl.java:1510)
[WARNING] at sun.security.ssl.SSLSocketImpl.readHandshakeRecord (SSLSocketImpl.java:1425)
[WARNING] at sun.security.ssl.SSLSocketImpl.startHandshake (SSLSocketImpl.java:455)
[WARNING] at sun.security.ssl.SSLSocketImpl.startHandshake (SSLSocketImpl.java:426)
[WARNING] at sun.net.www.protocol.https.HttpsClient.afterConnect (HttpsClient.java:589)
[WARNING] at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect (AbstractDelegateHttpsURLConnection.java:187)
[WARNING] at sun.net.www.protocol.http.HttpURLConnection.getInputStream0 (HttpURLConnection.java:1665)
[WARNING] at sun.net.www.protocol.http.HttpURLConnection.getInputStream (HttpURLConnection.java:1589)
[WARNING] at java.net.HttpURLConnection.getResponseCode (HttpURLConnection.java:529)
[WARNING] at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode (HttpsURLConnectionImpl.java:308)
[WARNING] at org.openrewrite.ipc.http.HttpUrlConnectionSender.send (HttpUrlConnectionSender.java:97)
[WARNING] at org.openrewrite.maven.internal.MavenPomDownloader.lambda$sendRequest$1 (MavenPomDownloader.java:142)
[WARNING] at dev.failsafe.Functions.lambda$toCtxSupplier$11 (Functions.java:243)
[WARNING] at dev.failsafe.Functions.lambda$get$0 (Functions.java:46)
[WARNING] at dev.failsafe.internal.RetryPolicyExecutor.lambda$apply$0 (RetryPolicyExecutor.java:74)
[WARNING] at dev.failsafe.SyncExecutionImpl.executeSync (SyncExecutionImpl.java:187)
[WARNING] at dev.failsafe.FailsafeExecutor.call (FailsafeExecutor.java:376)
[WARNING] at dev.failsafe.FailsafeExecutor.get (FailsafeExecutor.java:112)
[WARNING] at org.openrewrite.maven.internal.MavenPomDownloader.sendRequest (MavenPomDownloader.java:141)
[WARNING] at org.openrewrite.maven.internal.MavenPomDownloader.normalizeRepository (MavenPomDownloader.java:748)
[WARNING] at org.openrewrite.maven.internal.MavenPomDownloader.distinctNormalizedRepositories (MavenPomDownloader.java:670)
[WARNING] at org.openrewrite.maven.internal.MavenPomDownloader.download (MavenPomDownloader.java:507)
[WARNING] at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentPom (ResolvedPom.java:492)
[WARNING] at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentDependenciesRecursively (ResolvedPom.java:427)
[WARNING] at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentsRecursively (ResolvedPom.java:375)
[WARNING] at org.openrewrite.maven.tree.ResolvedPom.resolveDependencies (ResolvedPom.java:838)
[WARNING] at org.openrewrite.maven.tree.ResolvedPom.resolveDependencies (ResolvedPom.java:754)
[WARNING] at org.openrewrite.maven.tree.MavenResolutionResult.resolveDependencies (MavenResolutionResult.java:174)
Given there’s nothing we can do about it as they come from external dependencies, I wonder if this should be debug logging instead? At least for repositories coming from dependencies and not from the current project.
I have seen this lately in two different projects (and two different errors) so I suspect this might be more common than we think.
Thoughts?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 11
- Comments: 62 (35 by maintainers)
Links to this issue
Commits related to this issue
- Do not log stacktrace for repositoryAccessFailed For https://github.com/openrewrite/rewrite/issues/4101 — committed to openrewrite/rewrite-maven-plugin by timtebeek 2 years ago
- Do not log stacktrace for repositoryAccessFailed (#811) For https://github.com/openrewrite/rewrite/issues/4101 — committed to openrewrite/rewrite-maven-plugin by timtebeek 2 years ago
👋 I have the same issue as well. Is there a known workaround? But is not blocking rewrite:run
Would like to draw attention to following things that were added to Maven not so long time ago:
-itrcli option, to “ignore transitive POM repositories” (as they are usually stale, non existent, or just rogue)Basically, in ideal case:
In Maven, that repo is not even touched, as can be seen:
Reason is simple:
@timtebeek I think the problem is more complex than just having a warning.
See this comment: https://github.com/openrewrite/rewrite/issues/4101#issuecomment-2039520890
I think there is a problem in how the repositories are collected and their scopes. As these servers shouldn’t even be contacted (and are not in a standard Maven run).
FWIW, from the beginning in my case I had the warning but the recipes were applied.
👋 I have the same issue as well. Is there a known workaround? This is blocking
rewrite:runto completeThere’s no such issue yet. If you find you need that please open an issue and link it here. Be sure to include the context of why that needs to be added as well. 🙏
openssl s_client -connect yourserver.com:443 -showcerts
Copy the server’s certificate (including the -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- lines) and save it to a file, e.g., server.crt //
Import the certificate into the Java trust store: Use the keytool utility to import the certificate into the Java trust store. Replace /path/to/server.crt with the path to your certificate file and /path/to/cacerts with the path to your Java trust store (usually located in the lib/security directory of your JDK installation).
keytool -import -alias yourserver -keystore /path/to/cacerts -file /path/to/server.crt You will be prompted for the trust store password, which is usually changeit by default.
This worked for me for the PKIX issue.
Since most of the original problem has been resolved, perhaps we want to close this issue and open one about supporting “-itr”.
Hi! I notice you’ve also posted the same on this thread , and received an answer there saying it’s likely specific to your setup; let’s keep the discussion on this issue specific to what was reported.
The issue with maven.java.net has been fixed. Thanks to @brianf
Thanks for chiming in here with those details @michael-o ! Good to know it’s not just us, and caused by a certificate issue that we warn about, but continue in spite of to make the required changes.
Total crap, Oracle is too stupid to configure the certificate chain sent to the client. Just hit this as well:
Similar: https://bugzilla.mozilla.org/show_bug.cgi?id=1763708
Here is the breakdown:
“DigiCert TLS RSA SHA256 2020 CA1” is an intermediate, but neither part of Mozilla NSS, nor OpenJDK cacerts. The missed to send the root certificate DN as well: https://tls-observatory.services.mozilla.com/static/certsplainer.html?id=188407168
Quoting from https://httpd.apache.org/docs/current/mod/mod_ssl.html#sslcertificatefile:
Ugly solution:
Yeah, FWIW, it’s not the only problematic artifact. Old legacy artifacts often point to a repository that doesn’t exist anymore.
In Quarkus, we are using jakarta.annotation but… we rely on the Maven artifacts here that require the
javax.annotation and thus we had to use the oldjavax.annotationartifact to avoid conflicts.But as you can see from the various reports you had, it happens quite a lot in the wild as not all the reports here are related to Quarkus.
Sorry, time is scarce on my side and I wasn’t able to provide feedback here earlier.
Here is a simple reproducer with a simple project, a simple recipe and using the OpenRewrite Maven plugin directly:
You will get this warning during the execution:
When building the project with Maven, even with an empty Maven repo, you don’t get this warning so, as I explained a bit earlier, there’s something incorrect in how the repositories are resolved.
I have been working on an update to the
updatetask of the quarkus plugin. something like this applied to a quarkus app would show the stacktrace:mvn io.quarkus:quarkus-maven-plugin:999-SNAPSHOT:update -N -DrewriteDryRun=trueand I was mistaken to think this is blocking. the process continues normally after printing the stack trace as a warning.Thanks @timtebeek Found this issue also when running recipes on some jenkins plugins
Maven 3.9.7 added the --ignore-transitive-repositories switch. You might try that as a workaround.
Thanks for chiming in with that insight; good that recipe runs are at least not affected. That brings us back to the message Guillaume started with: that it’s probably best to not show the full stacktrace if this is not affecting recipe runs in practice.
With this PR we already have some work in progress that touches upon some of the same areas
I propose we wait for the above PR to be merged and then reevaluate if we still have to change the reported stacktrace here.
You are right. The execution-breaking error I referred to comes from dependencies using the
LATESTversion.I have the same issue. It leads to a
java.lang.IllegalStateException: Illegal state while comparing versions, or at least I assume that’s the cause@delanym FWIW, that is not my personal experience. Anyway, there are more pleasant ways to convey this message.