npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

private-ca

v1.0.0

Published

Private CA Certificate Issuance System - Lightweight PKI for internal networks

Readme

Private CA - 私有 CA 证书签发系统

一个轻量级的私有 CA(Certificate Authority)证书签发系统,用于内网环境下的 SSL/TLS 证书管理。支持完整的 CA 层级(根 CA / 中间 CA / 服务器证书),提供 Web 管理界面。

特性

  • 完整的 CA 层级:根 CA → 中间 CA → 服务器证书
  • Web 管理界面,无需命令行操作
  • 首次访问自动引导初始化 CA
  • 支持证书签发、吊销、查看、下载
  • 下载完整证书链(fullchain)和 cert+key 捆绑包
  • SHA-256 指纹、剩余天数自动计算
  • 审计日志
  • 无外部数据库,文件存储
  • 零认证(适用于内网隔离环境)

技术栈

  • Node.js 14+
  • Express
  • node-forge(X.509 证书生成)
  • 纯静态前端(无构建工具)

安装

npm install

启动

npm start

默认监听 127.0.0.1:8443,可通过环境变量配置:

HOST=0.0.0.0 PORT=8443 npm start

环境变量:

  • HOST - 监听地址(默认 127.0.0.1
  • PORT - 监听端口(默认 8443
  • DATA_DIR - 数据目录(默认 ./data

首次使用

  1. 启动服务后浏览器访问 http://localhost:8443
  2. 系统检测到未初始化 CA,自动跳转初始化页面
  3. 填写 CA 信息(组织、城市、有效期等)并提交
  4. 系统生成自签名根 CA,跳转到主页面

Web 界面

标签页

  • 根 CA - 查看根 CA 列表
  • 中间 CA - 查看中间 CA 列表,创建中间 CA
  • 证书 - 查看服务器证书列表,签发新证书
  • 吊销列表 - 查看已吊销的证书

证书操作

  • 查看详情(Subject、Issuer、SAN、指纹等)
  • 下载公钥 / 私钥 / 证书 PEM / 完整证书链 / cert+key 捆绑包
  • 吊销证书

签发证书

请求字段:

  • commonName - 通用名(必填)
  • sans - 主题备用名称数组(可选)
  • validityDays - 有效期天数(默认 825)
  • keySize - 密钥长度 2048/4096(默认 2048)
  • issuerSerial - 签发 CA 的序列号(根 CA 或中间 CA)

API 文档

初始化

GET  /init            初始化表单页面
POST /init            生成根 CA

证书管理

POST /api/issue               签发服务器证书
POST /api/intermediate        创建中间 CA
POST /api/revoke              吊销证书
GET  /api/certs?type=...      列表查询(root/intermediate/server/all)
GET  /api/cert/:serial        证书详情

下载

GET /api/ca.crt                                根 CA 证书
GET /api/crl.pem                               CRL 吊销列表
GET /api/download/:serial/cert                 证书 PEM
GET /api/download/:serial/pubkey               公钥 PEM
GET /api/download/:serial/privkey              私钥 PEM
GET /api/download/:serial/fullchain            完整证书链
GET /api/download/:serial/bundle               cert + key 捆绑包

签发请求示例

curl -X POST http://localhost:8443/api/issue \
  -H "Content-Type: application/json" \
  -d '{
    "commonName": "app.example.internal",
    "sans": ["app.example.internal", "10.0.0.5"],
    "validityDays": 825,
    "keySize": 2048,
    "issuerSerial": "根CA或中间CA的序列号"
  }'

创建中间 CA 示例

curl -X POST http://localhost:8443/api/intermediate \
  -H "Content-Type: application/json" \
  -d '{
    "commonName": "My Intermediate CA",
    "organization": "My Org",
    "validityDays": 1825,
    "keySize": 4096
  }'

数据存储

数据存储在 data/ 目录:

data/
├── ca.key / ca.crt            根 CA
├── intermediates/
│   └── <cn>/
│       ├── ca.key / ca.crt    中间 CA
│       └── certs/             由该中间 CA 签发的证书
├── certs/                     根 CA 直接签发的证书
├── crl.json                   吊销列表
└── audit.log                  审计日志

每个证书条目包含:

  • cert.pem - 证书 PEM
  • key.pem - 私钥 PEM(权限 0600)
  • meta.json - 元信息(序列号、时间、SAN 等)

安全建议

由于系统无认证机制,部署时请务必:

  1. 仅监听内网地址 - 设置 HOST=127.0.0.1 或内网 IP
  2. 上游网关保护 - 使用 Nginx/Envoy 做 IP 白名单或 mTLS
  3. 文件系统权限 - 确保 data/ 目录权限为 0700,私钥文件为 0600
  4. 定期备份 - 备份 data/ 目录(尤其是 CA 私钥)
  5. 审计日志 - 定期检查 data/audit.log
  6. 私钥保护 - 私钥下载需二次确认,仅在受信环境下操作

证书链说明

下载完整证书链(fullchain)时的顺序:

-----BEGIN CERTIFICATE-----
服务器证书
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
中间 CA 证书(如果有)
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
根 CA 证书
-----END CERTIFICATE-----

客户端只需信任根 CA,即可验证完整链。

浏览器信任

将根 CA 证书导入到客户端信任库:

  • Linux - 复制到 /usr/local/share/ca-certificates/ 并运行 update-ca-certificates
  • macOS - 打开钥匙串访问,导入并设置为「始终信任」
  • Windows - 双击证书 → 安装证书 → 受信任的根证书颁发机构
  • Firefox - 首选项 → 隐私与安全 → 证书 → 查看证书 → 导入

常见用途

  • 内网 HTTPS 服务(API、GitLab、Jenkins 等)
  • mTLS 双向认证
  • 服务间通信加密
  • 测试环境证书
  • 内部 PKI 基础设施

License

MIT