diff --git a/core/java/src/net/i2p/crypto/SelfSignedGenerator.java b/core/java/src/net/i2p/crypto/SelfSignedGenerator.java
index 9af4be49c299b85f90ddd574bc78c6d07e212d67..e45bd9be8686f9677c5a9bb5d9c281722e6a7cda 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 {