Issue #1673 - bring in bouncycastle jars with the .mod file

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2021-01-07 15:05:42 +11:00
parent c2b9d92a2f
commit a99f8196bc
3 changed files with 16 additions and 8 deletions

View File

@ -7,23 +7,24 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-test-keystore</artifactId>
<packaging>jar</packaging>
<name>Jetty :: Test Keystore</name>
<description>Test keystore with self-signed SSL Certificate.</description>
<properties>
<bouncycastle-version>1.60</bouncycastle-version>
<bouncycastle.version>1.62</bouncycastle.version>
</properties>
<dependencies>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>${bouncycastle-version}</version>
<version>${bouncycastle.version}</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>${bouncycastle-version}</version>
<version>${bouncycastle.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>

View File

@ -9,13 +9,20 @@ ssl
[depend]
ssl
[files]
maven://org.bouncycastle/bcpkix-jdk15on/${bouncycastle.version}|lib/bouncycastle/bcpkix-jdk15on-${bouncycastle.version}.jar
maven://org.bouncycastle/bcprov-jdk15on/${bouncycastle.version}|lib/bouncycastle/bcprov-jdk15on-${bouncycastle.version}.jar
[lib]
lib/jetty-test-keystore-${jetty.version}.jar
lib/bouncycastle/bcpkix-jdk15on-${bouncycastle.version}.jar
lib/bouncycastle/bcprov-jdk15on-${bouncycastle.version}.jar
[xml]
etc/jetty-test-keystore.xml
[ini]
bouncycastle.version?=1.62
jetty.sslContext.keyStorePath?=etc/test-keystore.p12
jetty.sslContext.keyStoreType?=PKCS12
jetty.sslContext.keyStorePassword?=OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4

View File

@ -43,7 +43,7 @@ public class KeystoreGenerator
generateTestKeystore("test-keystore.p12", "storepwd");
}
public static void generateTestKeystore(String location, String password) throws Exception
public static File generateTestKeystore(String location, String password) throws Exception
{
// Generate an RSA key pair.
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
@ -51,9 +51,9 @@ public class KeystoreGenerator
KeyPair keyPair = keyPairGenerator.generateKeyPair();
// Create a self-signed certificate.
Instant now = Instant.now();
Date notBefore = Date.from(now);
Date notAfter = Date.from(now.plus(Duration.ofDays(365)));
Instant start = Instant.now().minus(Duration.ofDays(1));
Date notBefore = Date.from(start);
Date notAfter = Date.from(start.plus(Duration.ofDays(365)));
BigInteger serial = BigInteger.valueOf(new SecureRandom().nextLong());
X500Name x500Name = new X500Name("C=US,ST=NE,L=Omaha,O=Webtide,OU=Jetty,CN=localhost");
X509v3CertificateBuilder certBuilder = new JcaX509v3CertificateBuilder(x500Name, serial, notBefore, notAfter, x500Name, keyPair.getPublic());
@ -76,6 +76,6 @@ public class KeystoreGenerator
{
keystore.store(fos, pwdCharArray);
}
return keystoreFile;
}
}