title: openssl_pkey_new throws error configuration file routines:NCONF_get_string:no value
body: <p>I have found couple of posts with this problem but I have not solved my problem using their solution.</p>
  
  <p>This is my test script:</p>
  
  <pre><code>&lt;?php
  echo "\n*** Errors before calling openssl_pkey_new\n";
  // no errors
  while (($e = openssl_error_string()) !== false) {
      var_dump($e);
  }
  
  $config = [
      'config' =&gt; '/etc/ssl/openssl.cnf',
      "digest_alg" =&gt; "sha1",
      "private_key_bits" =&gt; 4096,
      "private_key_type" =&gt; OPENSSL_KEYTYPE_RSA,
  ];
  var_dump(openssl_pkey_new($config));
  
  echo "\n*** Errors after calling openssl_pkey_new\n";
  while (($e = openssl_error_string()) !== false) {
      echo "&lt;pre&gt;";print_r($e);echo "&lt;/pre&gt;";
  }
  </code></pre>
  
  <p>Tried also sha256 and sha512.</p>
  
  <p>cnf file:</p>
  
  <pre><code>ls /etc/ssl/openssl.cnf
  -rw-r--r-- 1 root root 10835 Jun 20  2014 /etc/ssl/openssl.cnf
  </code></pre>
  
  <p>Errors: </p>
  
  <pre><code>error:0E06D06C:configuration file routines:NCONF_get_string:no value&lt;/pre&gt;&lt;pre&gt;error:0E06D06C:configuration file routines:NCONF_get_string:no value&lt;/pre&gt;&lt;pre&gt;error:0E06D06C:configuration file routines:NCONF_get_string:no value
  </code></pre>
  
  <p>I have also tried to set OPENSSL_CONF on the top of script but without success:</p>
  
  <pre><code>putenv('OPENSSL_CONF=/etc/ssl/openssl.cnf');
  </code></pre>
  
  <p>I have also tried to use custom openssl.cnf but also without any success:</p>
  
  <pre><code>cat /var/www/openssl.cnf 
  distinguished_name  = req_distinguished_name
  [req_distinguished_name]
  [v3_req]
  [v3_ca]
  </code></pre>
  
  <p>What could be a problem?</p>
  
  <p>Is it safe to ignore this errors and clear them out after using openssl_pkey_new or there is a solution?</p>
  
  <p>Thank you in advance</p>