Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node/crypto: add X509Certificate class from node.js crypto #17851

Closed
talentlessguy opened this issue Oct 1, 2021 · 2 comments
Closed

node/crypto: add X509Certificate class from node.js crypto #17851

talentlessguy opened this issue Oct 1, 2021 · 2 comments

Comments

@talentlessguy
Copy link

talentlessguy commented Oct 1, 2021

Node.js docs reference

https://nodejs.org/api/crypto.html#crypto_class_x509certificate

Implementation interface

import { Buffer } from "../buffer.ts";
import { ERR_INVALID_ARG_TYPE } from "../_errors.ts";
import { isArrayBufferView } from "../_util/_util_types.ts";

export class X509Certificate {
  constructor(buffer: string | Buffer | DataView) {
    if (typeof buffer === "string") buffer = Buffer.from(buffer);
    if (!isArrayBufferView(buffer)) {
      throw new ERR_INVALID_ARG_TYPE("buffer", [
        "string",
        "Buffer",
        "TypedArray",
        "DataView",
      ], buffer);
    }
  }

  get subject(): string {}

  get subjectAltName() {}

  get issuer(): string {}

  get issuerCertificate() {}

  get infoAccess() {}

  get validFrom(): string {}

  get validTo(): string {}

  get fingerprint(): string {}

  get fingerprint256(): string {}

  get keyUsage() {}

  get serialNumber(): string {}

  get raw() {}

  get publicKey() {}

  toString(): string {}

  // There's no standardized JSON encoding for X509 certs so we
  // fallback to providing the PEM encoding as a string.
  toJSON() {
    return this.toString();
  }

  get ca(): boolean {}

  checkHost(name, options) {}

  checkEmail(email, options) {}

  checkIP(ip, options) {}

  checkIssued(otherCert) {}

  checkPrivateKey(pkey) {}

  verify(pkey) {}
}
@Delapouite
Copy link

Hi.

This issue seems closely related to a similar request made in denoland/std#981. So we may want to merge them in a unique thread.

Also, as Deno std lib is closely modeled from Go std lib inspiration, https://pkg.go.dev/encoding/pem may also be worth implementing as dealing with PEM is often related to handling X509 certificates.

@kt3k kt3k mentioned this issue Feb 21, 2023
14 tasks
@kt3k kt3k transferred this issue from denoland/std Feb 21, 2023
@littledivy
Copy link
Member

We're tracking all missing APIs from node:crypto in #18455. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants