title: OpenSSL Error messages: error:14095126 unexpected eof while reading
body: <p><strong>Description</strong> <br>
  This error:</p>
  
  <pre><code>file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14095126:SSL routines:ssl3_read_n:unexpected eof while reading
  </code></pre>
  
  <p>returns when:</p>
  
  <pre><code>$file = file_get_contents($url['url'], false, stream_context_create($arrContextOptions));
  </code></pre>
  
  <p><strong>Steps to Reproduce</strong> <br></p>
  
  <p>Video to download:</p>
  
  <p><br>
  <a href="https://www.youtube.com/watch?v=r5NzAksjfDI" rel="noreferrer">https://www.youtube.com/watch?v=r5NzAksjfDI</a></p>
  
  <p><em>Extract the video id:</em></p>
  
  <pre><code>$video_id = $yt-&gt;extractVideoId(implode($url));
  </code></pre>
  
  <p><em>Get the downloadable url</em></p>
  
  <pre><code>$links = $yt-&gt;getDownloadLinks($video_id, $selector = 'video');
  </code></pre>
  
  <p><em>Get the array key for the specified video quality etc.</em></p>
  
  <pre><code>$arrayindex = array_search('mp4, video, 1080p, audio', array_column($links, 'format'));
  </code></pre>
  
  <p><em>Set $url to array</em></p>
  
  <pre><code>$url = $links[$arrayindex];
  </code></pre>
  
  <p><em>Disable SSL</em></p>
  
  <pre><code>$arrContextOptions=array( "ssl"=&gt;array( "verify_peer"=&gt;false, "verify_peer_name"=&gt;false, ), );
  </code></pre>
  
  <p><em>Get the file from the url</em></p>
  
  <pre><code>$video = file_get_contents($url['url'], false, stream_context_create($arrContextOptions));
  </code></pre>
  
  <p><em>Send the video back to front end</em></p>
  
  <pre><code>return view('convert', [ 'url' =&gt; $url['url'], 'quality' =&gt; $url['format'], ]);
  </code></pre>
  
  <p><strong>Expected behavior:</strong> <br>
  The video gets downloaded <br>
  <strong>Actual behavior:</strong> <br></p>
  
  <p>I get this error: </p>
  
  <pre><code>file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14095126:SSL routines:ssl3_read_n:unexpected eof while reading
  </code></pre>
  
  <p>The code stops.</p>
  
  <p><strong>Version</strong> <br>
  The latest version of: <br>
  <a href="https://github.com/Athlon1600/youtube-downloader/blob/master/src/YouTubeDownloader.php" rel="noreferrer">https://github.com/Athlon1600/youtube-downloader/blob/master/src/YouTubeDownloader.php</a></p>
  
  <p><strong>Additional Information</strong> <br>
  This code is in the laravel framework, the code here is in the UrlController. This is a local development server, this error also shows up when the firewall is disabled. All the functions used in my code are in the YouTubeDownloader.php file</p>