Пример #1
0
    def activate_ssl(self, name, domain, plugin='default'):
        lb = LoadBalancer.find(name)
        if lb is None:
            raise storage.InstanceNotFoundError()

        if not self._check_dns(name, domain):
            raise SslError('rpaas IP is not registered for this DNS name')

        key = ssl.generate_key()
        csr = ssl.generate_csr(key, domain)

        if plugin == 'le':
            try:
                self.task_manager.create(name)
                task = tasks.DownloadCertTask().delay(self.config, name, plugin, csr, key, domain)
                self.task_manager.update(name, task.task_id)
                return ''
            except Exception:
                raise SslError('rpaas IP is not registered for this DNS name')

        else:
            p_ssl = ssl_plugins.default.Default(domain)
            cert = p_ssl.download_crt(key=key)
            self.update_certificate(name, cert, key)
            return ''
Пример #2
0
    def activate_ssl(self, name, domain, plugin='default'):
        lb = LoadBalancer.find(name)
        if lb is None:
            raise storage.InstanceNotFoundError()

        # Check if DNS is registered for rpaas ip
        if not self._check_dns(name, domain):
            raise SslError('rpaas IP is not registered for this DNS name')

        # Key and CSR generated to request a certificate
        key = self._generate_key()
        csr = self._generate_csr(key, domain)

        # load plugin if get it as an arg
        if plugin.isalpha() and plugin in rpaas.ssl_plugins.__all__ and \
           plugin not in ['default', '__init__']:

            try:
                self.storage.store_task(name)
                task = tasks.DownloadCertTask().delay(self.config, name,
                                                      plugin, csr, key, domain)
                self.storage.update_task(name, task.task_id)
                return ''
            except Exception:
                raise SslError('rpaas IP is not registered for this DNS name')

        else:
            # default
            p_ssl = rpaas.ssl_plugins.default.Default(domain)
            cert = p_ssl.download_crt(key=key)
            self.update_certificate(name, cert, key)
            return ''