/**
  * Carga las claves Públicas y Privadas para las funciones de Cifrado/Descifrado
  * @throws Excepciones\Excepcion
  */
 private function CargarKeys()
 {
     //Busca los certificados en la ruta enviada
     if (!file_exists($this->ApiCertificados . "CriptoPay_ApiCert_" . $this->ApiId . ".crt")) {
         Log::Debug("No se encuentra " . $this->ApiCertificados . "CriptoPay_ApiCert_" . $this->ApiId . ".crt");
         throw new Excepciones\Excepcion("Falta el certificado público");
         return false;
     }
     if (!file_exists($this->ApiCertificados . "CriptoPay_ApiKey_" . $this->ApiId . ".key")) {
         Log::Debug("No se encuentra " . $this->ApiCertificados . "CriptoPay_ApiCert_" . $this->ApiId . ".crt");
         throw new Excepciones\Excepcion("Falta el certificado privado");
         return false;
     }
     $fp = fopen($this->ApiCertificados . "CriptoPay_ApiCert_" . $this->ApiId . ".crt", "r");
     $pub_key = fread($fp, 8192);
     fclose($fp);
     self::$KeyPublica = openssl_get_publickey($pub_key);
     if (!self::$KeyPublica) {
         if (DEBUG) {
             throw new Excepciones\Excepcion("El certificado cliente es inválido");
         }
         return false;
     }
     $fp = fopen($this->ApiCertificados . "CriptoPay_ApiKey_" . $this->ApiId . ".key", "r");
     $priv_key = fread($fp, 8192);
     fclose($fp);
     self::$KeyPrivada = openssl_get_privatekey($priv_key, $this->ApiPassword);
     if (!self::$KeyPrivada) {
         if (DEBUG) {
             throw new Excepciones\Excepcion("El certificado privado o la clave es inválido");
         }
         return false;
     }
     return true;
 }
Exemplo n.º 2
0
 public function __construct($message, $code = null, $previous = null)
 {
     Comun\Log::Critical($message);
     parent::__construct($message, $code, $previous);
 }