'Given a blob of certificate request data and a certificate authority\'s
DistinguishedName, return a blob of signed certificate data.
If verifyDNCallback returns a Deferred, I will return a Deferred which
fires the data when that Deferred has completed.'

def signCertificateRequest(self, issuerDistinguishedName, requestData, verifyDNCallback, serialNumber, requestFormat=crypto.FILETYPE_ASN1, certificateFormat=crypto.FILETYPE_ASN1, secondsToExpiry=(((60 * 60) * 24) * 365), digestAlgorithm='sha256'):

    hlreq = CertificateRequest.load(requestData, requestFormat)
    dn = hlreq.getSubject()
    vval = verifyDNCallback(dn)
    def verified(value):
        if (not value):
            raise VerifyError(('DN    callback    %r    rejected    request    DN    %r' % (verifyDNCallback, dn)))
        return self.signRequestObject(issuerDistinguishedName, hlreq, serialNumber, secondsToExpiry, digestAlgorithm).dump(certificateFormat)
    if isinstance(vval, Deferred):
        return vval.addCallback(verified)
    else:
        return verified(vval)
