我想在php中实现的soap服务器上验证soap请求的签名.
服务器代码:
$Server = new SoapServer();
$d = new DOMDocument();
$d->load('php://input');
$s = new WSSESoapServer($d);
try {
if($s->process()) {
// Valid signature
$Server->handle($s->saveXML());
} else {
throw new Exception('Invalid signature');
}
} catch (Exception $e) {
echo "server exception: " . $e;
}
Run Code Online (Sandbox Code Playgroud)
错误:
exception 'Exception' with message 'Error loading key to handle Signature' in /<path>/wse/src/WSSESoapServer.php:146
Run Code Online (Sandbox Code Playgroud)
我已使用此库实现了一个客户端来签署SOAP请求:https://github.com/robrichards/wse-php.没有如何实现服务器的例子......
如何加载公钥来检查签名?
[编辑]我现在可以使用加载提供的密钥了
$key = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, array('type' => 'public'));
$key->loadKey(CERT, true);
Run Code Online (Sandbox Code Playgroud)
验证签名时,我不再收到错误消息:
$x = new XMLSecurityDSig();
$d = $x->locateSignature($soapDoc); …Run Code Online (Sandbox Code Playgroud)