From a492fd4a6629f89cf1c9fb55b8968b5f25f459d1 Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Tue, 10 Aug 2010 11:26:52 +0000 Subject: [PATCH] SOAPClient: Use the $required parameter on Utilities::loadPublicKey. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2511 44740490-163a-0410-bde0-09ae8108e29a --- lib/SAML2/SOAPClient.php | 54 +++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/lib/SAML2/SOAPClient.php b/lib/SAML2/SOAPClient.php index b9655c775..25eef679e 100644 --- a/lib/SAML2/SOAPClient.php +++ b/lib/SAML2/SOAPClient.php @@ -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); -- GitLab