apex / armor-x509
Armor 的 x509 扩展
2.0
2022-01-30 22:57 UTC
Requires
- php: >=8.0
- apex/armor: ^2.0
Requires (Dev)
- apex/signer: ^2.0
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-09-29 05:56:33 UTC
README
为 Armor 包提供 x.509 签名和验证功能的扩展。此扩展功能相对基础,将在不久的将来进行更新。
注意:尽管功能在技术上存在,请勿将私钥存储在数据库中。此包旨在提供公钥和证书的存储,而不是私钥。
安装
使用 Composer 安装
composer require apex/armor-x509
基本用法
use Apex\Armor\Armor; use Apex\Armor\x509\{KeyManager, DistinguishedName, Signature}; // Init Armor $armor = new Armor(); // Get DN $dn = new DistinguishedName( country: 'CA', province: 'Ontario', locality: 'Toronto', org_name: 'Company XYZ', common_name: 'fqdn.domain.com', email: 'me@domain.com ); // Generate self-signed cert for uuid u:admin $manager = new KeyManager($armor); $res = $manager->generate('u:admin', $dn, 'adminpass12345', true); // Generate cert for uuid, u:581 signed by u:admin $user = $manager->generate('u:581', $dn, 'password12345'); $manager->sign('u:581', 'u:admin', 'adminpass12345', $res['privkey']); // Sign hash $signer = new Signature($armor); $user_privkey = $manager->openPrivKey($user_res['privkey'], 'password12345'); $sig = $signer->sign('message_to_sign', $user_privkey); // Verify signature if (!$signer->verify('message_to_sign', $sig, 'u:581', 'u:admin')) { echo "Unable to verify\n"; } else { echo "Verification successful\n": }
支持
如果您有任何问题、问题或反馈,请随时在 ApexPl Reddit 子版块 上留言,以获得快速和有用的答复。
关注 Apex
在不久的将来将有很多好事,包括新的优质开源包、更高级的文章/教程,涉及实用的主题等。通过加入我们网站上的 邮件列表 或在 Twitter 上关注 @mdizak1 来保持最新信息。