duanbei1709
2016-12-20 19:43
浏览 58
已采纳

CorePHP - SAMLSignOn失败:无法将base-64编码的字符串转换为XML

I have setup Identity Provider for SAML assertion using corePHP. I am using curl to send assertion request to Service Provider.

My identity provider is on core php using curl.

Service Provider is made using componentspace saml2.0 in asp.net

Here is my code:

$url = "https://sp.name.com/sso/saml";

$filename = "saml1.xml";
$read = fopen($filename, "r");
$XML = fread($read, filesize($filename));
fclose($read);

$XML_utf8 = utf8_encode($XML);
$XML64 = base64_encode($XML_utf8);

$data = "SAMLResponse=".$XML64."&RelayState=https://sp.name.com/sso/saml";

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);

When I run this script on my service provider following errors messages generate:

SAMLSignOn failed: Failed to convert the base-64 encoded string into XML.
[Exception: SAMLSignOn failed: Failed to convert the base-64 encoded string into XML.]
[SAMLSerializationException: Failed to convert the base-64 encoded string into XML.]

I have already spent long time on this issue.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题