Certificate 如何解决Google PHP SDK OpenSSL错误:ASN1_get_object:头太长

Certificate 如何解决Google PHP SDK OpenSSL错误:ASN1_get_object:头太长,certificate,google-api-php-client,mediatemple,Certificate,Google Api Php Client,Mediatemple,我很难让Google的PHPSDK直接(实际上是两次)从Google的开发控制台接受p12文件下载。适当的api权限应全部到位 服务器可以读取该文件,而我的主机(mediatemplegrid服务器)表示,没有任何东西应该阻止这一点 这是谷歌自己的sdk中的问题还是我做错了什么 错误是PHP致命错误:未捕获异常“Google_Auth_exception”,消息为“无法解析p12文件”。这是一个.p12文件吗?密码正确吗?OpenSSL错误:错误:0D07207B:asn1编码例程:asn1_g

我很难让Google的PHPSDK直接(实际上是两次)从Google的开发控制台接受p12文件下载。适当的api权限应全部到位

服务器可以读取该文件,而我的主机(mediatemplegrid服务器)表示,没有任何东西应该阻止这一点

这是谷歌自己的sdk中的问题还是我做错了什么

错误是PHP致命错误:未捕获异常“Google_Auth_exception”,消息为“无法解析p12文件”。这是一个.p12文件吗?密码正确吗?OpenSSL错误:错误:0D07207B:asn1编码例程:asn1_get_对象:头太长'

[26-Mar-2015 12:39:52 America/New_York] PHP 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: error:0D07207B:asn1 encoding routines:ASN1_get_object:header too long' in /vendor/google/apiclient/src/Google/Signer/P12.php:53
Stack trace:
#0 /vendor/google/apiclient/src/Google/Auth/AssertionCredentials.php(130): Google_Signer_P12->__construct('0\xEF\xBF\xBD\x06\xEF\xBF\xBD\x02\x01\x030\xEF\xBF\xBD...', 'notasecret')
#1 /vendor/google/apiclient/src/Google/Auth/AssertionCredentials.php(107): Google_Auth_AssertionCredentials->makeSignedJwt(Array)
#2 /vendor/google/apiclient/src/Google/Auth/OAuth2.php(306): Google_Auth_AssertionCredentials->generateAssertion()
#3 /vendor/google/apiclient/src/Google/Auth/OAuth2.php(233): Google_Auth_OAuth2->refreshTokenWithAssertion()
#4 /vendor/google/apiclient/src/Google/Service/Resource.php(208): Google_Auth_OAuth2->sign(Object(Google_Http_Request))
#5 /vendor/google/apiclient/src/Google/Service/Datastore.php(232): Google_Service_Resource->call('runQuery', Array, 'Google_Service_...')
#6 /vendor/tomwalder/php-gds/src/GDS/Gateway.php(360): Google_Service_Datastore_Datasets_Resource->runQuery('SomeName', Object(Google_Service_Datastore_RunQueryRequest))
#7 /vendor/tomwalder/php-gds/src/GDS/Gateway.php(305): GDS\Gateway->executeQuery(Object(Google_Service_Datastore_GqlQuery))
#8 /vendor/tomwalder/php-gds/src/GDS/Store.php(270): GDS\Gateway->gql('SELECT * FROM `...', NULL)
#9 /datastore_test/simple.php(28): GDS\Store->fetchOne()
#10 {main}
  thrown in /vendor/google/apiclient/src/Google/Signer/P12.php on line 53
更新。。。是的,档案会很有帮助。:)

config.php


相关,您需要先发布代码,然后才有人可以帮助您调试。是的,这显然会有帮助。发布代码后仍然不走运吗?
<?php
/**
 * Template Configuration file for php-gds examples
 *
 * @author Tom Walder <tom@docnet.nu>
 */
define('GDS_APP_NAME', 'NAME');
define('GDS_KEY_FILE_PATH', dirname(__FILE__) . '/google-generated-keyname.p12');
define('GDS_SERVICE_ACCOUNT_NAME', 'NAME-No');
define('GDS_DATASET_ID', 'DataStore');

$certs = array();
$pkcs12 = file_get_contents( GDS_KEY_FILE_PATH );
// No password
openssl_pkcs12_read( $pkcs12, $certs, "notasecret" );
//echo $certs['cert'];

$data[0] = $certs['cert'];
$data[1] = 'notasecret';
// If the private key is provided directly, then this isn't in the p12
// format. Different versions of openssl support different p12 formats
// and the key from google wasn't being accepted by the version available
// at the time.
if (!$password && strpos($p12, "-----BEGIN RSA PRIVATE KEY-----") !== false) {
  $this->privateKey = openssl_pkey_get_private($p12);
} else {
  // This throws on error
  $certs = array();
  if (!openssl_pkcs12_read($p12, $certs, $password)) {
    throw new Google_Auth_Exception(
        "Unable to parse the p12 file.  " .
        "Is this a .p12 file?  Is the password correct?  OpenSSL error: " .
        openssl_error_string()
    );
  }
  // TODO(beaton): is this part of the contract for the openssl_pkcs12_read
  // method?  What happens if there are multiple private keys?  Do we care?
  if (!array_key_exists("pkey", $certs) || !$certs["pkey"]) {
    throw new Google_Auth_Exception("No private key found in p12 file.");
  }
  $this->privateKey = openssl_pkey_get_private($certs['pkey']);
}