{"id":50915958,"url":"https://github.com/lepresk/pki-infrastructure","last_synced_at":"2026-06-16T15:01:30.143Z","repository":{"id":340946720,"uuid":"1168299507","full_name":"lepresk/pki-infrastructure","owner":"lepresk","description":"Three-tier PKI in Node.js — Root CA, Intermediate CA, signing certificates, chain verification, and document signing","archived":false,"fork":false,"pushed_at":"2026-02-27T08:26:13.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-02-27T14:06:36.649Z","etag":null,"topics":["certificate-authority","cryptography","nodejs","pki","typescript","x509"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lepresk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-27T08:23:20.000Z","updated_at":"2026-02-27T08:37:22.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/lepresk/pki-infrastructure","commit_stats":null,"previous_names":["lepresk/pki-infrastructure"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/lepresk/pki-infrastructure","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lepresk%2Fpki-infrastructure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lepresk%2Fpki-infrastructure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lepresk%2Fpki-infrastructure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lepresk%2Fpki-infrastructure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lepresk","download_url":"https://codeload.github.com/lepresk/pki-infrastructure/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lepresk%2Fpki-infrastructure/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34410784,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-16T02:00:06.860Z","response_time":126,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["certificate-authority","cryptography","nodejs","pki","typescript","x509"],"created_at":"2026-06-16T15:01:28.897Z","updated_at":"2026-06-16T15:01:30.134Z","avatar_url":"https://github.com/lepresk.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pki-infrastructure\n\n![Build a Complete PKI from Scratch in Node.js](https://lepresk.com/storage/posts/featured-images/01KHNYFVHQ74AK5HPTT59EK614.webp)\n\nNode.js implementation of a three-tier Public Key Infrastructure — Root CA, Intermediate CA, and leaf signing certificates — using `node-forge` and the built-in `crypto` module.\n\nThis is the companion code for the article: [Build a Complete PKI from Scratch in Node.js](https://lepresk.com/blog/build-a-complete-pki-from-scratch-in-nodejs)\n\nRepository: [github.com/lepresk/pki-infrastructure](https://github.com/lepresk/pki-infrastructure)\n\n## Requirements\n\n- Node.js 20 or later\n- pnpm\n\n## Getting started\n\n```bash\ngit clone https://github.com/lepresk/pki-infrastructure.git\ncd pki-infrastructure\npnpm install\npnpm dev\n```\n\n## What it does\n\nRunning the demo generates a full certificate chain and exercises signing and verification:\n\n1. Creates a self-signed Root CA (4096-bit RSA, 10-year validity)\n2. Issues an Intermediate CA signed by the Root CA (2048-bit, 5-year validity)\n3. Issues a leaf signing certificate signed by the Intermediate CA (2048-bit, 2-year validity)\n4. Verifies the certificate chain\n5. Signs a document and verifies the signature against the original and a tampered version\n\nCertificates are written to `pki/` as PEM files. That directory is excluded from git — never commit private keys.\n\n## Project structure\n\n```\nsrc/\n  types.ts     — shared interfaces\n  crypto.ts    — key decryption, sign, verify\n  pki.ts       — CA and certificate generation, chain verification\n  storage.ts   — read/write PEM files\n  index.ts     — end-to-end demo\n```\n\n## A note on AES-256 key decryption\n\n`node-forge` silently returns `null` when decrypting AES-256 encrypted private keys in some Node.js versions. The workaround in `src/crypto.ts` uses the built-in `crypto` module to decrypt the key and re-exports it as unencrypted PKCS#1 before handing it back to forge. See the article for a full explanation.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flepresk%2Fpki-infrastructure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flepresk%2Fpki-infrastructure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flepresk%2Fpki-infrastructure/lists"}