title: Does OpenSSL really need a path to openssl.conf?
body: <p>I want to create a self-signed-certificate in PHP 5.x. with my own (alternative) openssl configuration which should be defined by my PHP code. The PHP script will run on different environments (shared hosting webservers).</p>
  
  <p>The official <a href="http://php.net/manual/en/function.openssl-csr-new.php" rel="noreferrer">PHP Manual</a> says:</p>
  
  <blockquote>
    <p>By default, the information in your system openssl.conf is used to initialize the request; you can specify a configuration file section by setting the config_section_section key of configargs. You can also specify an <strong>alternative openssl configuration file by setting the value of the config key to the path of the file you want to use.</strong> The following keys, if present in configargs behave as their equivalents in the openssl.conf, as listed in the table below.....</p>
  </blockquote>
  
  <p>My question: Is there a reason why I have to specify the path to openssl.conf explicitly, because it seems to work fine without it:</p>
  
  <pre><code>$Configs = array(       
      'digest_alg' =&gt; 'sha1',
      'x509_extensions' =&gt; 'v3_ca',
      'req_extensions' =&gt; 'v3_req',
      'private_key_bits' =&gt; 1024,
      'private_key_type' =&gt; OPENSSL_KEYTYPE_RSA,
      'encrypt_key' =&gt; true,
      'encrypt_key_cipher' =&gt; OPENSSL_CIPHER_3DES
  );
  
  $privkey = openssl_pkey_new();
  $csr = openssl_csr_new($dn, $privkey, $Configs);
  $sscert = openssl_csr_sign($csr, null, $privkey, 365, $Configs);
  </code></pre>
  
  <p><strong>Edit:</strong></p>
  
  <p>In the user contributed notes on the <a href="http://php.net/manual/en/function.openssl-csr-new.php" rel="noreferrer">PHP Manual</a>, why do they always specify a path to openssl.cnf? For example:</p>
  
  <pre><code>$configargs = array(
      'config' =&gt; '/etc/ssl/openssl.cnf',
      'digest_alg' =&gt; 'md5',
      'x509_extensions' =&gt; 'v3_ca',
      'req_extensions'   =&gt; 'v3_req',
      'private_key_bits' =&gt; 666,
      'private_key_type' =&gt; OPENSSL_KEYTYPE_RSA,
      'encrypt_key' =&gt; false,
  );
  </code></pre>