| @@ 67-84 (lines=18) @@ | ||
| 64 | * |
|
| 65 | * @return resource |
|
| 66 | */ |
|
| 67 | public function getRsaPublicKey() |
|
| 68 | { |
|
| 69 | if ($this->rsaPublicKey) { |
|
| 70 | return $this->rsaPublicKey; |
|
| 71 | } |
|
| 72 | ||
| 73 | if (!file_exists($this->rsaPublicKeyFile)) { |
|
| 74 | throw new CredentialsException('Could not read the public key file.'); |
|
| 75 | } |
|
| 76 | ||
| 77 | $this->rsaPublicKey = openssl_get_publickey(file_get_contents($this->rsaPublicKeyFile)); |
|
| 78 | ||
| 79 | if (!$this->rsaPublicKey) { |
|
| 80 | throw new CredentialsException('Cannot access public key for signing'); |
|
| 81 | } |
|
| 82 | ||
| 83 | return $this->rsaPublicKey; |
|
| 84 | } |
|
| 85 | ||
| 86 | /** |
|
| 87 | * Gets the RSA private key. |
|
| @@ 93-110 (lines=18) @@ | ||
| 90 | * |
|
| 91 | * @return resource |
|
| 92 | */ |
|
| 93 | public function getRsaPrivateKey() |
|
| 94 | { |
|
| 95 | if ($this->rsaPrivateKey) { |
|
| 96 | return $this->rsaPrivateKey; |
|
| 97 | } |
|
| 98 | ||
| 99 | if (!file_exists($this->rsaPrivateKeyFile)) { |
|
| 100 | throw new CredentialsException('Could not read the private key file.'); |
|
| 101 | } |
|
| 102 | ||
| 103 | $this->rsaPrivateKey = openssl_pkey_get_private(file_get_contents($this->rsaPrivateKeyFile)); |
|
| 104 | ||
| 105 | if (!$this->rsaPrivateKey) { |
|
| 106 | throw new CredentialsException('Cannot access private key for signing'); |
|
| 107 | } |
|
| 108 | ||
| 109 | return $this->rsaPrivateKey; |
|
| 110 | } |
|
| 111 | ||
| 112 | public function __destruct() |
|
| 113 | { |
|