From 7bb7677604a6efaba550573b8daad77b1c6908b6 Mon Sep 17 00:00:00 2001
From: zzz <zzz@mail.i2p>
Date: Wed, 27 Mar 2019 12:26:05 +0000
Subject: [PATCH] SelfSignedGenerator: improve previous fix

---
 core/java/src/net/i2p/crypto/SelfSignedGenerator.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/core/java/src/net/i2p/crypto/SelfSignedGenerator.java b/core/java/src/net/i2p/crypto/SelfSignedGenerator.java
index 9af4be49c2..e45bd9be86 100644
--- a/core/java/src/net/i2p/crypto/SelfSignedGenerator.java
+++ b/core/java/src/net/i2p/crypto/SelfSignedGenerator.java
@@ -249,7 +249,8 @@ public final class SelfSignedGenerator {
         cert.verify(cpub);
         if (!cpub.equals(jpub)) {
             boolean ok = false;
-            if (cpub.getClass().getName().equals("sun.security.x509.X509Key")) {
+            if ((jpub instanceof EdDSAPublicKey) &&
+                cpub.getClass().getName().equals("sun.security.x509.X509Key")) {
                 // X509Certificate will sometimes contain an X509Key rather than the EdDSAPublicKey itself; the contained
                 // key is valid but needs to be instanced as an EdDSAPublicKey before it can be used.
                 try {
-- 
GitLab