Repository: deno
Issue: X509Certificate.prototype.publicKey fails for Ed25519 keys eventho KeyObject supports them
Labels: bug,node compat,crypto

Version: Deno 2.1.2

In the provided script the X.509 structure's SPKI includes the very same SPKI. The SPKI itself can be passed to `createPublicKey` but cannot be obtained through X509Certificate.

This is unexpected.

The very fact that `process.getBuiltinModule` is used to **again** ship incomplete `node:crypto` implementations is to Deno user's own detriment since it is used by modules to dynamically target Node.js APIs for their performance and ease of use when a pure JS fallback would be used otherwise.

```js
const spki =
  '-----BEGIN PUBLIC KEY-----\n' +
  'MCowBQYDK2VwAyEAlBZ9GShvbQEtyyaGs+0Nd4aurH7ERq6UOIvXGb5/tXA=\n' +
  '-----END PUBLIC KEY-----\n'

const x509 =
  '-----BEGIN CERTIFICATE-----\n' +
  'MIIBoTCCAVOgAwIBAgIUde5G4y+mtbb0eRISc7vnINRbSXkwBQYDK2VwMEUxCzAJ\n' +
  'BgNVBAYTAkNaMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5l\n' +
  'dCBXaWRnaXRzIFB0eSBMdGQwIBcNMjIxMDExMTIyMTUzWhgPMjEyMjA5MTcxMjIx\n' +
  'NTNaMEUxCzAJBgNVBAYTAkNaMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQK\n' +
  'DBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwKjAFBgMrZXADIQCUFn0ZKG9tAS3L\n' +
  'Joaz7Q13hq6sfsRGrpQ4i9cZvn+1cKNTMFEwHQYDVR0OBBYEFAATzoAtBcYTcOdY\n' +
  'jkcQqsWXipnSMB8GA1UdIwQYMBaAFAATzoAtBcYTcOdYjkcQqsWXipnSMA8GA1Ud\n' +
  'EwEB/wQFMAMBAf8wBQYDK2VwA0EApfw+9jSO0x0IorDfdr5ZVGRBVgrfrd9XhxqQ\n' +
  'Krphj6cA4Ls9aMYAHf5w+OW9D/t3a9p6mYm78AKIdBsPEtT1AQ==\n' +
  '-----END CERTIFICATE-----\n'

const crypto = globalThis.process.getBuiltinModule('node:crypto')

const publicKeyObject = crypto.createPublicKey(spki)
const x509Object = new crypto.X509Certificate(x509)

console.log('got publicKeyObject\n', publicKeyObject)
console.log('got x509Object\n', x509Object)

try {
  console.log('got x509Object.publicKey', x509Object.publicKey)

  // Not implemented in deno, but it never gets here anyway
  console.log(
    'x509Object.publicKey.equals(publicKeyObject)',
    x509Object.publicKey.equals(publicKeyObject),
  )
} catch (err) {
  console.log('x509Object.publicKey error', err)
}
```

Node.js console out
```
got publicKeyObject
 PublicKeyObject [KeyObject] { [Symbol(kKeyType)]: 'public' }
got x509Object
 X509Certificate {
  subject: 'C=CZ\nST=Some-State\nO=Internet Widgits Pty Ltd',
  subjectAltName: undefined,
  issuer: 'C=CZ\nST=Some-State\nO=Internet Widgits Pty Ltd',
  infoAccess: undefined,
  validFrom: 'Oct 11 12:21:53 2022 GMT',
  validTo: 'Sep 17 12:21:53 2122 GMT',
  validFromDate: 2022-10-11T12:21:53.000Z,
  validToDate: 2122-09-17T12:21:53.000Z,
  fingerprint: 'FC:35:B7:FC:EE:99:AA:A3:32:4B:EA:93:DB:4F:E5:FB:1B:26:57:41',
  fingerprint256: '1D:96:32:84:05:BA:54:8C:04:2C:64:8E:9B:46:7A:36:E8:90:10:87:5B:D5:BE:9B:9E:DE:37:C9:26:87:30:59',
  fingerprint512: 'BE:F8:CE:6E:EC:C9:B7:DA:69:FD:B5:DE:89:48:E2:41:AB:6F:A7:71:AD:E5:9E:7F:BB:D2:8A:BF:13:41:7D:80:5B:DA:0E:DE:CF:F8:53:0E:4F:A9:C7:78:AC:1F:04:68:41:9A:9E:69:DC:EC:3F:9D:09:F9:7E:BE:3E:48:AF:A5',
  keyUsage: undefined,
  serialNumber: '75EE46E32FA6B5B6F479121273BBE720D45B4979'
}
got x509Object.publicKey PublicKeyObject [KeyObject] { [Symbol(kKeyType)]: 'public' }
x509Object.publicKey.equals(publicKeyObject) true
```

Deno console out
```
got publicKeyObject
 PublicKeyObject [KeyObject] {
  [Symbol(kKeyType)]: "public",
  [Symbol(kHandle)]: {}
}
got x509Object
 X509Certificate {}
x509Object.publicKey error Error: unsupported x509 public key type
    at X509Certificate.get publicKey (ext:deno_node/internal/crypto/x509.ts:84:20)
    at file:///Users/panva/repo/jose/some.mjs:28:54
```