创建CSR时,OpenSSL错误0x2006D002


OpenSSL error 0x2006D002 when creating CSR

我有错误

error:2006D002:BIO routines:BIO_new_file:system lib

调用openssl_csr_new函数。

$pKey = openssl_pkey_new( $keyConfig );
$pCSR = openssl_csr_new( $sslConfig, $pKey );

如果没有openssl.cnf,第一个函数就失败了。

我尝试了最小的openssl.cnf和实际配置,但没有效果。如果我使用错误的openssl.cnf错误将是:

error:0E064002:configuration file routines:CONF_load:system lib

请,你能帮助正确的最低openssl.cnf或我需要修复?

  • PHP 5.3.28作为Apache mod;
  • phpinfo: OpenSSL support enabled
  • OpenSSL库版本0.9.8y 5 Feb 2013
  • PHP已经重新安装并重新启动。

解决了,我需要为OpenSSL功能指定$keyConfig:

$keyConfig = array(
    'config' => dirname($_SERVER['SCRIPT_FILENAME']) . '/store/openssl.cnf',
    ...
);
$sslConfig = array(
    "countryName" => 'XX',
    "stateOrProvinceName" => 'XX',
    "localityName" => 'XX',
    ...
);
$pKey = openssl_pkey_new( $keyConfig );
$pCSR = openssl_csr_new( $sslConfig, $pKey , $keyConfig );
$pCRT = openssl_csr_sign( $pCSR , null , $pKey , self::TIME_INTERVAL_WEEK , $keyConfig );
openssl_x509_export( $pCRT, $strCertificate );
openssl_pkey_export( $pKey, $strPrivateKey , null , $keyConfig );