定制 ross-kvit/php-mtls-hmac 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ross-kvit/php-mtls-hmac

Composer 安装命令:

composer require ross-kvit/php-mtls-hmac

包简介

mTLS + HMAC-signed GET client for testing

README 文档

README

# PHP mTLS + HMAC client


Minimal Composer package demonstrating:


- mTLS client configuration using Guzzle
- HMAC-SHA256 signature computation over canonical query string
- PSR-4 autoloading, .env configuration via vlucas/phpdotenv
- Unit and integration tests (integration test uses badssl client endpoint)


## Setup


1. Copy files into a directory and run `composer install`.
2. Create a `.env` file (copy `.env.example`) and set the real paths/secrets.


Example `.env` for testing with badssl (download certs from https://badssl.com/download/):


```ini
MTLS_CLIENT_CERT=./certs/badssl.com-client-cert.pem
MTLS_CLIENT_KEY=./certs/badssl.com-client-key.pem
MTLS_CLIENT_KEY_PASSPHRASE=badssl.com
HMAC_SECRET=your_shared_hmac_secret
API_ENDPOINT=https://client.badssl.com/
```


3. Run unit tests: `./vendor/bin/phpunit --filter SignerTest`
4. Run integration test (if `.env` contains real cert/key/secret): `./vendor/bin/phpunit --filter IntegrationTest`


## Notes


- Guzzle options set `cert` and `ssl_key`. If your private key is encrypted, set `MTLS_CLIENT_KEY_PASSPHRASE`.
- `verify` defaults to system CA if `MTLS_CA_BUNDLE` not set. To force validation with a specific bundle, set `MTLS_CA_BUNDLE` to the path to your CA bundle.
- The Signer canonicalizes by sorting keys and building an RFC3986-encoded query string, then computing HMAC-SHA256.


## Final notes


This package is structured for testability: Signer is pure and unit-testable; Client depends on Config and Guzzle. The integration test is intentionally skipped unless environment variables are set so CI won't fail.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-10