def generate_and_save_cert(iot, cert_filename, private_key_filename):
    """Create, activate and save an AWS IoT certificate.

    :param iot: IoT session client
    :param str cert_filename: Name of the certificate file
    :param str private_key_filename: Name of the certificate's private key file
    """
    response = iot.create_keys_and_certificate(setAsActive=True)

    with open(cert_filename, 'w') as f:
        f.write(response['certificatePem'])

    with open(private_key_filename, 'w') as f:
        f.write(response['keyPair']['PrivateKey'])

    return response['certificateArn']