Exemple #1
0
    /**
     * Set PEM string
     *
     * @param string $value
     * @return RsaOptions
     */
    public function setPemString($value)
    {
        $this->pemString = $value;

        try {
            $this->privateKey = new Rsa\PrivateKey($this->pemString, $this->passPhrase);
            $this->publicKey  = $this->privateKey->getPublicKey();
        } catch (Rsa\Exception\RuntimeException $e) {
            $this->privateKey = null;
            $this->publicKey  = new Rsa\PublicKey($this->pemString);
        }

        return $this;
    }
Exemple #2
0
 /**
  * Set private key
  *
  * @param  Rsa\PrivateKey $key
  * @return RsaOptions
  */
 public function setPrivateKey(Rsa\PrivateKey $key)
 {
     $this->privateKey = $key;
     $this->publicKey = $this->privateKey->getPublicKey();
     return $this;
 }