def create(cls, csr, duration, package, altnames=None, dcv_method=None):
        """ Create a new certificate. """
        params = {'csr': csr, 'package': package, 'duration': duration}
        if altnames:
            params['altnames'] = altnames
        if dcv_method:
            params['dcv_method'] = dcv_method

        try:
            result = cls.call('cert.create', params)
        except UsageError:
            params['--dry-run'] = True
            msg = '\n'.join(['%s (%s)' % (err['reason'], err['attr'])
                             for err in cls.call('cert.create', params)])
            cls.error(msg)
            raise

        if dcv_method in ('dns', 'file'):
            cls.advice_dcv_method(csr, package, altnames, dcv_method,
                                  cert_id=result['params'].get('cert_id'))
        return result
Create a new certificate.