基于君子签开放平台 API 实现,采用 SHA256 form 表单签名机制。
包信息
- NuGet 包:
Bitzsoft.Integrations.ElectronicSignature.Junziqian - 接口:
IElectronicSignatureProvider - 鉴权:SHA256 form 签名(AppKey / AppSecret)
- Provider ID:
Junziqian
配置
| 字段 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
AppKey | string | 是 | — | 应用 AppKey |
AppSecret | string | 是 | — | 应用 AppSecret(用于签名字符串拼接,不传输) |
BaseUrl | string | 否 | https://api.junziqian.com | API 基地址(沙箱 https://api.sandbox.junziqian.com) |
Timeout | TimeSpan | 否 | 00:00:30 | HTTP 请求超时(文件上传可调大) |
HttpClientName | string | 否 | JunziqianElectronicSignatureProvider | 命名 HttpClient 标识 |
{ "Junziqian": { "AppKey": "your-app-key", "AppSecret": "your-app-secret", "BaseUrl": "https://api.junziqian.com", "Timeout": "00:00:30" }}注册
using Bitzsoft.Integrations.ElectronicSignature.Junziqian;
// 方式一:IConfiguration(默认读取 "Junziqian" 配置节)services.AddBitzsoftJunziqianElectronicSignature(configuration);
// 方式二:委托配置services.AddBitzsoftJunziqianElectronicSignature(options =>{ options.AppKey = "your-app-key"; options.AppSecret = "your-app-secret"; options.BaseUrl = "https://api.junziqian.com";});使用示例
var createResult = await provider.CreateContractAsync(new SimpleContractRequest{ Title = "租赁合同", FileName = "contract.pdf", FileData = await File.ReadAllBytesAsync("contract.pdf"), SignerName = "赵六", SignerPhone = "13600000000"});
var contractId = createResult.Data!;var signUrl = await provider.GetSigningUrlAsync(contractId, "signer-id");var status = await provider.GetSigningStatusAsync(contractId);鉴权机制
- 将表单参数按规则排序拼接,加入 AppSecret 后做 SHA256 摘要,生成签名字段随请求发送。
已知限制
统一接口覆盖极简场景。复杂签署流程通过 partial class 扩展方法调用。