'Saves the certificate received from the ACME server.
:param certr: ACME "certificate" resource.
:type certr: :class:`acme.messages.Certificate`
:param list chain_cert:
:param str cert_path: Candidate path to a certificate.
:param str chain_path: Candidate path to a certificate chain.
:param str fullchain_path: Candidate path to a full cert chain.
:returns: cert_path, chain_path, and fullchain_path as absolute
paths to the actual files
:rtype: `tuple` of `str`
:raises IOError: If unable to find room to write the cert files'

def save_certificate(self, certr, chain_cert, cert_path, chain_path, fullchain_path):

    for path in (cert_path, chain_path, fullchain_path):
        util.make_or_verify_dir(os.path.dirname(path), 493, os.geteuid(), self.config.strict_permissions)
    cert_pem = OpenSSL.crypto.dump_certificate(OpenSSL.crypto.FILETYPE_PEM, certr.body.wrapped)
    (cert_file, abs_cert_path) = _open_pem_file('cert_path', cert_path)
    try:
        cert_file.write(cert_pem)
    finally:
        cert_file.close()
    logger.info('Server    issued    certificate;    certificate    written    to    %s', abs_cert_path)
    if (not chain_cert):
        return (abs_cert_path, None, None)
    else:
        chain_pem = crypto_util.dump_pyopenssl_chain(chain_cert)
        (chain_file, abs_chain_path) = _open_pem_file('chain_path', chain_path)
        (fullchain_file, abs_fullchain_path) = _open_pem_file('fullchain_path', fullchain_path)
        _save_chain(chain_pem, chain_file)
        _save_chain((cert_pem + chain_pem), fullchain_file)
        return (abs_cert_path, abs_chain_path, abs_fullchain_path)
