def _sign_csr(csr_text, ca_folder):
    with utils.tempdir() as tmpdir:
        inbound = os.path.join(tmpdir, 'inbound.csr')
        outbound = os.path.join(tmpdir, 'outbound.csr')

        try:
            with open(inbound, 'w') as csrfile:
                csrfile.write(csr_text)
        except __HOLE__:
            with excutils.save_and_reraise_exception():
                LOG.exception(_LE('Failed to write inbound.csr'))

        LOG.debug('Flags path: %s', ca_folder)

        # Change working dir to CA
        fileutils.ensure_tree(ca_folder)
        utils.execute('openssl', 'ca', '-batch', '-out', outbound, '-config',
                      './openssl.cnf', '-infiles', inbound, cwd=ca_folder)
        out, _err = utils.execute('openssl', 'x509', '-in', outbound,
                                  '-serial', '-noout', cwd=ca_folder)
        serial = out.rpartition('=')[2].strip()

        with open(outbound, 'r') as crtfile:
            return (serial, crtfile.read())
dataset/ETHPy150Open openstack/nova/nova/crypto.py/_sign_csr