def write_certificates(environment):
    """Write SSL certificate to files

    If certificates are specified, they are written, otherwise
    dummy certificates are generated and written"""

    ssl_keys = ['SSL_CERTIFICATE', 'SSL_PRIVATE_KEY']
    if set(environment) <= set(ssl_keys):
        for k in ssl_keys:
            with open(environment[k + '_FILE'], 'w') as f:
                f.write(environment[k])
    else:
        openssl_cmd = [
            '/usr/bin/openssl',
            'req',
            '-nodes',
            '-new',
            '-x509',
            '-subj',
            '/CN=spilo.dummy.org',
            '-keyout',
            environment['SSL_PRIVATE_KEY_FILE'],
            '-out',
            environment['SSL_CERTIFICATE_FILE'],
        ]
        logging.info('Generating ssl certificate')
        p = subprocess.Popen(openssl_cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
        output, _ = p.communicate()
        logging.debug(output)

    os.chmod(environment['SSL_PRIVATE_KEY_FILE'], 0o600)
dataset/ETHPy150Open zalando/spilo/postgres-appliance/postgres_ha.py/write_certificates/swapped operands of `<=`