public function testCertificatePairs() { $infoCard = new Zend_InfoCard(); $key_id = $infoCard->addCertificatePair($this->sslPrvKey, $this->sslPubKey); $this->assertTrue((bool)$key_id); $key_pair = $infoCard->getCertificatePair($key_id); $this->assertTrue(!empty($key_pair['public'])); $this->assertTrue(!empty($key_pair['private'])); $this->assertTrue(!empty($key_pair['type_uri'])); $infoCard->removeCertificatePair($key_id); $failed = false; try { $key_pair = $infoCard->getCertificatePair($key_id); } catch(Zend_InfoCard_Exception $e) { $failed = true; } $this->assertTrue($failed); try { $infoCard->addCertificatePair("I don't exist", "I don't exist"); } catch(Zend_InfoCard_Exception $e) { $this->assertTrue(true); } catch(Exception $e) { $this->assertFalse(true); } $key_id = $infoCard->addCertificatePair($this->sslPrvKey, $this->sslPubKey, Zend_InfoCard_Cipher::ENC_RSA_OAEP_MGF1P, "foo"); try { $key_id = $infoCard->addCertificatePair($this->sslPrvKey, $this->sslPubKey, Zend_InfoCard_Cipher::ENC_RSA_OAEP_MGF1P, "foo"); } catch(Zend_InfoCard_Exception $e) { $this->assertTrue(true); } catch(Exception $e) { $this->assertFalse(true); } $this->assertTrue(!empty($key_id)); try { $infoCard->removeCertificatePair($key_id); $infoCard->addCertificatePair($this->sslPrvKey, $this->sslPubKey, "Doesn't Exist", "foo"); } catch(Zend_InfoCard_Exception $e) { $this->assertTrue(true); } catch(Exception $e) { $this->assertFalse(true); } }
public function testCertificatePairs() { try { $infoCard = new Zend_InfoCard(); } catch (Zend_InfoCard_Exception $e) { $message = $e->getMessage(); if (preg_match('/requires.+mcrypt/', $message)) { $this->markTestSkipped($message); } else { throw $e; } } $key_id = $infoCard->addCertificatePair($this->sslPrvKey, $this->sslPubKey); $this->assertTrue((bool) $key_id); $key_pair = $infoCard->getCertificatePair($key_id); $this->assertTrue(!empty($key_pair['public'])); $this->assertTrue(!empty($key_pair['private'])); $this->assertTrue(!empty($key_pair['type_uri'])); $infoCard->removeCertificatePair($key_id); $failed = false; try { $key_pair = $infoCard->getCertificatePair($key_id); } catch (Zend_InfoCard_Exception $e) { $failed = true; } $this->assertTrue($failed); try { $infoCard->addCertificatePair("I don't exist", "I don't exist"); } catch (Zend_InfoCard_Exception $e) { $this->assertTrue(true); } catch (Exception $e) { $this->assertFalse(true); } $key_id = $infoCard->addCertificatePair($this->sslPrvKey, $this->sslPubKey, Zend_InfoCard_Cipher::ENC_RSA_OAEP_MGF1P, "foo"); try { $key_id = $infoCard->addCertificatePair($this->sslPrvKey, $this->sslPubKey, Zend_InfoCard_Cipher::ENC_RSA_OAEP_MGF1P, "foo"); } catch (Zend_InfoCard_Exception $e) { $this->assertTrue(true); } catch (Exception $e) { $this->assertFalse(true); } $this->assertTrue(!empty($key_id)); try { $infoCard->removeCertificatePair($key_id); $infoCard->addCertificatePair($this->sslPrvKey, $this->sslPubKey, "Doesn't Exist", "foo"); } catch (Zend_InfoCard_Exception $e) { $this->assertTrue(true); } catch (Exception $e) { $this->assertFalse(true); } }
/** * Return a Certificate Pair from a key ID * * @param string $key_id The Key ID of the certificate pair in the component * @throws Zend_InfoCard_Exception * @return array An array containing the path to the private/public key files, * the type URI and the password if provided */ public function getCertificatePair($key_id) { return $this->_infoCard->getCertificatePair($key_id); }