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

相关推荐

  • passwd

    文章目录passwd补充说明语法选项参数知识扩展实例 passwd 用于让用户可以更改自己的密码 补充说明 passwd命令 用于设置用户的认证信息,包括用户密码、密码过期时间等。…

    入门教程 2024年 3月 1日
  • traceroute

    文章目录traceroute补充说明语法选项参数实例 traceroute 显示数据包到主机间的路径 补充说明 traceroute命令 用于追踪数据包在网络上的传输时的全部路径,…

    入门教程 2024年 3月 11日
  • iOS操作(action)和输出口(Outlet)

    简介 在iOS中,操作(action)和输出口(Outlet)指的是ibActions和ibOutlets,也就是ib接口生成器所在的地方。这些都和UI元素相关,我们将直观的了解他…

    2023年 4月 10日
  • xhost

    文章目录xhost补充说明语法参数 xhost 制哪些X客户端能够在X服务器上显示 补充说明 xhost命令 是X服务器的访问控制工具,用来控制哪些X客户端能够在X服务器上显示。该…

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

    文章目录cal补充说明语法选项参数实例 cal 显示当前日历或指定日期的日历 补充说明 cal命令 用于显示当前日历,或者指定日期的日历,如果没有指定参数,则显示当前月份。 一个单…

    入门教程 2023年 12月 7日
  • dpkg-split

    文章目录dpkg-split补充说明语法选项参数实例 dpkg-split Debian Linux中将大软件包分割成小包 补充说明 dpkg-split命令 用来将Debian …

    入门教程 2023年 12月 7日
  • apt-key

    文章目录apt-key补充说明语法参数实例 apt-key 管理Debian Linux系统中的软件包密钥 补充说明 apt-key命令 用于管理Debian Linux系统中的软…

    入门教程 2023年 12月 6日
  • hexdump

    文章目录hexdump补充说明语法选项实例 hexdump 显示文件十六进制格式 补充说明 hexdump命令 一般用来查看“二进制”文件的十六进制编码,但实际上它能查看任何文件,…

    入门教程 2023年 12月 15日
  • tput

    文章目录tput补充说明什么是 terminfo 数据库?实例 tput 通过terminfo数据库对终端会话进行初始化和操作 补充说明 tput命令 将通过 terminfo 数…

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

    文章目录ngrep补充说明安装语法选项实例 ngrep 方便的数据包匹配和显示工具 补充说明 ngrep命令 是grep命令的网络版,他力求更多的grep特征,用于搜寻指定的数据包…

    入门教程 2024年 1月 10日

发表回复

登录后才能评论
Translate »