1:获取
https://api.mch.weixin.qq.com/risk/getcertficates
获取到了
serial_no 和pem
与解密后是一本证书
-----BEGIN CERTIFICATE----- MIID3DCCAsSgAwIBAgIUZPK3dQ2TBNA/Doe4YwWiLDDt+DowDQYJKoZIhvcNAQEL BQAwXjELMAkGA1UEBhMCQ04xEzARBgNVBAoTClRlbnBheS5jb20xHTAbBgNVBAsTFFRlbnBheS5jb20gQ0Eg****************************************
2开始对 要解密的内容加密
$data['id_card_name']=$this->controllerUnit->getEncrypt($data_micro['really_name']);
$data['id_card_number']=$this->controllerUnit->getEncrypt($data_micro['identity_id']);
$data['account_name']=$this->controllerUnit->getEncrypt($data_micro['bank_card_name']);
$data['account_number']=$this->controllerUnit->getEncrypt($data_micro['bank_card_id']);
$data['contact']=$this->controllerUnit->getEncrypt($data_micro['contract_name']);
$data['contact_phone']=$this->controllerUnit->getEncrypt($data_micro['contract_phone']);$data['contact_email']=$this->controllerUnit->getEncrypt($data_micro['contract_email']);
2.1其中 getEncrypt() 方法如下
public function getEncrypt($str){
$encrypted = '';
openssl_public_encrypt($str,$encrypted,$this->getcertficates);
//base64编码
$sign = base64_encode($encrypted);
return $sign;}
$this->getcertficates 就是 上面第一步解密后的证书
与解密后是一本证书
-----BEGIN CERTIFICATE----- MIID3DCCAsSgAwIBAgIUZPK3dQ2TBNA/Doe4YwWiLDDt+DowDQYJKoZIhvcNAQEL BQAwXjELMAkGA1UEBhMCQ04xEzARBgNVBA
3:发送post返回
<xml><return_code><![CDATA[FAIL]]></return_code> <return_msg><![CDATA[解密敏感信息失败,请检查后再试]]></return_msg> </xml>
已解决,不懂问我