diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2024-09-19 19:12:23 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-19 19:12:23 +0530 |
commit | e97f00f6f624d11ce7f37796bd65e52c473093b6 (patch) | |
tree | fa1dcc4eb1e56ebe6fca875ec72a301661718192 /ext/node/ops | |
parent | 159ac45a852c32b9b76176328900b9cdb3f1a8e0 (diff) |
fix(ext/node): support x509 certificates in `createPublicKey` (#25731)
Fixes https://github.com/denoland/deno/issues/25681
Diffstat (limited to 'ext/node/ops')
-rw-r--r-- | ext/node/ops/crypto/keys.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/ext/node/ops/crypto/keys.rs b/ext/node/ops/crypto/keys.rs index cc011dfad..867b34e04 100644 --- a/ext/node/ops/crypto/keys.rs +++ b/ext/node/ops/crypto/keys.rs @@ -752,7 +752,15 @@ impl KeyObjectHandle { | KeyObjectHandle::Secret(_) => unreachable!(), } } - // TODO: handle x509 certificates as public keys + "CERTIFICATE" => { + let (_, pem) = x509_parser::pem::parse_x509_pem(pem.as_bytes()) + .map_err(|_| type_error("invalid x509 certificate"))?; + + let cert = pem.parse_x509()?; + let public_key = cert.tbs_certificate.subject_pki; + + return KeyObjectHandle::new_x509_public_key(&public_key); + } _ => { return Err(type_error(format!("unsupported PEM label: {}", label))) } |