我是新来的php,我需要对SSO服务器进行身份验证。 SSO服务器是.Net,使用SSL证书。用证书解码http响应
当我从SSO服务器返回时,响应被编码。 我有证书的关键当然,但我怎么能解密的回应?
这对我来说很模糊,不要犹豫,详细你的答案:)
提前感谢您的帮助, 问候
我是新来的php,我需要对SSO服务器进行身份验证。 SSO服务器是.Net,使用SSL证书。用证书解码http响应
当我从SSO服务器返回时,响应被编码。 我有证书的关键当然,但我怎么能解密的回应?
这对我来说很模糊,不要犹豫,详细你的答案:)
提前感谢您的帮助, 问候
可以使用http/ssl stream wrapper让PHP透明地处理ssl部分。
让我们从简单的开始:
$c = file_get_contents('file.txt');
没有包装已指定,因此文件://默认情况下使用。 file:// wrapper尝试打开本地文件file.txt,file_get_contents()从该流读取数据。
下一步:所述HTTP包装
$c = file_get_contents('http://docs.php.net/fopen');
现在被指定的包装。 http-wrapper请求h ttp://docs.php.net/fopen并将结果作为从其中file_get_contents()所有数据的流返回。
如果启用了ssl支持(另请参阅http://docs.php.net/openssl),也可以使用http s。
$c = file_get_contents('https://developer.mozilla.org/en/gecko_dom_reference');
可选:服务器/客户机认证
您可以将context to a php stream允许您设置选项/参数所涉及的流包装。
例如http-wrapper在向服务器发送http请求时考虑参数http.user_agent。所以,如果你想使服务器“相信”火狐的特定版本发出请求为一个文件,你可以这样做
$context = stream_context_create(
array(
'http'=>array('user-agent'=>'Mozilla/6.0 (Windows; U; Windows NT 7.0; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.9 (.NET CLR 3.5.30729)')
)
);
$c = file_get_contents('http://docs.php.net/fopen', 0, $context);
$context = stream_context_create(
array(
'http'=>array( ...http-wrapper options here),
'ssl'=>array( ...ssl-wrapper options here)
)
);
https服务器可能会要求您在允许访问资源前进行身份验证。客户端证书必须与请求一起发送,服务器决定它是否可接受。上下文参数ssl.local_cert允许您指定请求中使用的客户端证书。证书文件可能受密码保护。在这种情况下,你必须为ssl.passphrase
$context = stream_context_create(
array(
'ssl'=>array(
'local_cert'=>'xyz/VolkerCA/UserVolker.pem',
'passphrase'=>'my secret passphrase'
)
)
);
$c = file_get_contents('https://hermes..../ssl/test.php', 0, $context);
在您可能(还)要确保服务器确实是它所声称的另一方面提供密码。如何确定一个(服务器)证书是否可接受/有效/可信赖是有点超出了这篇文章。 http://docs.php.net/book.openssl
设置ssl.verify_peer = true并将查找验证数据的位置信息传递给ssl。cafile
$context = stream_context_create(
array(
'ssl'=>array(
'local_cert'=>'xyz/VolkerCA/UserVolker.pem',
'passphrase'=>'my secret passphrase',
'verify_peer'=>true,
'cafile'=>'xyz/VolkerCA/VolkerCA.pem'
)
)
);
$c = file_get_contents('https://hermes..../ssl/test.php', 0, $context);
如果来自SSO的响应超过SSL/HTTPS,则不需要解密响应。你能给出一些代码,并指出你期望它做什么,不做什么。 – Gordon 2009-12-17 11:03:02
另外,您可以提供SSO服务器产品的名称或任何其他相关信息。 – Gordon 2009-12-17 11:07:24