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

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条回答 默认 最新

  • doumeng3188 2017-03-14 07:40
    关注

    There was issues with the certificate mismatch and saml assertion format. So we switched to asp.net and stopped using PHP for the task. Now we are using COMPONENTSPACE SAML2.0 library in asp.net

    Question is: How do we manage to run php code with asp.net

    ANS: We send an api request to asp.net code with login credentials and asp.net calls service provider and returns us the redirect url.

    Hope this may help

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 phython如何实现以下功能?查找同一用户名的消费金额合并—
  • ¥15 ARIMA模型时间序列预测用pathon解决
  • ¥15 孟德尔随机化怎样画共定位分析图
  • ¥18 模拟电路问题解答有偿速度
  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对
  • ¥15 误删注册表文件致win10无法开启
  • ¥15 请问在阿里云服务器中怎么利用数据库制作网站
  • ¥60 ESP32怎么烧录自启动程序,怎么查看客户esp32板子上程序及烧录地址
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 java业务性能问题求解(sql,业务设计相关)