'Returns an (cert, privkey, cert_chain) tuple.
commonname: Common name for the generated certificate. Must be a
valid, plain-ASCII, IDNA-encoded domain name.
sans: A list of Subject Alternate Names.'

def get_cert(self, commonname, sans):

    potential_keys = self.asterisk_forms(commonname)
    for s in sans:
        potential_keys.extend(self.asterisk_forms(s))
    potential_keys.append((commonname, tuple(sans)))
    name = next(filter((lambda key: (key in self.certs)), potential_keys), None)
    if name:
        entry = self.certs[name]
    else:
        entry = CertStoreEntry(cert=dummy_cert(self.default_privatekey, self.default_ca, commonname, sans), privatekey=self.default_privatekey, chain_file=self.default_chain_file)
        self.certs[(commonname, tuple(sans))] = entry
        self.expire(entry)
    return (entry.cert, entry.privatekey, entry.chain_file)
