function signCSR($signatureAlgorithm = 'sha1WithRSAEncryption')
    {
        if (!is_object($this->privateKey) || empty($this->dn)) {
            return false;
        }

        $origPublicKey = $this->publicKey;
        $class = get_class($this->privateKey);
        $this->publicKey = new $class();
        $this->publicKey->loadKey($this->privateKey->getPublicKey());
        $this->publicKey->setPublicKey();
        if (!($publicKey = $this->_formatSubjectPublicKey())) {
            return false;
        }
        $this->publicKey = $origPublicKey;

        $currentCert = isset($this->currentCert) ? $this->currentCert : NULL;
        $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject: NULL;

        if (isset($this->currentCert) && is_array($this->currentCert) && isset($this->currentCert['certificationRequestInfo'])) {
            $this->currentCert['signatureAlgorithm']['algorithm'] =
                $signatureAlgorithm;
            if (!empty($this->dn)) {
                $this->currentCert['certificationRequestInfo']['subject'] = $this->dn;
            }
            $this->currentCert['certificationRequestInfo']['subjectPKInfo'] = $publicKey;
        } else {
            $this->currentCert = array(
                'certificationRequestInfo' =>
                    array(
                        'version' => 'v1',
                        'subject' => $this->dn,
                        'subjectPKInfo' => $publicKey
                    ),
                'signatureAlgorithm' => array('algorithm' => $signatureAlgorithm),
                'signature'          => false // this is going to be overwritten later
            );
        }

        // resync $this->signatureSubject
        // save $certificationRequestInfo in case there are any File_ASN1_Element objects in it
        $certificationRequestInfo = $this->currentCert['certificationRequestInfo'];
        $this->loadCSR($this->saveCSR($this->currentCert));

        $result = $this->_sign($this->privateKey, $signatureAlgorithm);
        $result['certificationRequestInfo'] = $certificationRequestInfo;

        $this->currentCert = $currentCert;
        $this->signatureSubject = $signatureSubject;

        return $result;
    }
function signCSR($signatureAlgorithm = 'sha1WithRSAEncryption')
    {
        if (!is_object($this->privateKey) || empty($this->dn)) {
            return false;
        }

        $origPublicKey = $this->publicKey;
        $class = get_class($this->privateKey);
        $this->publicKey = new $class();
        $this->publicKey->loadKey($this->privateKey->getPublicKey());
        $this->publicKey->setPublicKey();
        if (!($publicKey = $this->_formatSubjectPublicKey())) {
            return false;
        }
        $this->publicKey = $origPublicKey;

        $currentCert = isset($this->currentCert) ? $this->currentCert : NULL;
        $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject: NULL;

        if (isset($this->currentCert) && is_array($this->currentCert) && isset($this->currentCert['certificationRequestInfo'])) {
            $this->currentCert['signatureAlgorithm']['algorithm'] =
                $signatureAlgorithm;
            if (!empty($this->dn)) {
                $this->currentCert['certificationRequestInfo']['subject'] = $this->dn;
            }
            $this->currentCert['certificationRequestInfo']['subjectPKInfo'] = $publicKey;
        } else {
            $this->currentCert = array(
                'certificationRequestInfo' =>
                    array(
                        'version' => 'v1',
                        'subject' => $this->dn,
                        'subjectPKInfo' => $publicKey
                    ),
                'signatureAlgorithm' => array('algorithm' => $signatureAlgorithm),
                'signature'          => false // this is going to be overwritten later
            );
        }

        // resync $this->signatureSubject
        // save $certificationRequestInfo in case there are any File_ASN1_Element objects in it
        $certificationRequestInfo = $this->currentCert['certificationRequestInfo'];
        $this->loadCSR($this->saveCSR($this->currentCert));

        $result = $this->_sign($this->privateKey, $signatureAlgorithm);
        $result['certificationRequestInfo'] = $certificationRequestInfo;

        $this->currentCert = $currentCert;
        $this->signatureSubject = $signatureSubject;

        return $result;
    }
function signCSR ( $ signatureAlgorithm = 'sha1WithRSAEncryption' ) { if ( ! is_object ( $ this -> privateKey ) || empty ( $ this -> dn ) ) { return false ; } $ origPublicKey = $ this -> publicKey ; $ class = get_class ( $ this -> privateKey ) ; $ this -> publicKey = new $ class ( ) ; $ this -> publicKey -> loadKey ( $ this -> privateKey -> getPublicKey ( ) ) ; $ this -> publicKey -> setPublicKey ( ) ; if ( ! ( $ publicKey = $ this -> _formatSubjectPublicKey ( ) ) ) { return false ; } $ this -> publicKey = $ origPublicKey ; $ currentCert = isset ( $ this -> currentCert ) ? $ this -> currentCert : NULL ; $ signatureSubject = isset ( $ this -> signatureSubject ) ? $ this -> signatureSubject : NULL ; if ( isset ( $ this -> currentCert ) && is_array ( $ this -> currentCert ) && isset ( $ this -> currentCert [ 'certificationRequestInfo' ] ) ) { $ this -> currentCert [ 'signatureAlgorithm' ] [ 'algorithm' ] = $ signatureAlgorithm ; if ( ! empty ( $ this -> dn ) ) { $ this -> currentCert [ 'certificationRequestInfo' ] [ 'subject' ] = $ this -> dn ; } $ this -> currentCert [ 'certificationRequestInfo' ] [ 'subjectPKInfo' ] = $ publicKey ; } else { $ this -> currentCert = array ( 'certificationRequestInfo' => array ( 'version' => 'v1' , 'subject' => $ this -> dn , 'subjectPKInfo' => $ publicKey ) , 'signatureAlgorithm' => array ( 'algorithm' => $ signatureAlgorithm ) , 'signature' => false // this is going to be overwritten later
 ) ; } // resync $this->signatureSubject
 // save $certificationRequestInfo in case there are any File_ASN1_Element objects in it
 $ certificationRequestInfo = $ this -> currentCert [ 'certificationRequestInfo' ] ; $ this -> loadCSR ( $ this -> saveCSR ( $ this -> currentCert ) ) ; $ result = $ this -> _sign ( $ this -> privateKey , $ signatureAlgorithm ) ; $ result [ 'certificationRequestInfo' ] = $ certificationRequestInfo ; $ this -> currentCert = $ currentCert ; $ this -> signatureSubject = $ signatureSubject ; return $ result ; }
Sign a CSR

@access public
@return Mixed
Sign a CSR