forked from keycloak/keycloak
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve merge conflicts by adopting changes from main branch
- Loading branch information
Showing
43 changed files
with
2,375 additions
and
542 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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; | ||
|
@@ -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()); | ||
|
||
|
@@ -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(), | ||
|
@@ -110,7 +108,6 @@ public X509Certificate generateV3Certificate(KeyPair keyPair, PrivateKey caPriva | |
.setNotValidBefore(notBefore) | ||
.setNotValidAfter(notAfter) | ||
|
||
.setSigningKey(keyPair.getPrivate()) | ||
.setPublicKey(keyPair.getPublic()) | ||
|
||
.setSerialNumber(serialNumber) | ||
|
@@ -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( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.