修正ca签章
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace Extend\Ca;
|
||||
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Exception\BusinessException;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Hyperf\Snowflake\IdGeneratorInterface;
|
||||
|
||||
/**
|
||||
* ca-四川ca云证书+电子签章-线上
|
||||
*/
|
||||
class CaOnline extends Ca
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$offline = config('ca.online');
|
||||
if (empty($offline)) {
|
||||
throw new BusinessException("缺少ca线上配置");
|
||||
}
|
||||
$this->app_id = $offline['app_id'];
|
||||
$this->api_url = $offline['api_url'];
|
||||
$this->secret = $offline['secret'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请云证书
|
||||
* @param array $data
|
||||
* @param string $type
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getCloudCert(array $data, string $type = "Personal"): mixed
|
||||
{
|
||||
$option = [
|
||||
'form_params' => [
|
||||
'entityId' => $data['user_id'], // 用户唯一标识,由业务系统定义
|
||||
'entityType' => $type,// 用户类型,可选值[Personal/Organizational]
|
||||
'personalPhone' => (string)$data['mobile'], // 联系人电话
|
||||
'personalName' => $data['card_name'] ?? "", // 个人姓名,类型为Personal时必填
|
||||
'personalIdNumber' => $data['card_num'] ?? "", // 个人证件号,类型为Personal时必填
|
||||
'orgName' => $data['org_name'] ?? "", // 组织机构名称,信用代码类型为Organizational时必填
|
||||
'orgNumber' => $data['org_number'] ?? "", // 组织机构代码,信用代码类型为Organizational时必填
|
||||
'pin' => $data['user_id'], // 证书PIN码
|
||||
'province' => "四川省", // 卫生证书:省、州
|
||||
'locality' => "成都市", // 卫生证书:城市
|
||||
'authType' => "实人认证", // 委托鉴证方式[实人认证、线下认证、其它方式认证]
|
||||
'authTime' => time(), // 委托鉴证时间(鉴证完成的时间戳)单位:秒
|
||||
'authResult' => "认证通过", // 委托鉴证结果[认证通过]
|
||||
'authNoticeType' => "数字证书申请告知", // 委托鉴证告知类型[数字证书申请告知]
|
||||
]
|
||||
];
|
||||
|
||||
try {
|
||||
$response = $this->httpRequest($this->api_url . '/cloud-certificate-service' . '/api/cloudCert/open/v2/cert/certEnroll', $option);
|
||||
if (empty($response)) {
|
||||
// 返回值为空
|
||||
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
|
||||
}
|
||||
return $response;
|
||||
} catch (GuzzleException $e) {
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user