function signAssertion($responseXmlString,$privKey,$cert) 
   {
      if (file_exists("/tmp/xml")) {
         $tempFileDir="/tmp/xml/";          
      
      } else {
             mkdir("/tmp/xml",0777);   
         $tempFileDir="/tmp/xml/";
      }
      $tempName = 'saml-response-' . $this->samlCreateId() . '.xml';
      $tempFileName=$tempFileDir.$tempName;
      while (file_exists($tempFileName)) 
         $tempFileName = 'saml-response-' . $this->samlCreateId() . '.xml';

      if (!$handle = fopen($tempFileName, 'w')) {
         return null;
      }
      if (fwrite($handle, $responseXmlString) === false) {
         return null;
      }
      fclose($handle);
      $cmd = 'xmlsec1 --sign --privkey-pem ' . $privKey . 
         ',' . $cert . ' --output ' . $tempFileName . 
         '.out ' . $tempFileName;
      exec($cmd, $resp);
      unlink($tempFileName);

      $xmlResult = @file_get_contents($tempFileName . '.out');
      if (!$xmlResult) { 
         return null;
      } else {
         unlink($tempFileName . '.out');
         return $xmlResult;
      }
   }