public function sign(SignatureAlgorithmIdentifier $algo,
        PrivateKeyInfo $privkey_info, Crypto $crypto = null): Certificate
    {
        $crypto = $crypto ?: Crypto::getDefault();
        $tbs_cert = clone $this;
        if (!isset($tbs_cert->_version)) {
            $tbs_cert->_version = $tbs_cert->_determineVersion();
        }
        if (!isset($tbs_cert->_serialNumber)) {
            $tbs_cert->_serialNumber = strval(0);
        }
        $tbs_cert->_signature = $algo;
        $data = $tbs_cert->toASN1()->toDER();
        $signature = $crypto->sign($data, $privkey_info, $algo);
        return new Certificate($tbs_cert, $algo, $signature);
    }
public function sign(SignatureAlgorithmIdentifier $algo,
        PrivateKeyInfo $privkey_info, Crypto $crypto = null): Certificate
    {
        $crypto = $crypto ?: Crypto::getDefault();
        $tbs_cert = clone $this;
        if (!isset($tbs_cert->_version)) {
            $tbs_cert->_version = $tbs_cert->_determineVersion();
        }
        if (!isset($tbs_cert->_serialNumber)) {
            $tbs_cert->_serialNumber = strval(0);
        }
        $tbs_cert->_signature = $algo;
        $data = $tbs_cert->toASN1()->toDER();
        $signature = $crypto->sign($data, $privkey_info, $algo);
        return new Certificate($tbs_cert, $algo, $signature);
    }
public function sign ( SignatureAlgorithmIdentifier $ algo , PrivateKeyInfo $ privkey_info , Crypto $ crypto = null ) : Certificate { $ crypto = $ crypto ? : Crypto :: getDefault ( ) ; $ tbs_cert = clone $ this ; if ( ! isset ( $ tbs_cert -> _version ) ) { $ tbs_cert -> _version = $ tbs_cert -> _determineVersion ( ) ; } if ( ! isset ( $ tbs_cert -> _serialNumber ) ) { $ tbs_cert -> _serialNumber = strval ( 0 ) ; } $ tbs_cert -> _signature = $ algo ; $ data = $ tbs_cert -> toASN1 ( ) -> toDER ( ) ; $ signature = $ crypto -> sign ( $ data , $ privkey_info , $ algo ) ; return new Certificate ( $ tbs_cert , $ algo , $ signature ) ; }
Create signed certificate.

@param SignatureAlgorithmIdentifier $algo Algorithm used for signing
@param PrivateKeyInfo $privkey_info Private key used for signing
@param Crypto|null $crypto Crypto engine, use default if not set
@return Certificate
Create signed certificate .