title: openssl_pkey_new doesn't work in xampp
body: <p>I have googled and studied openssl for several days, and have not found a solution to the problem with openssl_pkey_new in XAMPP for windows. Have tried both ver. 7.1.1 and 7.1.4. Each time i try to run this code:</p>
  
  <pre><code>echo getenv('OPENSSL_CONF')."&lt;p&gt;";
  
  $config = array(
      "config" =&gt; "c:/xampp/apache/conf/openssl.cnf",
      "digest_alg" =&gt; "sha256",
      "private_key_bits" =&gt; 4096,
      "private_key_type" =&gt; OPENSSL_KEYTYPE_RSA,
  );
  
  // Create the private and public key
  $res = openssl_pkey_new($config);
  echo "&lt;br&gt;openssl_pkey_new: &lt;br&gt;";
  //var_dump(openssl_error_string());
  while($e = openssl_error_string() ) {
      print_r($e."&lt;br&gt;\n");
  }
  
  // Extract the private key from $res to $privKey
  openssl_pkey_export($res, $privKey);
  echo "&lt;br&gt;openssl_pkey_export: &lt;br&gt;";
  while($e = openssl_error_string() ) {
      print_r($e."&lt;br&gt;\n");
  }
  
  // Extract the public key from $res to $pubKey
  $pubKey = openssl_pkey_get_details($res);
  $pubKey = $pubKey["key"];
  echo "&lt;br&gt;openssl_pkey_get_details: &lt;br&gt;";
  while($e = openssl_error_string() ) {
      print_r($e."&lt;br&gt;\n");
  }
  </code></pre>
  
  <p>I get these errors:</p>
  
  <pre><code>openssl_pkey_new:
  error:02001003:system library:fopen:No such process
  error:2006D080:BIO routines:BIO_new_file:no such file
  error:0E064002:configuration file routines:CONF_load:system lib
  error:0E06D06C:configuration file routines:NCONF_get_string:no value
  error:0E06D06C:configuration file routines:NCONF_get_string:no value
  error:0E06D06C:configuration file routines:NCONF_get_string:no value
  error:0E06D06C:configuration file routines:NCONF_get_string:no value
  
  openssl_pkey_export:
  error:02001003:system library:fopen:No such process
  error:2006D080:BIO routines:BIO_new_file:no such file
  error:0E064002:configuration file routines:CONF_load:system lib
  error:02001003:system library:fopen:No such process
  error:2006D080:BIO routines:BIO_new_file:no such file
  error:0E064002:configuration file routines:CONF_load:system lib
  </code></pre>
  
  <p>Maybe erroneous openssl.cnf or/and server.key+server.csr+server.crt
  and/or maybe erroneous  libeay32.dll+ssleay32.dll, or all is bad?
  an anoying problem to be mild in my expression!!</p>
  
  <p>Key generating tutorial: 
  <a href="https://latunyj.wordpress.com/2011/10/31/generating-self-signed-certificate-in-xampp-win32-for-apache-web-server/" rel="nofollow noreferrer">https://latunyj.wordpress.com/2011/10/31/generating-self-signed-certificate-in-xampp-win32-for-apache-web-server/</a></p>
  
  <p>Comprhensive answers to the problem:
  <a href="https://stackoverflow.com/questions/9789358/what-i-have-to-do-to-openssl-extension-work-on-my-xampp-windows">What I have to do to OpenSSL extension work on my xampp (Windows)? :(</a></p>
  
  <p>Other links:
  <a href="https://snippets.aktagon.com/snippets/543-how-to-fix-pem-read-bio-no-start-line-error-nginx-error" rel="nofollow noreferrer">https://snippets.aktagon.com/snippets/543-how-to-fix-pem-read-bio-no-start-line-error-nginx-error</a>
  <a href="http://au.php.net/manual/en/openssl.installation.php" rel="nofollow noreferrer">http://au.php.net/manual/en/openssl.installation.php</a>
  <a href="https://community.apachefriends.org/f/viewtopic.php?f=16&amp;t=71199" rel="nofollow noreferrer">https://community.apachefriends.org/f/viewtopic.php?f=16&amp;t=71199</a></p>
  
  <p>Really hope someone know the answer to this problem.</p>
  
  <p>Edit:</p>
  
  <p>If wondering why it is annoying, is because i am using RSA-OAEP between server and client, implementing openssl and webcrypto to encrypt/decrypt AES-CBC keys. AES-CBC encrypted data is exchanged together with the encrypted keys.</p>
  
  <p>My temporary workaround is generating the on server reciding RSA keypair on client and send in clear text. Ok for development, but not appopriate for production. That is the annoying part. XAMPP prior to 7.x.x didn't have AES-CBC methods. By the way XAMPP is only development.</p>