def upload_certificate(self): cert_file = os.path.expanduser( self.cloudify_agent['agent_rest_cert_path']) cert_content = self.rest_cert_content if not os.path.exists(cert_file): cert_dir = os.path.dirname(cert_file) if not os.path.exists(cert_dir): utils.safe_create_dir(cert_dir) with open(cert_file, 'wb') as f: f.write(cert_content)
def _create_broker_ssl_cert(agent): """ Put the broker SSL cert into a file for AMQP clients to use, if broker_ssl_cert is set. """ click.echo('Deploying broker SSL certificate (if defined).') broker_ssl_cert_content = agent['broker_ssl_cert'] if broker_ssl_cert_content: broker_ssl_cert_path = \ os.path.expanduser(agent['broker_ssl_cert_path']) agent['broker_ssl_cert_path'] = broker_ssl_cert_path api_utils.safe_create_dir(os.path.dirname(broker_ssl_cert_path)) with open(broker_ssl_cert_path, 'w') as broker_cert_file: broker_cert_file.write(broker_ssl_cert_content)
def _create_rest_ssl_cert(agent): """ put the REST SSL cert into a file for clients to use, if rest_cert_content is set. """ click.echo('Deploying REST SSL certificate (if defined).') rest_cert_content = agent['rest_cert_content'] if rest_cert_content and agent['verify_rest_certificate']: local_rest_cert_file = \ os.path.expanduser(agent['local_rest_cert_file']) agent['local_rest_cert_file'] = local_rest_cert_file api_utils.safe_create_dir(os.path.dirname(local_rest_cert_file)) with open(local_rest_cert_file, 'w') as rest_cert_file: rest_cert_file.write(rest_cert_content)