これらの問題の回答を検索するためにグーグルで検索しましたが、多くの回答が関連する問題に固有のものであるため、私の質問に対する適切な解決策を見つけることができません。
XMLSecurityKey
を使用してコンテンツのデジタル署名を作成しようとするとopenssl_sign
、警告が表示され、署名が作成されませんでした。
openssl_sign は次のようにエラーをスローしています:
Warning: openssl_sign(): supplied key param cannot be coerced into a private key in /var/www/git/ta_client/accessService.php on line 105
そして私のコードは次のとおりです。
public function _signMessage($encData, $configValues)
{
$decode = 'decode';
$token = $encData['token'];
$cipherValue = $encData['cipherValue'];
$clientId = $encData['ClientId'];
$grpCustNum = $encData['grpCustNum'];
// Sign the concatenated string
$toSign = $token . $cipherValue . $clientId . $grpCustNum;
// Encrypt the token with the public key from vendor
$cipher = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, array('type'=>'private')); // Reference to XMLSecLibs
$cipher->loadKey($configValues['privkey'], true);
try{
if (! openssl_sign ($toSign, $signature, $cipher->key, OPENSSL_ALGO_MD5)) {
openssl_error_string();
throw new Exception();
}
}catch(Exception $e){
print_r($e);
die;
}
// append the decode values
$encData['sign'] = urlencode(base64_encode($signature)) . $decode;
$encData['token'] = urlencode($token) . $decode;
$encData['cipherValue'] = urlencode($cipherValue) . $decode;
return $encData;
}
そして、私$configValues['privkey']
はxml形式です.何か提案はありますか?