3

我尝试在 mac 上使用证书创建签名:

$pkcs12 = file_get_contents($this->certPath);

$certs = array();

if(openssl_pkcs12_read($pkcs12, $certs, $this->certPass) == true) {

    $certdata = openssl_x509_read($certs['cert']);
    $privkey = openssl_pkey_get_private($certs['pkey'], $this->certPass );

    openssl_pkcs7_sign($paths['manifest'], $paths['signature'], $certdata, $privkey, array(), PKCS7_BINARY | PKCS7_DETACHED);

    $signature = file_get_contents($paths['signature']);
    $signature = $this->convertPEMtoDER($signature);

    file_put_contents($paths['signature'], $signature);

    return true;
}

但它给了我:

警告:openssl_x509_read():提供的参数不能被强制转换为 X509 证书!

我发现有人说这是 UTF-8 BOM 问题,但在这种情况下不是问题,我该怎么办?

谢谢!

4

0 回答 0