<?php
namespace Alipay\EasySDK\Kernel;
use Alipay\EasySDK\Kernel\Util\AntCertificationUtil;
use http\Exception\RuntimeException;
class CertEnvironment
{
private $rootCertSN;
private $merchantCertSN;
private $cachedAlipayPublicKey;
public function certEnvironment($merchantCertPath, $alipayCertPath, $alipayRootCertPath)
{
if (empty($merchantCertPath) || empty($alipayCertPath) || empty($alipayRootCertPath)) {
throw new RuntimeException("证书参数merchantCertPath、alipayCertPath或alipayRootCertPath设置不完整。");
}
$antCertificationUtil = new AntCertificationUtil();
$this->rootCertSN = $antCertificationUtil->getRootCertSN($alipayRootCertPath);
$this->merchantCertSN = $antCertificationUtil->getCertSN($merchantCertPath);
$this->cachedAlipayPublicKey = $antCertificationUtil->getPublicKey($alipayCertPath);
}
public function getRootCertSN()
{
return $this->rootCertSN;
}
public function getMerchantCertSN()
{
return $this->merchantCertSN;
}
public function getCachedAlipayPublicKey()
{
return $this->cachedAlipayPublicKey;
}
}