CloudKit сервер-сервер и переполнение стека

Следующий PHP-код прекрасно работает в среде разработки, но в производственной среде возвращает ошибку:

{«uuid»: «xxxxx», «serverErrorCode»: «AUTHENTICATION_FAILED», «reason»: «Ошибка аутентификации»}

любая идея ?

function cloudKitRequest($requestType, $jsonbody)
{
$KEY_ID                 = '97659598759875987508750875087087608785987585985';
$CONTAINER              = 'xyz.zz.zzyyxx.xyz';
$PRIVATE_PEM_LOCATION   = 'eckey.pem';
//$Environment            = 'development';
$Environment            = 'production';
$dbtype                 = 'public';
$result                 = NULL;$url = 'https://api.apple-cloudkit.com/database/1/' . $CONTAINER . '/'. $Environment . '/' . $dbtype . '/records/'.$requestType;

// Set cURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);

// Create signature
date_default_timezone_set('UTC');
$explode_date = explode('+', date("c", time()));
$time = $explode_date[0] . 'Z';
$signature = $time . ":" . base64_encode(hash("sha256", $jsonbody, true)) . ":" . explode('cloudkit.com', $url)[1];
// Get private key
$pkeyid = openssl_pkey_get_private("file://" . $PRIVATE_PEM_LOCATION);
// Sign signature with private key
if(openssl_sign($signature, $signed_signature, $pkeyid, "sha256WithRSAEncryption")) {
openssl_free_key($pkeyid);
// Set headers
curl_setopt($ch, CURLOPT_HTTPHEADER,
[
"Content-Type: text/plain",
"X-Apple-CloudKit-Request-KeyID: " . $KEY_ID,
"X-Apple-CloudKit-Request-ISO8601Date: " . $time,
"X-Apple-CloudKit-Request-SignatureV1: " . base64_encode($signed_signature),
]
);
// Set body
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonbody);
// Send the request & save response to $resp
$resp = curl_exec($ch);
if($resp === false) {
die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch));
} else {
//echo $resp;
// $result = json_decode($resp, true);
$result = $resp;
}
curl_close($ch);
} else {
while ($msg = openssl_error_string()) {
echo $msg . "<br />\n";
}
}
return $result;
}

любая идея

1

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …