Skip to content
Snippets Groups Projects
Commit a492fd4a authored by Olav Morken's avatar Olav Morken
Browse files

SOAPClient: Use the $required parameter on Utilities::loadPublicKey.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2511 44740490-163a-0410-bde0-09ae8108e29a
parent e4c09afb
No related branches found
No related tags found
No related merge requests found
......@@ -53,36 +53,32 @@ class SAML2_SOAPClient {
// do peer certificate verification
if ($dstMetadata !== NULL) {
$peerPublicKey = SimpleSAML_Utilities::loadPublicKey($dstMetadata);
if ($peerPublicKey !== NULL) {
$certData = $peerPublicKey['PEM'];
$peerCertFile = SimpleSAML_Utilities::getTempDir() . '/' . sha1($certData) . '.pem';
if (!file_exists($peerCertFile)) {
SimpleSAML_Utilities::writeFile($peerCertFile, $certData);
}
// create ssl context
$ctxOpts = array(
'ssl' => array(
'verify_peer' => TRUE,
'verify_depth' => 1,
'cafile' => $peerCertFile
));
if (isset($options['local_cert'])) {
$ctxOpts['ssl']['local_cert'] = $options['local_cert'];
unset($options['local_cert']);
}
if (isset($options['passhprase'])) {
$ctxOpts['ssl']['passphrase'] = $options['passphrase'];
unset($options['passphrase']);
}
$context = stream_context_create($ctxOpts);
if ($context === NULL) {
throw new Exception('Unable to create SSL stream context');
}
$options['stream_context'] = $context;
} else {
throw new Exception('IdP metadata was supplied, but no certData present');
$peerPublicKey = SimpleSAML_Utilities::loadPublicKey($dstMetadata, TRUE);
$certData = $peerPublicKey['PEM'];
$peerCertFile = SimpleSAML_Utilities::getTempDir() . '/' . sha1($certData) . '.pem';
if (!file_exists($peerCertFile)) {
SimpleSAML_Utilities::writeFile($peerCertFile, $certData);
}
// create ssl context
$ctxOpts = array(
'ssl' => array(
'verify_peer' => TRUE,
'verify_depth' => 1,
'cafile' => $peerCertFile
));
if (isset($options['local_cert'])) {
$ctxOpts['ssl']['local_cert'] = $options['local_cert'];
unset($options['local_cert']);
}
if (isset($options['passhprase'])) {
$ctxOpts['ssl']['passphrase'] = $options['passphrase'];
unset($options['passphrase']);
}
$context = stream_context_create($ctxOpts);
if ($context === NULL) {
throw new Exception('Unable to create SSL stream context');
}
$options['stream_context'] = $context;
}
$x = new SoapClient(NULL, $options);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment