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

nginx-ssl

v1.0.1

Published

生成HTTPS证书

Downloads

1

Readme

生成自签名SSL证书

在Windows、Linux中需要使用openssl来生成自签名HTTPS证书,先确保系统中已安装openssl。 此处提供自动、手动生成的方式,自动生成方式需要在项目目录下/config/custom.conf.json中填写自己的证书信息,手动生成方式需要自己复制以下命令手动生成证书。

自动生成自签名证书

1.填写证书信息

{
  "countryName": "",//国家单词简称大写,如:中国CN
  "stateOrProvinceName": "",//省份名称拼音
  "localityName": "",//城市名称拼音
  "organizationName": "",//组织名称
  "organizationalUnitName": "",//组织单位名称
  "commonName": "",//域名,确保和host文件中的一致
  "emailAddress": "",//邮箱
  "needClient": false,//是否生成客户端证书
}

2.生成证书

运行:npm start

手动生成自签名证书

【注意】在Linux环境下使用命令先加 sudo.证书存放在项目目录output下,先运行命令:cd output

1.生成CA根证书

# 1.1生成CA私钥
openssl genrsa -out ca.key 4096

# 1.2使用CA私钥请求签署CA证书
openssl req -new -x509 -key ca.key -out ca.crt -days 365 -config config/openssl.conf

2.生成服务器证书

# 2.1生成服务器私钥
openssl genrsa -out server.key 4096

# 2.2生成服务器签署申请文件
openssl req -new -key server.key -out server.csr -config config/openssl.conf

# 2.3使用CA证书和私钥签署服务器证书
openssl x509 -req -days 365 -sha256 -CA ca.crt -CAkey ca.key -CAcreateserial -extfile config/openssl.conf -extensions v3_req -in server.csr -out server.crt

3.生成客户端证书(需要双向认证的场景生成)

# 3.1生成服务器私钥
openssl genrsa -out client.key 4096

# 3.2生成服务器签署申请文件
openssl req -new -key client.key -out client.csr -config config/openssl.conf

# 3.3使用CA证书和私钥签署服务器证书
openssl x509 -req -days 365 -sha256 -CA ca.crt -CAkey ca.key -CAcreateserial -extfile config/openssl.conf -extensions v3_req -in client.csr -out client.crt

服务器配置host域名

在机器上配置host

Linux: etc/hosts   
windows: windows/system32/drivers/etc/host

  127.0.0.1	localhost  
  127.0.0.1	taporb.com

手动复制证书到服务器

使用自动或手动生成证书后,需要把证书复制到服务器静态服务容器对应目录下,此处在Ubuntu 根目录下建立目录/nginx/cert/,把证书全部复制到此处。

在nginx中需要先配置HTTPS,配置文件在项目config/nginx.conf,根据自己nginx修改即可。

server_name taporb.com; #替换此处域名
ssl_certificate /nginx/cert/server.crt; #修改自己服务器nginx证书的路径
ssl_certificate_key /nginx/cert/server.key; #修改自己服务器nginx证书的路径

证书加入服务器信任列表

# 复制证书到目录/usr/local/share/ca-certificates/

# 更新信任列表
sudo update-ca-certificates

本地浏览器安装证书

在客户端中双击自签名根证书 ca.crt ,把证书安装到 “受信任的根证书颁发机构”列表下。安装完成后浏览器中不会提示不安全的信息。