Skip to content

Commit

Permalink
FISH-1323 Zulu JDK Update (payara#5215)
Browse files Browse the repository at this point in the history
* FISH-1323 Upgraded dependency on Zulu JDK to 8u292 and 11.0.9

* FISH-1323 Fixed PrintCertificateCommandTest

- compatibility issue, RSA vs. PKCS12
  • Loading branch information
David Matějček authored Apr 28, 2021
1 parent e15cd82 commit c109277
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
4 changes: 2 additions & 2 deletions appserver/extras/docker-images/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<docker.noCache>true</docker.noCache>

<docker.java.repository>azul/zulu-openjdk</docker.java.repository>
<docker.jdk8.tag>8u262</docker.jdk8.tag>
<docker.jdk11.tag>11.0.7</docker.jdk11.tag>
<docker.jdk8.tag>8u292</docker.jdk8.tag>
<docker.jdk11.tag>11.0.9</docker.jdk11.tag>

<docker.payara.domainName>domain1</docker.payara.domainName>
<docker.payara.rootDirectoryName>payara5</docker.payara.rootDirectoryName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import java.security.KeyPairGenerator;
import java.security.KeyStore;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.PrivateKey;
import java.security.Security;
import java.security.cert.Certificate;
Expand Down Expand Up @@ -99,10 +100,15 @@
@RunWith(Parameterized.class)
public class PrintCertificateCommandTest {

private static final String ALIAS = "test";
private static final BouncyCastleProvider PROVIDER = new BouncyCastleProvider();

private static final String ALIAS = "test";
private static final String KEYSTORE_PASSWORD = "changeit";

private static final String KS_TYPE_JKS = "JKS";
private static final String KS_TYPE_JCEKS = "JCEKS";
private static final String KS_TYPE_PKCS12 = "PKCS12";

private static final File FILE_JKS = new File("target/pcct.jks");
private static final File FILE_PKCS12 = new File("target/pcct.p12");
private static final File FILE_JCEKS = new File("target/pcct.jceks");
Expand All @@ -128,9 +134,9 @@ public static void initEnvironment() throws Exception {
final KeyPair keyPair = createKeyPair();
final X509Certificate certificate = createSelfSignedCertificate(keyPair);

saveKeyStore(keyPair.getPrivate(), certificate, FILE_PKCS12, "PKCS12");
saveKeyStore(keyPair.getPrivate(), certificate, FILE_JKS, "JKS");
saveKeyStore(keyPair.getPrivate(), certificate, FILE_JCEKS, "JCEKS");
saveKeyStore(keyPair.getPrivate(), certificate, FILE_PKCS12, KS_TYPE_PKCS12);
saveKeyStore(keyPair.getPrivate(), certificate, FILE_JKS, KS_TYPE_JKS);
saveKeyStore(keyPair.getPrivate(), certificate, FILE_JCEKS, KS_TYPE_JCEKS);
saveDer(certificate);
savePem(certificate);
}
Expand Down Expand Up @@ -221,7 +227,12 @@ public void testBCProvider() throws Exception {
private static void saveKeyStore(final PrivateKey key, final X509Certificate certificate, //
final File keystoreFile, final String keystoreType) throws Exception {

final KeyStore keystore = KeyStore.getInstance(keystoreType);
final KeyStore keystore;
if (KS_TYPE_PKCS12.equals(keystoreType)) {
keystore = KeyStore.getInstance(keystoreType, PROVIDER);
} else {
keystore = KeyStore.getInstance(keystoreType);
}
keystore.load(null, null);
keystore.setKeyEntry(ALIAS, key, "changeit".toCharArray(), new Certificate[] {certificate});
try (final OutputStream os = new FileOutputStream(keystoreFile)) {
Expand All @@ -246,8 +257,8 @@ private static void savePem(final X509Certificate certificate) throws IOExceptio
}


private static KeyPair createKeyPair() throws NoSuchAlgorithmException {
final KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
private static KeyPair createKeyPair() throws NoSuchAlgorithmException, NoSuchProviderException {
final KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", PROVIDER);
kpg.initialize(2048);
return kpg.generateKeyPair();
}
Expand Down

0 comments on commit c109277

Please sign in to comment.