Public.php 996 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. require_once 'Zend/Crypt/Rsa/Key.php';
  3. class Zend_Crypt_Rsa_Key_Public extends Zend_Crypt_Rsa_Key
  4. {
  5. protected $_certificateString = null;
  6. public function __construct($string)
  7. {
  8. $this->_parse($string);
  9. }
  10. protected function _parse($string)
  11. {
  12. if (preg_match("/^-----BEGIN CERTIFICATE-----/", $string)) {
  13. $this->_certificateString = $string;
  14. } else {
  15. $this->_pemString = $string;
  16. }
  17. $result = openssl_get_publickey($string);
  18. if (!$result) {
  19. require_once 'Zend/Crypt/Exception.php';
  20. throw new Zend_Crypt_Exception('Unable to load public key');
  21. }
  22. //openssl_pkey_export($result, $public);
  23. //$this->_pemString = $public;
  24. $this->_opensslKeyResource = $result;
  25. $this->_details = openssl_pkey_get_details($this->_opensslKeyResource);
  26. }
  27. public function getCertificate()
  28. {
  29. return $this->_certificateString;
  30. }
  31. }