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 🙏

© 2024 – Pkg Stats / Ryan Hefner

myca

v5.1.0

Published

Create Self-signed CA certificate for development use and issue server or client certificates, generated using openssl

Downloads

1,904

Readme

myca

使用 openssl 和 node.js 创建自有 CA 中心(自签发CA证书或者上级CA签发的中级CA证书),签发自签名数字证书。支持创建多个 CA 中心。支持 RSA,EC(P-256, P-384)算法。

GitHub tag License ci codecov Conventional Commits lerna

安装

npm install --save myca

CLI 命令行

  • myca-cli

  • 安装 npm i -g myca-cli

  • 命令行帮助

    • myca
    • myca initca -h
    • myca issue -h
  • Example

    myca initca --days=10950 --alg=ec --pass=capass \
      --cn="Root CA" --ou="waitingsong.com" --o="waitingsong" --l="CD" --c=CN \
    myca issue --kind=server --days=3650 --pass=mypass \
      --cn="waitingsong.com" --o="waitingsong" --c=CN --caKeyPass=capass \
      --centerName=default --alg=ec \
      --ips="127.0.0.1, 192.168.0.1" \
      --SAN="localhost" 
    myca issue --kind=client --days=3650 --pass=mypass \
      --cn="client" --o="it" --c=CN --caKeyPass=capss \
      --centerName=default --alg=ec 

使用

  • 初始化默认中心

    import { initDefaultCenter } from 'myca'
    
    await initDefaultCenter()
  • 初始化默认中心的 CA 自签发证书

    import { initCaCert } from 'myca'
    
    const opts = {
      days: 10950,  // 30years
      pass: 'mycapass',
      CN: 'My Root CA',    // Common Name
      O: 'My Company',   // Organization Name (eg, company)
      C: 'CN',   // Country Name (2 letter code)
    }
    await initCaCert(opts)
  • 签发一张 RSA 服务器证书

    import { genCert } from 'myca'
    
    const opts = {
      caKeyPass: 'mycapass',
      kind: 'server',   // server cert
      days: 730,
      pass: 'fooo',   // at least 4 letters
      CN: 'www.waitingsong.com',    // Common Name
      OU: '',   // Organizational Unit Name
      O: '',   // Organization Name
      L: '',    // Locality Name (eg, city)
      ST: '',   // State or Province Name
      C: 'CN',   // Country Name (2 letter code)
      emailAddress: '',
    }
    await genCert(opts)
    console.log(ret.cert)
    console.log(ret.crtFile)
    console.log(ret.privateUnsecureKey)
  • 创建额外的中心,并且自签发 EC 算法的 CA 证书 (默认 P-256)

    import { initCenter, initCaCert } from 'myca'
    
    // 中心名centerName: ec, 路径: /opt/center-ec/ (可省略)
    await initCenter('ec', '/opt/center-ec')
    await myca.initCaCert({
      centerName: 'ec',
      alg: 'ec',
      days: 10950,
      pass: 'mycapass',
      CN: 'My Root CA',
      O: 'My Company',
      C: 'CN',
    })
  • 使用指定的中心签发一张 RSA 服务器证书

    import { genCert } from 'myca'
    
    const opts = {
      centerName: 'ec',  // <--- 指定中心名: ec
      caKeyPass: 'mycapass',
      kind: 'server',
      days: 730,
      pass: 'fooo',
      CN: 'www.waitingsong.com',
      C: 'CN',
    }
    const ret = await genCert(opts)
    console.log(ret.cert)
    console.log(ret.crtFile)
    console.log(ret.privateUnsecureKey)
  • 签发 SAN 多域名服务器证书

    import { genCert } from 'myca'
    
    const opts = {
      caKeyPass: 'mycapass',
      kind: 'server',
      days: 730,
      pass: 'fooo',
      CN: 'www.waitingsong.com',
      C: 'CN',
      SAN: ['foo.waitingsong.com', 'bar.waitingsong.com'],
    }
    await genCert(opts)
  • 签发 SAN 多ip服务器证书

    import { genCert } from 'myca'
    
    const opts = {
      caKeyPass: 'mycapass',
      kind: 'server',
      days: 730,
      pass: 'fooo',
      CN: 'www.waitingsong.com',
      C: 'CN',
      // https://www.tbs-certificates.co.uk/FAQ/en/normes_tld.html
      // 10.0.0.0 – 10.255.255.255
      // 172.16.0.0 – 172.31.255.255
      // 192.168.0.0 – 192.168.255.255
      ips: ['127.0.0.1', '192.168.0.1'], // not support ip mask
    }
    const ret = await genCert(opts)
    console.log(ret.cert)
  • 签发一张 RSA p12/pfx 客户端证书

    import { genCert } from 'myca'
    
    const opts = {
      caKeyPass: 'mycapass',
      kind: 'client',   // pfx cert
      days: 730,
      pass: 'fooo',   // at least 4 letters
      CN: 'www.waitingsong.com',    // Common Name
      C: 'CN',   // Country Name (2 letter code)
    }
    const ret = await genCert(opts)
    console.log(ret.pfxFile)

Packages

| Package | Version | | ------------ | ---------------------- | | myca | main-svg | | myca-cli | cli-svg |

License

MIT

Languages