Revision: 2237
Author: olavmrk
Date: Fri Mar 26 03:14:37 2010
Log: Allow absolute paths to certificates.
http://code.google.com/p/simplesamlphp/source/detail?r=2237
Modified:
/trunk/lib/SimpleSAML/Bindings/Shib13/Artifact.php
/trunk/lib/SimpleSAML/Metadata/Signer.php
/trunk/lib/SimpleSAML/Utilities.php
/trunk/lib/SimpleSAML/XML/Shib13/AuthnResponse.php
/trunk/lib/SimpleSAML/XML/Signer.php
/trunk/modules/adfs/lib/IdP/ADFS.php
/trunk/modules/saml2/lib/Message.php
/trunk/www/wsfed/sp/prp.php
=======================================
--- /trunk/lib/SimpleSAML/Bindings/Shib13/Artifact.php Wed Nov 4 05:53:25
2009
+++ /trunk/lib/SimpleSAML/Bindings/Shib13/Artifact.php Fri Mar 26 03:14:37
2010
@@ -137,8 +137,7 @@
SimpleSAML_Utilities::writeFile($file, $certData);
}
- $globalConfig = SimpleSAML_Configuration::getInstance();
- $spKeyCertFile = $globalConfig->getPathValue('certdir', 'cert/') .
$spMetadata->getString('privatekey');
+ $spKeyCertFile =
SimpleSAML_Utilities::resolveCert($spMetadata->getString('privatekey'));
$opts = array(
'ssl' => array(
=======================================
--- /trunk/lib/SimpleSAML/Metadata/Signer.php Fri Aug 14 04:07:44 2009
+++ /trunk/lib/SimpleSAML/Metadata/Signer.php Fri Mar 26 03:14:37 2010
@@ -143,13 +143,13 @@
$keyCertFiles = self::findKeyCert($config, $entityMetadata,
$type);
- $keyFile = $config->getPathValue('certdir', 'cert/') .
$keyCertFiles['privatekey'];
+ $keyFile =
SimpleSAML_Utilities::resolveCert($keyCertFiles['privatekey']);
if (!file_exists($keyFile)) {
throw new Exception('Could not find private key file [' .
$keyFile . '], which is needed to sign the metadata');
}
$keyData = file_get_contents($keyFile);
- $certFile = $config->getPathValue('certdir', 'cert/') .
$keyCertFiles['certificate'];
+ $certFile =
SimpleSAML_Utilities::resolveCert($keyCertFiles['certificate']);
if (!file_exists($certFile)) {
throw new Exception('Could not find certificate file [' .
$certFile . '], which is needed to sign the metadata');
}
=======================================
--- /trunk/lib/SimpleSAML/Utilities.php Tue Feb 16 04:21:51 2010
+++ /trunk/lib/SimpleSAML/Utilities.php Fri Mar 26 03:14:37 2010
@@ -1476,6 +1476,21 @@
return $error['message'];
}
+
+
+ /**
+ * Resolves a path that may be relative to the cert-directory.
+ *
+ * @param string $path The (possibly relative) path to the file.
+ * @return string The file path.
+ */
+ public static function resolveCert($path) {
+ assert('is_string($path)');
+
+ $globalConfig = SimpleSAML_Configuration::getInstance();
+ $base = $globalConfig->getPathValue('certdir', 'cert/');
+ return SimpleSAML_Utilities::resolvePath($path, $base);
+ }
/**
@@ -1525,8 +1540,7 @@
} elseif (array_key_exists($prefix . 'certificate', $metadata))
{
/* Reference to certificate file. */
- $config = SimpleSAML_Configuration::getInstance();
- $file = $config->getPathValue('certdir', 'cert/') .
$metadata[$prefix . 'certificate'];
+ $file =
SimpleSAML_Utilities::resolveCert($metadata[$prefix . 'certificate']);
$data = @file_get_contents($file);
if ($data === FALSE) {
throw new Exception('Unable to load certificate/public key from
file "' . $file . '"');
@@ -1612,8 +1626,7 @@
}
}
- $config = SimpleSAML_Configuration::getInstance();
- $file = $config->getPathValue('certdir', 'cert/') .
$metadata[$prefix . 'privatekey'];
+ $file =
SimpleSAML_Utilities::resolveCert($metadata[$prefix . 'privatekey']);
$data = @file_get_contents($file);
if ($data === FALSE) {
throw new Exception('Unable to load private key from file "' .
$file . '"');
=======================================
--- /trunk/lib/SimpleSAML/XML/Shib13/AuthnResponse.php Thu Oct 8 02:55:07
2009
+++ /trunk/lib/SimpleSAML/XML/Shib13/AuthnResponse.php Fri Mar 26 03:14:37
2010
@@ -98,8 +98,7 @@
$this->validator->validateFingerprint($issuerFingerprint);
} elseif(array_key_exists('caFile', $md)) {
/* Validate against CA. */
- $globalConfig = SimpleSAML_Configuration::getInstance();
-
$this->validator->validateCA($globalConfig->getPathValue('certdir', 'cert/') .
$md['caFile']);
+
$this->validator->validateCA(SimpleSAML_Utilities::resolveCert($md['caFile']));
} else {
throw new Exception('Required field [certFingerprint] or [caFile] in
Shibboleth 1.3 IdP Remote metadata was not found for identity provider [' .
$issuer . ']. Please add a fingerprint and try again. You can add a dummy
fingerprint first, and then an error message will be printed with the real
fingerprint.');
}
=======================================
--- /trunk/lib/SimpleSAML/XML/Signer.php Fri Aug 14 04:07:44 2009
+++ /trunk/lib/SimpleSAML/XML/Signer.php Fri Mar 26 03:14:37 2010
@@ -12,11 +12,6 @@
class SimpleSAML_XML_Signer {
- /**
- * The path to the simpleSAMLphp cert dir.
- */
- private static $certDir = FALSE;
-
/**
* The name of the ID attribute.
*/
@@ -58,11 +53,6 @@
public function __construct($options = array()) {
assert('is_array($options)');
- if(self::$certDir === FALSE) {
- $config = SimpleSAML_Configuration::getInstance();
- self::$certDir = $config->getPathValue('certdir',
'cert/');
- }
-
$this->idAttrName = FALSE;
$this->privateKey = FALSE;
$this->certificate = FALSE;
@@ -128,7 +118,7 @@
assert('is_string($file)');
assert('is_string($pass) || is_null($pass)');
- $keyFile = self::$certDir . $file;
+ $keyFile = SimpleSAML_Utilities::resolveCert($file);
if (!file_exists($keyFile)) {
throw new Exception('Could not find private key file "' .
$keyFile . '".');
}
@@ -178,7 +168,7 @@
public function loadCertificate($file) {
assert('is_string($file)');
- $certFile = self::$certDir . $file;
+ $certFile = SimpleSAML_Utilities::resolveCert($file);
if (!file_exists($certFile)) {
throw new Exception('Could not find certificate file "' .
$certFile . '".');
}
@@ -213,7 +203,7 @@
public function addCertificate($file) {
assert('is_string($file)');
- $certFile = self::$certDir . $file;
+ $certFile = SimpleSAML_Utilities::resolveCert($file);
if (!file_exists($certFile)) {
throw new Exception('Could not find extra certificate file "' .
$certFile . '".');
}
=======================================
--- /trunk/modules/adfs/lib/IdP/ADFS.php Sun Feb 14 11:38:59 2010
+++ /trunk/modules/adfs/lib/IdP/ADFS.php Fri Mar 26 03:14:37 2010
@@ -156,9 +156,9 @@
$response = sspmod_adfs_IdP_ADFS::ADFS_GenerateResponse($idpEntityId,
$spEntityId, $nameid, $attributes);
- $config = SimpleSAML_Configuration::getInstance();
- $certdir = $config->getPathValue('certdir', 'cert/');
- $wresult = sspmod_adfs_IdP_ADFS::ADFS_SignResponse($response, $certdir .
$idpMetadata->getString('privatekey'), $certdir .
$idpMetadata->getString('certificate'));
+ $privateKeyFile =
SimpleSAML_Utilities::resolveCert($idpMetadata->getString('privatekey'));
+ $certificateFile =
SimpleSAML_Utilities::resolveCert($idpMetadata->getString('certificate'));
+ $wresult = sspmod_adfs_IdP_ADFS::ADFS_SignResponse($response,
$privateKeyFile, $certificateFile);
$wctx = $state['adfs:wctx'];
sspmod_adfs_IdP_ADFS::ADFS_PostResponse($spMetadata->getValue('prp'),
$wresult, $wctx);
=======================================
--- /trunk/modules/saml2/lib/Message.php Thu Jan 28 00:17:39 2010
+++ /trunk/modules/saml2/lib/Message.php Fri Mar 26 03:14:37 2010
@@ -164,8 +164,7 @@
'Missing certificate in metadata for ' .
var_export($srcMetadata->getString('entityid'), TRUE));
}
- $globalConfig = SimpleSAML_Configuration::getInstance();
- $caFile = $globalConfig->getPathValue('certdir',
'cert/') . $caFile;
+ $caFile = SimpleSAML_Utilities::resolveCert($caFile);
if (count($certificates) === 0) {
/* We need the full certificate in order to check it against the CA
file. */
=======================================
--- /trunk/www/wsfed/sp/prp.php Fri Aug 14 04:07:44 2009
+++ /trunk/www/wsfed/sp/prp.php Fri Mar 26 03:14:37 2010
@@ -78,7 +78,7 @@
/* Find the certificate used by the IdP. */
if(array_key_exists('certificate', $idpMetadata)) {
- $certFile = $config->getPathvalue('certdir', 'cert/') .
$idpMetadata['certificate'];
+ SimpleSAML_Utilities::resolveCert($idpMetadata['certificate']);
} else {
throw new Exception('Missing \'certificate\' metadata option in the
\'wsfed-idp-remote\' metadata' .
' for the IdP \'' . $idpEntityId . '\'.');
--
You received this message because you are subscribed to the Google Groups
"simpleSAMLphp commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/simplesamlphp-commits?hl=en.