title: Getting "Unable to parse the p12 file..." Error With google-api-php-client
body: <p>I've been searching for days and trying new and older version of google-api-php-client along with various other examples out there, but I can't seem to get around this error. 
  The code below is the service-account example retrieved from GitHub and I dropped in my credentials and file from the API Console.  I've got a different file I'm actually building, but for use in this question, I figure this simpler file would be easier to discuss. I'm getting the same error with both files.</p>
  
  <blockquote>
    <p>Fatal error: Uncaught exception 'Google_Auth_Exception' with message 'Unable to parse the p12 file. Is this a .p12 file? Is the password correct? OpenSSL error: ' in /google-api-php-client/src/Google/Signer/P12.php on line 52</p>
  </blockquote>
  
  <p>I'm completely stumped about why it is throwing this error. </p>
  
  <p>I've verified "file_get_contents" is actually getting the contents of the file and my "notasecret" password is getting pulled properly. I was hoping <a href="https://github.com/google/google-api-php-client/commit/ca8aa5ea8a90eef737f44e0bd7d011d0c3b54e42" rel="noreferrer">this recent commit</a> might help, but unfortunately, it didn't solve this error for me. </p>
  
  <p>Any idea what is going wrong here? Thank you for any suggestions!</p>
  
  <pre><code>&lt;?php
  
  session_start();
  include_once "templates/base.php";
  
  set_include_path("../src/" . PATH_SEPARATOR . get_include_path());
  require_once 'Google/Client.php';
  require_once 'Google/Service/Books.php';
  
  
  $client_id = 'xxxx.apps.googleusercontent.com';
  $service_account_name = 'xxxx@developer.gserviceaccount.com';
  $key_file_location = 'xxxx-privatekey.p12';
  
  echo pageHeader("Service Account Access");
  if ($client_id == 'xxxx.apps.googleusercontent.com'
      || !strlen($service_account_name)
      || !strlen($key_file_location)) {
    echo missingServiceAccountDetailsWarning();
  }
  
  $client = new Google_Client();
  $client-&gt;setApplicationName("Client_Library_Examples");
  $service = new Google_Service_Books($client);
  
  if (isset($_SESSION['service_token'])) {
    $client-&gt;setAccessToken($_SESSION['service_token']);
  }
  $key = file_get_contents($key_file_location);
  $cred = new Google_Auth_AssertionCredentials(
      $service_account_name,
      array('https://www.googleapis.com/auth/books'),
      $key
  );
  $client-&gt;setAssertionCredentials($cred);
  if($client-&gt;getAuth()-&gt;isAccessTokenExpired()) {
    $client-&gt;getAuth()-&gt;refreshTokenWithAssertion($cred);
  }
  $_SESSION['service_token'] = $client-&gt;getAccessToken();
  
  
  $optParams = array('filter' =&gt; 'free-ebooks');
  $results = $service-&gt;volumes-&gt;listVolumes('Henry David Thoreau', $optParams);
  echo "&lt;h3&gt;Results Of Call:&lt;/h3&gt;";
  foreach ($results as $item) {
    echo $item['volumeInfo']['title'], "&lt;br /&gt; \n";
  }
  
  echo pageFooter(__FILE__);
  </code></pre>