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

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

报告相同问题?

悬赏问题

  • ¥50 有偿求qftp工具。能连接,下载文件,发送代码,windows环境,最好qt6 要qt creator写的
  • ¥70 刚刚看到一个人的网站居然是通过cname访问的
  • ¥15 Attributeerror:super object has no attribute '__sklearn_tags__'_'
  • ¥15 逆置单链表输出不完整
  • ¥15 宇视vms-B200-A16@R启动不了,如下图所示,在软件工具搜不到,如何解决?(操作系统-linux)
  • ¥500 寻找一名电子工程师完成pcb主板设计(拒绝AI生成式答案)
  • ¥15 关于#mysql#的问题:UNION ALL(相关搜索:sql语句)
  • ¥15 matlab二位可视化能否针对不同数值范围分开分级?
  • ¥15 已经创建了模拟器但是不能用来运行app 怎么办😭自己搞两天了
  • ¥15 关于#极限编程#的问题,请各位专家解答!