mkcert

mkcert

用来生成自签证书的工具

示例

mkcert 是 GO 编写的,一个简单的零配置的用来生成自签证书的工具。

下面给一个简单的示例,在本地生成自签证书,并使用让 nc 使用生成的证书。

~ ·········································································································································  10:46:25
❯ mkcert -install
The local CA is already installed in the system trust store! 👍The local CA is already installed in the Firefox and/or Chrome/Chromium trust store! 👍
~ ·········································································································································  10:46:34
❯ mkcert example.com "*.example.com" example.test localhost 127.0.0.1 ::1

Created a new certificate valid for the following names 📜 - "example.com"
 - "*.example.com"
 - "example.test"
 - "localhost"
 - "127.0.0.1"
 - "::1"

Reminder: X.509 wildcards only go one level deep, so this won't match a.b.example.com ℹ️

The certificate is at "./example.com+5.pem" and the key at "./example.com+5-key.pem" ✅
It will expire on 30 January 2025 🗓

~ ·········································································································································  10:47:37
❯ ls             
公共  视频  文档  音乐  aria          aria2-downloads  Dockerfile             example.com+5.pem  GOPATH  minio-binaries  nowip_hosts.txt  tech_backend.jar
模板  图片  下载  桌面  aria2-config  cv_debug.log     example.com+5-key.pem  go                 math    navicat_reset   src
~ ·········································································································································  10:47:55
❯ ncat -lvp 1589 --ssl-key example.com+5-key.pem --ssl-cert example.com+5.pem 
Ncat: Version 7.92 ( https://nmap.org/ncat )
Ncat: Listening on :::1589
Ncat: Listening on 0.0.0.0:1589
Ncat: Connection from 127.0.0.1.
Ncat: Connection from 127.0.0.1:39156.
Ncat: Failed SSL connection from 127.0.0.1: error:00000000:lib(0):func(0):reason(0)

mkcert 自动生成并安装一个本地 CA 到 root stores,并且生成 locally-trusted 证书。mkcert 不会自动使用证书来配置服务器,不过,这取决于你。

安装

Warning: mkcert 自动生成的 rootCA-key.pem 文件提供了完整的能力来拦截你机器上的安全请求。请不要分享它。

macOS

$ brew install mkcert
$ brew install nss # 如果用 Firefox 的话

Linux

在 Linux 上,首先要安装 certutil

$ sudo apt install libnss3-tools
#    -or-
$ sudo yum install nss-tools
#    -or-
$ sudo pacman -S nss
#    -or-
$ sudo zypper install mozilla-nss-tools

然后可以使用 Homebrew on Linux 来安装。

$ brew install mkcert

或者从源码构建(要求 Go 1.13+)

git clone https://github.com/FiloSottile/mkcert && cd mkcert
go build -ldflags "-X main.Version=$(git describe --tags)"

又或者使用 预构建的二进制文件

$ curl -JLO "https://dl.filippo.io/mkcert/latest?for=linux/amd64"
$ chmod +x mkcert-v*-linux-amd64
$ sudo cp mkcert-v*-linux-amd64 /usr/local/bin/mkcert

对于 Arch Linux 用户(比如我),mkcert 在 Arch Linux 官方仓库中可用。

$ sudo pacman -S mkcert

Windows

使用 Chocolatey

$ choco install mkcert

或者使用 Scoop

$ scoop bucket add extras
$ scoop install mkcert

或者从源码构建(要求 Go 1.10+) ,或者使用 预构建的二进制文件

如果遇到权限问题,请使用管理员运行 mkcert

支持的 root stores

mkcert 支持以下 root stores:

  • macOS system store
  • Windows system store
  • Linux 发行版提供
    • update-ca-trust (Fedora,RHEL,CentOS)或者
    • update-ca-certificates (Ubuntu,Debian,OpenSUSE,SLES)或者
    • trust (Arch)
  • Firefox (仅 macOS 和 Linux)
  • Chrome 和 Chromium
  • Java(当 JAVA_HOME 被设置时)

若文章对你有帮助,可以点赞或打赏支持我们。发布者:Aurora,转载请注明出处:http://61.174.243.28:13541/AY-knowledg-hub/mkcert/

(0)
AuroraAurora站点维系者
上一篇 2024年 1月 3日 下午6:03
下一篇 2024年 1月 3日 下午6:03

相关推荐

  • getent

    文章目录getent语法选项实例 getent 查询 DNS 名称服务器中的命名空间 语法 getent [选项] 主机名或域名 选项 -h # 显示帮助信息 -n # 不解析 D…

    入门教程 2023年 12月 14日
  • systemctl

    文章目录systemctl补充说明实例 systemctl 系统服务管理器指令 补充说明 systemctl命令 是系统服务管理器指令,它实际上将 service 和 chkcon…

    入门教程 2024年 3月 11日
  • suspend

    文章目录suspend概要主要用途选项返回值例子注意 suspend 挂起shell的执行。 概要 suspend [-f] 主要用途 挂起shell的执行,直到收到SIGCONT…

    入门教程 2024年 3月 11日
  • shopt

    文章目录shopt补充说明语法选项参数实例 shopt 显示和设置shell操作选项 补充说明 shopt命令 用于显示和设置shell中的行为选项,通过这些选项以增强shell易…

    入门教程 2024年 3月 4日
  • enable

    文章目录enable概要主要用途选项参数返回值例子(以下内容限于篇幅不再列出返回值部分)Q&A注意 enable 启动或禁用shell内建命令 概要 enable [-a]…

    入门教程 2023年 12月 14日
  • 接口(二)

    文章目录接口实现接口:指针接受者与值接受者实现多个接口接口的嵌套接口的零值 接口 上一节:第十八篇 接口一下一节:第二十篇 并发入门 欢迎来到第 19 个教程。接口共有两个教程,这…

    2023年 12月 5日
  • TCP/IP 寻址

    TCP/IP 使用 32 个比特或者 4 组 0 到 255 之间的数字来为计算机编址。 文章目录IP地址IP 地址包含 4 组数字:32 比特 = 4 字节IP V6域名 IP地…

    2023年 5月 15日
  • init

    文章目录init补充说明语法选项参数实例 init init进程是所有Linux进程的父进程 补充说明 init命令 是Linux下的进程初始化工具,init进程是所有Linux进…

    入门教程 2023年 12月 19日
  • vmstat

    文章目录vmstat补充说明语法选项参数实例 vmstat 显示虚拟内存状态 补充说明 vmstat命令 的含义为显示虚拟内存状态(“Viryual Memor Statics”)…

    入门教程 2024年 3月 11日
  • Java 开发环境配置

    在本章节中我们将为大家介绍如何搭建Java开发环境。 Windows 上安装开发环境 Linux 上安装开发环境 安装 Eclipse 运行 Java 文章目录window系统安装…

    2023年 3月 4日

发表回复

登录后才能评论
Translate »