'Obtains a certificate from the ACME server.
`.register` must be called before `.obtain_certificate`
:param list domains: domains to get a certificate
:returns: `.CertificateResource`, certificate chain (as
returned by `.fetch_chain`), and newly generated private key
(`.util.Key`) and DER-encoded Certificate Signing Request
(`.util.CSR`).
:rtype: tuple'

def obtain_certificate(self, domains):

    authzr = self.auth_handler.get_authorizations(domains, self.config.allow_subset_of_names)
    auth_domains = set((a.body.identifier.value for a in authzr))
    domains = [d for d in domains if (d in auth_domains)]
    if self.config.dry_run:
        key = util.Key(file=None, pem=crypto_util.make_key(self.config.rsa_key_size))
        csr = util.CSR(file=None, form='pem', data=acme_crypto_util.make_csr(key.pem, domains, self.config.must_staple))
    else:
        key = crypto_util.init_save_key(self.config.rsa_key_size, self.config.key_dir)
        csr = crypto_util.init_save_csr(key, domains, self.config.csr_dir)
    (certr, chain) = self.obtain_certificate_from_csr(domains, csr, authzr=authzr)
    return (certr, chain, key, csr)
