This functions finds what key & certificate files should be used to sign the metadata for the given entity. 
   26    {
   27        
   28        if (array_key_exists('metadata.sign.privatekey', $entityMetadata)
   29            || array_key_exists('metadata.sign.certificate', $entityMetadata)
   30        ) {
   31            if (!array_key_exists('metadata.sign.privatekey', $entityMetadata)
   32                || !array_key_exists('metadata.sign.certificate', $entityMetadata)
   33            ) {
   34                throw new Exception(
   35                    'Missing either the "metadata.sign.privatekey" or the'.
   36                    ' "metadata.sign.certificate" configuration option in the metadata for'.
   37                    ' the '.
$type.
' "'.$entityMetadata[
'entityid'].
'". If one of'.
 
   38                    ' these options is specified, then the other must also be specified.'
   39                );
   40            }
   41 
   43                'privatekey'  => $entityMetadata['metadata.sign.privatekey'],
   44                'certificate' => $entityMetadata['metadata.sign.certificate']
   45            );
   46 
   47            if (array_key_exists('metadata.sign.privatekey_pass', $entityMetadata)) {
   48                $ret[
'privatekey_pass'] = $entityMetadata[
'metadata.sign.privatekey_pass'];
 
   49            }
   50 
   52        }
   53 
   54        
   55        $privatekey = 
$config->getString(
'metadata.sign.privatekey', 
null);
 
   59                throw new Exception(
   60                    'Missing either the "metadata.sign.privatekey" or the'.
   61                    ' "metadata.sign.certificate" configuration option in the global'.
   62                    ' configuration. If one of these options is specified, then the other'.
   63                    ' must also be specified.'
   64                );
   65            }
   67 
   68            $privatekey_pass = 
$config->getString(
'metadata.sign.privatekey_pass', 
null);
 
   69            if ($privatekey_pass !== null) {
   70                $ret[
'privatekey_pass'] = $privatekey_pass;
 
   71            }
   72 
   74        }
   75 
   76        
   77        if (array_key_exists('privatekey', $entityMetadata)
   78            || array_key_exists('certificate', $entityMetadata)
   79        ) {
   80            if (!array_key_exists('privatekey', $entityMetadata)
   81                || !array_key_exists('certificate', $entityMetadata)
   82            ) {
   83                throw new Exception(
   84                    'Both the "privatekey" and the "certificate" option must'.
   85                    ' be set in the metadata for the '.
$type.
' "'.
 
   86                    $entityMetadata['entityid'].'" before it is possible to sign metadata'.
   87                    ' from this entity.'
   88                );
   89            }
   90 
   92                'privatekey'  => $entityMetadata['privatekey'],
   93                'certificate' => $entityMetadata['certificate']
   94            );
   95 
   96            if (array_key_exists('privatekey_pass', $entityMetadata)) {
   97                $ret[
'privatekey_pass'] = $entityMetadata[
'privatekey_pass'];
 
   98            }
   99 
  101        }
  102 
  103        throw new Exception(
  104            'Could not find what key & certificate should be used to sign the metadata'.
  105            ' for the '.
$type.
' "'.$entityMetadata[
'entityid'].
'".' 
  106        );
  107    }
if(@file_exists(dirname(__FILE__).'/lang/eng.php')) $certificate