Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugging the cause of random PGP failures #3382

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -16,6 +16,7 @@

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
Expand Down Expand Up @@ -231,11 +232,13 @@ public void execute() throws MojoExecutionException, MojoFailureException {

private void handle(IArtifactDescriptor artifactDescriptor, File artifact, ProxySignerWithPublicKeyAccess signer,
KeyStore allKeys) {
Log log = getLog();
if (artifact != null) {
var existingKeys = artifactDescriptor.getProperty(PGPSignatureVerifier.PGP_SIGNER_KEYS_PROPERTY_NAME);
var existingSignatures = artifactDescriptor.getProperty(PGPSignatureVerifier.PGP_SIGNATURES_PROPERTY_NAME);

if (existingSignatures != null && pgpKeyBehavior == PGPKeyBehavior.skip) {
log.debug(artifact + " is already pgp signed and these should be skipped!");
return;
}

Expand All @@ -245,6 +248,7 @@ private void handle(IArtifactDescriptor artifactDescriptor, File artifact, Proxy
var classifier = artifactKey.getClassifier();
var isBinary = "binary".equals(classifier);
if (skipBinaries && isBinary) {
log.debug(artifact + " is a binary and these should be skipped!");
return;
}

Expand All @@ -253,18 +257,22 @@ private void handle(IArtifactDescriptor artifactDescriptor, File artifact, Proxy
var signedContent = signedContentFactory.getSignedContent(artifact);
if (signedContent.isSigned()) {
if (skipIfJarsigned) {
log.debug(artifact + " is already signed and signed jars should be skipped!");
return;
}
if (skipIfJarsignedAndAnchored) {
for (var signerInfo : signedContent.getSignerInfos()) {
if (signerInfo.getTrustAnchor() != null) {
log.debug(artifact
+ " is already signed and signed jars should be skipped if anchored!");
return;
}
}
}
}
} catch (Exception e) {
//$FALL-THROUGH$ Treat as unsigned.
log.error("Can't check signature " + artifact + " :: " + e, e);
}
}
}
Expand Down Expand Up @@ -294,6 +302,8 @@ private void handle(IArtifactDescriptor artifactDescriptor, File artifact, Proxy
} catch (MojoExecutionException | IOException e) {
throw new RuntimeException(e.getMessage(), e);
}
} else {
log.error("No artifact file for " + artifactDescriptor);
}
}
}