Skip to content

Commit a860977

Browse files
committed
Fixed bug introduced by commit 3c27925
1 parent 84b8e74 commit a860977

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

kse/src/org/kse/gui/dialogs/DViewCertificate.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -499,22 +499,23 @@ public void run() {
499499
private DefaultMutableTreeNode createCertificateNodes(X509Certificate[] certs) {
500500
DefaultMutableTreeNode certsNode = new DefaultMutableTreeNode();
501501

502+
Set<X509Certificate> originalSet = new TreeSet<>(new X509CertificateComparator());
503+
Collections.addAll(originalSet, certs);
502504
Set<X509Certificate> certSet = new TreeSet<>(new X509CertificateComparator());
503505
Collections.addAll(certSet, certs);
504506

505507
// first find certs with no issuer in set and add them to the tree
506508
certSet.stream()
507-
.filter(cert -> !isIssuerInSet(cert, certSet))
508-
.forEach(cert -> certsNode.add(new DefaultMutableTreeNode(cert)));
509-
certSet.removeIf(cert -> !isIssuerInSet(cert, certSet));
509+
.filter(cert -> !isIssuerInSet(cert, certSet))
510+
.forEach(cert -> certsNode.add(new DefaultMutableTreeNode(cert)));
511+
certSet.removeIf(cert -> !isIssuerInSet(cert, originalSet));
510512

511513
// then add root certs
512514
certSet.stream()
513-
.filter(X509CertUtil::isCertificateSelfSigned)
514-
.forEach(cert -> certsNode.add(new DefaultMutableTreeNode(cert)));
515+
.filter(X509CertUtil::isCertificateSelfSigned)
516+
.forEach(cert -> certsNode.add(new DefaultMutableTreeNode(cert)));
515517
certSet.removeIf(X509CertUtil::isCertificateSelfSigned);
516518

517-
518519
// then attach the other certs to their issuers
519520
while (!certSet.isEmpty()) {
520521

0 commit comments

Comments
 (0)