title: SSL routines:tls_process_server_certificate:certificate verify failed
body: <p>Since last night, several of my scripts (on different servers) using <code>file_get_contents(&quot;https://...&quot;)</code> and <code>curl</code> functions stopped working.<br />
  Example request that fails:</p>
  <pre><code>file_get_contents(&quot;https://domain.tld/script.php&quot;);
  </code></pre>
  <hr />
  <p><strong>Error</strong>:</p>
  <pre><code>PHP Warning:  file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages:
  error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed in /home/domain/public_html/script.php on line 19
  </code></pre>
  <p>I already &quot;fixed&quot; the problem using:</p>
  <pre><code>$arrContextOptions=array(
      &quot;ssl&quot;=&gt;array(
         &quot;verify_peer&quot;=&gt;false,
         &quot;verify_peer_name&quot;=&gt;false,
      ),
  ); 
  
  file_get_contents(&quot;https://domain.tld/path/script.php&quot;, false, stream_context_create($arrContextOptions));
  </code></pre>
  <p>The &quot;fix&quot; is far from ideal since I'm not verifying the authenticity of the connection, but until I understand the origin of the problem and how to prevent it from happening again, I'll be forced to use it.</p>
  <hr />
  <p><strong>Notes</strong>:</p>
  <ul>
  <li>PHP scripts with <code>Curl</code> also stopped working and the <em>fix</em> is similar:
  <code>curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);</code>;</li>
  <li>The <code>SSL</code> certificate is issued by <code>Let's Encrypt</code> and it was renewed last night (&quot;<em>not valid before 2020/12/24</em>&quot;);</li>
  <li>All servers have the same timezone;</li>
  <li>I'm using <code>CentOS 7/Ubuntu 18</code> and <code>Virtualmin</code>;</li>
  <li>If I open <code>&quot;https://domain.tld/script.php&quot;</code> on Firefox/Chrome, no SSL warnings are shown and the certificate is valid;</li>
  <li>I've tried to update the CA certificates (<code>yum install ca-certificates.noarch</code>), but the latest version is already installed;</li>
  </ul>
  <hr />
  <p>I understand what's wrong, what I cannot figure out is why it started happening and how to fix it (the real fix).</p>
  <hr />
  <p><strong>Question</strong>:</p>
  <p>How to fix and prevent it from happening again?</p>