当使用任何关于配置文件的openssl函数时,尽管在PHP中将位置传递给函数,但会出现错误


Get error when using any openssl function about config file despite passing location to the function in PHP

我试图使用PHP的openssl函数创建密钥对,但我一直得到错误:

error:0E06D06C:configuration file routines:NCONF_get_string:no value

尽管传递给它配置文件的位置(它存在于那个位置,我检查):

$res = openssl_pkey_new( array('config' => '/etc/ssl/openssl.cnf' ));
//Print errors
while ($msg = openssl_error_string()) echo $msg . "d<br />'n";

,甚至在/usr/local/ssl/openssl.cnf中创建一个符号链接也不能解决问题。

当我检查phpinfo()时,它显示SSL是启用的。

我做错了什么?

我有完全相同的问题,可以通过以下步骤找到上面提到的问题。基本检查以下几点:

    在php.ini中启用openssl扩展
  • openssl.cnf的路径(如phpinfo()所示)是有效的,并且文件存在
  • 将cnf文件替换为其他来源的工作文件(如您的xampp,如果您有一个或php/extra文件夹中的文件)

我的问题(和你的似乎也是)是一个无效的cnf文件。由于我无法改正,我不得不从其他来源得到一份。来自openssl.org的那个不工作。我在我的xampp/php/extra文件夹中找到了一个工作的