Skip to content

Commit

Permalink
Resolve merge conflicts by adopting changes from main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
hanpen24 committed Feb 28, 2024
2 parents ac71f0f + 941e7cc commit e4e4fd5
Show file tree
Hide file tree
Showing 43 changed files with 2,375 additions and 542 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/js-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,15 @@ jobs:
name: admin-ui-server-log-${{ matrix.container }}-${{ matrix.browser }}
path: ~/server.log

- name: Upload Cypress videos
uses: actions/upload-artifact@v3
if: github.repository != 'keycloak/keycloak-private'
with:
name: cypress-videos-${{ matrix.container }}-${{ matrix.browser }}
path: js/apps/admin-ui/cypress/videos
if-no-files-found: ignore
retention-days: 10

check:
name: Status Check - Keycloak JavaScript CI
if: always()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public X509Certificate generateV3Certificate(KeyPair keyPair, PrivateKey caPriva

// Authority Key Identifier
certGen.addExtension(Extension.authorityKeyIdentifier, false,
x509ExtensionUtils.createAuthorityKeyIdentifier(subjPubKeyInfo));
x509ExtensionUtils.createAuthorityKeyIdentifier(caCert));

// Key Usage
certGen.addExtension(Extension.keyUsage, false, new KeyUsage(KeyUsage.digitalSignature | KeyUsage.keyCertSign
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
Expand All @@ -41,6 +40,7 @@
import org.keycloak.common.crypto.CertificateUtilsProvider;
import org.wildfly.security.asn1.ASN1;
import org.wildfly.security.asn1.DERDecoder;
import org.wildfly.security.x500.GeneralName;
import org.wildfly.security.x500.X500;
import org.wildfly.security.x500.cert.AuthorityKeyIdentifierExtension;
import org.wildfly.security.x500.cert.BasicConstraintsExtension;
Expand All @@ -52,14 +52,15 @@
import org.wildfly.security.x500.cert.SubjectKeyIdentifierExtension;
import org.wildfly.security.x500.cert.X509CertificateBuilder;
import org.wildfly.security.x500.cert.X509CertificateExtension;
import org.wildfly.security.x500.cert.util.KeyUtil;

/**
* The Class CertificateUtils provides utility functions for generation
* and usage of X.509 certificates
*
* @author <a href="mailto:[email protected]">David Anderson</a>
*/
public class ElytronCertificateUtils implements CertificateUtilsProvider {
public class ElytronCertificateUtilsProvider implements CertificateUtilsProvider {

Logger log = Logger.getLogger(getClass());

Expand All @@ -82,10 +83,7 @@ public X509Certificate generateV3Certificate(KeyPair keyPair, PrivateKey caPriva
try {

X500Principal subjectdn = subjectToX500Principle(subject);
X500Principal issuerdn = subjectdn;
if (caCert != null) {
issuerdn = caCert.getSubjectX500Principal();
}
X500Principal issuerdn = caCert.getSubjectX500Principal();

// Validity
ZonedDateTime notBefore = ZonedDateTime.ofInstant(new Date(System.currentTimeMillis()).toInstant(),
Expand All @@ -110,7 +108,6 @@ public X509Certificate generateV3Certificate(KeyPair keyPair, PrivateKey caPriva
.setNotValidBefore(notBefore)
.setNotValidAfter(notAfter)

.setSigningKey(keyPair.getPrivate())
.setPublicKey(keyPair.getPublic())

.setSerialNumber(serialNumber)
Expand All @@ -120,10 +117,14 @@ public X509Certificate generateV3Certificate(KeyPair keyPair, PrivateKey caPriva
.setSigningKey(caPrivateKey)

// Subject Key Identifier Extension
.addExtension(new SubjectKeyIdentifierExtension(keyPair.getPublic().getEncoded()))
.addExtension(new SubjectKeyIdentifierExtension(KeyUtil.getKeyIdentifier(keyPair.getPublic())))

// Authority Key Identifier
.addExtension(new AuthorityKeyIdentifierExtension(keyPair.getPublic().getEncoded(), null, null))
.addExtension(new AuthorityKeyIdentifierExtension(
KeyUtil.getKeyIdentifier(caCert.getPublicKey()),
Collections.singletonList(new GeneralName.DirectoryName(caCert.getIssuerX500Principal().getName())),
caCert.getSerialNumber()
))

// Key Usage
.addExtension(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import java.security.spec.ECParameterSpec;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Supplier;

import javax.crypto.Cipher;
import javax.crypto.NoSuchPaddingException;
Expand Down Expand Up @@ -77,7 +76,7 @@ public <T> T getAlgorithmProvider(Class<T> clazz, String algorithm) {

@Override
public CertificateUtilsProvider getCertificateUtils() {
return new ElytronCertificateUtils();
return new ElytronCertificateUtilsProvider();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;

import javax.security.auth.x500.X500Principal;

import org.junit.Test;
import org.keycloak.common.util.PemUtils;
import org.keycloak.crypto.elytron.ElytronCertificateUtils;
import org.keycloak.crypto.elytron.ElytronCertificateUtilsProvider;
import org.wildfly.security.x500.GeneralName;
import org.wildfly.security.x500.cert.CRLDistributionPoint;
import org.wildfly.security.x500.cert.CRLDistributionPoint.DistributionPointName;
Expand All @@ -55,7 +53,7 @@ public void getCrlDistPoint() throws CertificateException, NoSuchAlgorithmExcept
expect.add("http://crl0.test0.com");


ElytronCertificateUtils bcutil = new ElytronCertificateUtils();
ElytronCertificateUtilsProvider bcutil = new ElytronCertificateUtilsProvider();
List<String> crldp = bcutil.getCRLDistributionPoints(cert);

assertArrayEquals(expect.toArray(), crldp.toArray());
Expand All @@ -70,7 +68,7 @@ public void getCrlDistPointMultiNames() throws CertificateException, NoSuchAlgor
expect.add("http://crl0.test0.com");
expect.add("http://crl0.test1.com");

ElytronCertificateUtils bcutil = new ElytronCertificateUtils();
ElytronCertificateUtilsProvider bcutil = new ElytronCertificateUtilsProvider();
List<String> crldp = bcutil.getCRLDistributionPoints(cert);

assertArrayEquals(expect.toArray(), crldp.toArray());
Expand All @@ -87,7 +85,7 @@ public void getMultiCrlDistPointMultiNames() throws CertificateException, NoSuch
expect.add("http://crl1.test0.com");
expect.add("http://crl1.test1.com");

ElytronCertificateUtils bcutil = new ElytronCertificateUtils();
ElytronCertificateUtilsProvider bcutil = new ElytronCertificateUtilsProvider();
List<String> crldp = bcutil.getCRLDistributionPoints(cert);

assertArrayEquals(expect.toArray(), crldp.toArray());
Expand All @@ -101,7 +99,7 @@ public void revokedCertCRLDistTest() throws CertificateException, IOException {
expect.add("http://localhost:8889/empty.crl");
expect.add("http://localhost:8889/intermediate-ca.crl");

ElytronCertificateUtils bcutil = new ElytronCertificateUtils();
ElytronCertificateUtilsProvider bcutil = new ElytronCertificateUtilsProvider();
List<String> crldp = bcutil.getCRLDistributionPoints(cert);

assertArrayEquals(expect.toArray(), crldp.toArray());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public X509Certificate generateV3Certificate(KeyPair keyPair, PrivateKey caPriva

// Authority Key Identifier
certGen.addExtension(Extension.authorityKeyIdentifier, false,
x509ExtensionUtils.createAuthorityKeyIdentifier(subjPubKeyInfo));
x509ExtensionUtils.createAuthorityKeyIdentifier(caCert));

// Key Usage
certGen.addExtension(Extension.keyUsage, false, new KeyUsage(KeyUsage.digitalSignature | KeyUsage.keyCertSign
Expand Down
Loading

0 comments on commit e4e4fd5

Please sign in to comment.