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

Update to bouncycastle jdk18on with version 1.78.1 #785

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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,14 @@
<version>1.10</version>
</dependency>
<dependency>
<groupId>bouncycastle</groupId>
<artifactId>bcprov-jdk15</artifactId>
<version>140</version>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
<version>1.78.1</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk18on</artifactId>
<version>1.78.1</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
Expand Down Expand Up @@ -269,6 +274,10 @@
</dependencies>

<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2/</url>
</repository>
daniel-beck marked this conversation as resolved.
Show resolved Hide resolved
<repository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/io/jenkins/update_center/Signer.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package io.jenkins.update_center;

import io.jenkins.update_center.json.JsonSignature;

import io.jenkins.update_center.util.Environment;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.output.NullOutputStream;
import org.apache.commons.io.output.TeeOutputStream;
import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.openssl.PEMReader;
import org.bouncycastle.openssl.PEMParser;
import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
import org.jvnet.hudson.crypto.CertificateUtil;
import org.jvnet.hudson.crypto.SignatureOutputStream;
import org.kohsuke.args4j.Option;
Expand All @@ -23,7 +24,6 @@
import java.nio.file.Files;
import java.security.DigestOutputStream;
import java.security.GeneralSecurityException;
import java.security.KeyPair;
import java.security.MessageDigest;
import java.security.PrivateKey;
import java.security.Signature;
Expand Down Expand Up @@ -86,8 +86,9 @@ public JsonSignature sign(String json) throws GeneralSecurityException, IOExcept
X509Certificate signer = certs.get(0); // the first one is the signer, and the rest is the chain to a root CA.

PrivateKey key;
try (PEMReader pem = new PEMReader(Files.newBufferedReader(privateKey.toPath(), StandardCharsets.UTF_8))) {
key = ((KeyPair) pem.readObject()).getPrivate();
try (PEMParser pem = new PEMParser(Files.newBufferedReader(privateKey.toPath(), StandardCharsets.UTF_8))) {
PrivateKeyInfo privateKeyInfo = (PrivateKeyInfo) pem.readObject();
key = new JcaPEMKeyConverter().getPrivateKey(privateKeyInfo);
}

// the correct signature (since Jenkins 1.433); no longer generate wrong signatures for older releases.
Expand Down