Dvi*_*nis 6 linux ssh openssh cryptography digital-signature
我想让选定数量的开发人员能够在系统上运行代码,并使用 OpenSSH 的-Y verify
功能对其进行验证。
# Generate the certificates, and sign the dev cert with the root CA
ssh-keygen -t ed25519 -C "Example Root CA" -N "" -f ./rootca
ssh-keygen -t ed25519 -C "Some Developer Inc." -N "" -f ./developer
ssh-keygen -s ./rootca -I somedeveloper@example.com ./developer.pub # <- Creates ./developer-cert.pub
# Sign "example.bin"
echo "hello" > ./example.bin
ssh-keygen -Y sign -f ./developer -n "codesign@example.com" ./example.bin
Run Code Online (Sandbox Code Playgroud)
现在,给定“example.bin”、“example.bin.sig”、“rootca.pub”和“developer-cert.pub”,您将如何验证它?
该ssh-keygen -Y verify
命令不带“developer-cert.pub”文件的参数,这对于完成 CA 和签名之间的信任链至关重要。
我可以使用ssh-keygen -L
,但它似乎不安全(谁实际上检查证书中的根 CA 签名?)。
目前看来我唯一的选择是使用 libssh,还有其他方法吗?
编辑:感谢@user1686的回答,我已经完成了这个例子:
# Generate the certificates
ssh-keygen -t ed25519 -C "Example Root CA" -N "" -f ./rootca
ssh-keygen -t ed25519 -C "Some Developer Inc." -N "" -f ./developer
# Sign the dev cert with the root CA, granting a "codesign+foo" entitlement
ssh-keygen -s ./rootca -I somedeveloper@example.com -n codesign+foo@example.com ./developer.pub # <- Creates ./developer-cert.pub
# Sign "example.bin" using the "codesign@example.com" namespace (doesn't grant any entitlements, just used for security)
echo "hello" > example.bin
ssh-keygen -Y sign -f ./developer-cert.pub -n "codesign@example.com" ./example.bin
# Verifying the "codesign+foo@example.com" entitlement
echo "codesign+foo@example.com cert-authority $(cat rootca.pub)" > allowed_signers.conf
ssh-keygen -Y verify -I "codesign+foo@example.com" -n "codesign@example.com" -s example.bin.sig -f allowed_signers.conf < example.bin
Run Code Online (Sandbox Code Playgroud)
创建签名时必须指定证书,以便将其嵌入到签名public_key
字段中而不是普通的公钥中。(签名时,ssh-keygen 将自动查找附近的私钥-f developer-cert.pub
,但反之则不然。)
稍后在验证时,将根据嵌入的公钥验证签名,并根据“允许的签名者”文件(可以使用 指定您的 CA)检查公钥cert-authority
。
(OpenSSH 证书格式不支持中间 CA,因此没有像 X.509 中那样嵌入或指定“证书链”的选项,并且术语“根 CA”没有多大意义。)
归档时间: |
|
查看次数: |
1104 次 |
最近记录: |