7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
24 * @see Zend_Crypt_Rsa_Key
26 require_once 'Zend/Crypt/Rsa/Key.php';
31 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
32 * @license http://framework.zend.com/license/new-bsd New BSD License
34 class Zend_Crypt_Rsa_Key_Public extends Zend_Crypt_Rsa_Key
37 protected $_certificateString = null;
39 public function __construct($string)
41 $this->_parse($string);
45 * @param string $string
46 * @throws Zend_Crypt_Exception
48 protected function _parse($string)
50 if (preg_match("/^-----BEGIN CERTIFICATE-----/", $string)) {
51 $this->_certificateString = $string;
53 $this->_pemString = $string;
55 $result = openssl_get_publickey($string);
58 * @see Zend_Crypt_Exception
60 require_once 'Zend/Crypt/Exception.php';
61 throw new Zend_Crypt_Exception('Unable to load public key');
63 //openssl_pkey_export($result, $public);
64 //$this->_pemString = $public;
65 $this->_opensslKeyResource = $result;
66 $this->_details = openssl_pkey_get_details($this->_opensslKeyResource);
69 public function getCertificate()
71 return $this->_certificateString;