惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
A
About on SuperTechFans
Apple Machine Learning Research
Apple Machine Learning Research
The Register - Security
The Register - Security
Vercel News
Vercel News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
人人都是产品经理
人人都是产品经理
MyScale Blog
MyScale Blog
云风的 BLOG
云风的 BLOG
博客园_首页
U
Unit 42
T
Tailwind CSS Blog
G
GRAHAM CLULEY
F
Full Disclosure
V
Vulnerabilities – Threatpost
T
Tenable Blog
月光博客
月光博客
P
Privacy & Cybersecurity Law Blog
P
Privacy International News Feed
K
Kaspersky official blog
Scott Helme
Scott Helme
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
N
News and Events Feed by Topic
T
The Exploit Database - CXSecurity.com
N
News and Events Feed by Topic
有赞技术团队
有赞技术团队
Recent Commits to openclaw:main
Recent Commits to openclaw:main
L
LINUX DO - 最新话题
Recorded Future
Recorded Future
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Help Net Security
Help Net Security
The GitHub Blog
The GitHub Blog
Cisco Talos Blog
Cisco Talos Blog
SecWiki News
SecWiki News
P
Proofpoint News Feed
Security Latest
Security Latest
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
罗磊的独立博客
S
Security Affairs
M
MIT News - Artificial intelligence
L
LINUX DO - 热门话题
美团技术团队
Simon Willison's Weblog
Simon Willison's Weblog
T
Threat Research - Cisco Blogs
Stack Overflow Blog
Stack Overflow Blog
Forbes - Security
Forbes - Security
Hugging Face - Blog
Hugging Face - Blog
博客园 - Franky
V
Visual Studio Blog

ThinkAlone

JavaCard 上手 灵上加灵:使用 Pico HSM 和 step-ca 自建一个CA 友善 FriendlyELEC NanoPC-T4 CPU跑分测试 CPU Benchmark 常见物品尺寸记录 树莓派5 Raspberry Pi 5 CPU跑分测试 CPU Benchmark 鼎阳 SDS804X HD 示波器带宽与选件升级 OrangePi Zero3 CPU跑分测试 CPU Benchmark Canokey Canary上手 在2024年配置IPv6是什么怎样一种体验 用 Orange Pi Zero 搭建一台 Stratum 1 的 NTP 服务器 难绷的Zip与中文密码 OrangePi Zero CPU跑分测试 CPU Benchmark 使用 Docker 部署 zhenxun_bot(绪山真寻Bot) 在Docker中运行Klipper 如何优雅的跳过/禁止Steam更新你的游戏 使用 GitHub Actions 自动部署Hexo 使用 Travis CI 自动构建 Hexo 博客 使DockerHub的Autobuild自动构建ARM/其他 架构的镜像 CoffeeMiner:劫持WiFi网络接入设备进行“挖矿”的框架
灵车!开创! Step-CA 日常使用教程
Disappear9 · 2026-01-09 · via ThinkAlone

前几天总算抽空把咕了快一年的自建灵车CA的教程写完了:使用 Pico HSM 和 step-ca 自建一个CA
建完以后总是要拿来用一用玩一玩的,那么这一篇幅就写一些 Step-CA 的使用教程吧,顺便也给自己留个参考。


ACME

修改默认配置

为了安全 Step-CA 默认签出的证书只有24小时的有效期,这对于我们来说是完全没有必要的,先来把它修改到7天

编辑step-ca/config/ca.json

ca.json
1
2
3
4
5
6
7
8
9
{
"type": "ACME",
"name": "acme",
"claims": {
"maxTLSCertDuration": "336h",
"minTLSCertDuration": "24h",
"defaultTLSCertDuration": "168h"
}
}

开启CRL功能

编辑 step-ca/config/ca.json

ca.json
1
2
3
4
5
"insecureAddress": ":9001",
"crl": {
"enabled": true,
"idpURL": "http://ca.lab.d9lab.eu.org/1.0/crl"
},

创建模板 /etc/step-ca/templates/x509/leaf.tpl

leaf.tpl
1
2
3
4
5
6
7
8
9
10
11
{
"subject": { { toJson .Subject } },
"sans": { { toJson .SANs } },
{ {- if typeIs "*rsa.PublicKey" .Insecure.CR.PublicKey } }
"keyUsage": ["keyEncipherment", "digitalSignature"],
{ {- else } }
"keyUsage": ["digitalSignature"],
{ {- end } }
"extKeyUsage": ["serverAuth", "clientAuth"],
"crlDistributionPoints": ["http://ca.lab.d9lab.eu.org/1.0/crl"]
}

编辑 step-ca/config/ca.json
设置acme和JWK provisioner使用模板

ca.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
......
"claims": {
"maxTLSCertDuration": "336h",
"minTLSCertDuration": "24h",
"defaultTLSCertDuration": "168h"
},
"options": {
"x509": {
"templateFile": "/etc/step-ca/templates/x509/leaf.tpl"
},
"ssh": {}
}
......
"claims": {
"enableSSHCA": true,
"disableRenewal": false,
"allowRenewalAfterExpiry": false,
"disableSmallstepExtensions": false
},
"options": {
"x509": {
"templateFile": "/etc/step-ca/templates/x509/leaf.tpl"
},
"ssh": {}
}

给设备发SSL证书

其他ACME客户端可以参考:Popular ACME Clients
这里我们使用acme.sh,主打一个小而美。

假设我要给我内网的旁路由(OpenWRT)签一个证书

由于我们的自建CA不在系统的信任根证书列表里,所以如果直接运行acme.sh,curl会报错,我们需要把root_ca.crt复制一份到设备上。

1
2
3
4
5
6
7
8


$ curl https://get.acme.sh | sh -s [email protected]

$ ~/.acme.sh/acme.sh --issue -d router2.d9lab.eu.org \
--server https://ca.lab.thinkalone.win:4443/acme/acme/directory \
--ca-bundle /root/certs/root_ca.crt \
--webroot /www --days 6 --reloadcmd "service uhttpd reload"

然后编辑/etc/config/uhttpd

1
2
3
4
5
6
7
8
9
...

list listen_https '0.0.0.0:443'
list listen_https '[::]:443'
...

option cert '/root/.acme.sh/router2.d9lab.eu.org_ecc/router2.d9lab.eu.org.cer'
option key '/root/.acme.sh/router2.d9lab.eu.org_ecc/router2.d9lab.eu.org.key'
...

SSH

参考:
SSH Certificates with step-ca
step-ca で ssh証明書を扱う

Server

重启 step-ca ,查看日志找到 SSH Host CA KeySSH User CA Key

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$ sudo service step-ca stop
$ sudo service step-ca start
$ sudo service step-ca status
● step-ca.service - step-ca
Loaded: loaded (/etc/systemd/system/step-ca.service; enabled; preset: enabled)
Active: active (running) since
Main PID: 156738 (sh)
Tasks: 11 (limit: 4529)
Memory: 14.4M
CPU: 305ms
CGroup: /system.slice/step-ca.service
├─156738 /bin/sh -c "/usr/local/bin/step-ca /etc/step-ca/config/ca.json"
└─156739 /usr/local/bin/step-ca /etc/step-ca/config/ca.json

......
SSH Host CA Key: ecdsa-sha2-nistp256 AAA=
SSH User CA Key: ecdsa-sha2-nistp256 AAB=
......

SSH User CA Key 写入到 /etc/ssh/ssh_user_ca_key.pub

1
2
3
$ sudo echo "ecdsa-sha2-nistp256 AAB=" > /etc/ssh/ssh_user_ca_key.pub
$ sudo chown root:root /etc/ssh/ssh_user_ca_key.pub
$ sudo chmod 644 /etc/ssh/ssh_user_ca_key.pub

签名主机公钥

1
2
3
$ sudo cp /etc/ssh/ssh_host_ecdsa_key.pub ssh_host_ecdsa_key.pub
$ sudo step ssh certificate $HOSTNAME ssh_host_ecdsa_key.pub --host --sign
$ sudo cp ssh_host_ecdsa_key-cert.pub /etc/ssh/ssh_host_ecdsa_key-cert.pub

创建 /etc/ssh/sshd_config.d/ca.conf

ca.conf
1
2
TrustedUserCAKeys /etc/ssh/ssh_user_ca_key.pub
HostCertificate /etc/ssh/ssh_host_ecdsa_key-cert.pub

测试 sshd 配置并重启 sshd

1
2
$ sudo sshd -t
$ sudo service ssh restart

SSH Host CA Key 写入到 ~/.ssh/authorized_keys

authorized_keys
1
ecdsa-sha2-nistp256 AAA=

Client

生成用于连接的证书

1
2
3
4
5
6
$ step ssh certificate [email protected] id_ecdsa
......
Please enter the password to encrypt the private key:
Private Key: id_ecdsa
Public Key: id_ecdsa.pub
Certificate: id_ecdsa-cert.pub

SSH Host CA Key 写入到 ~/.ssh/known_hosts

authorized_keys
1
echo "@cert-authority 192.168.1.100 ecdsa-sha2-nistp256 AAA=" >> ~/.ssh/authorized_keys

然后就可以直接 ssh [email protected] 连接了

(完)