Пример #1
0
async def run_relay(config, path, class_, config_name):
    config_section = config[config_name]

    challenge_solver = await create_challenge_solver(
        config_section["client"]["challenge_solver"])
    challenge_validator = await create_challenge_validator(
        config_section["challenge_validator"])

    relay_client = AcmeClient(
        directory_url=config_section["client"]["directory"],
        private_key=config_section["client"]["private_key"],
        contact=config_section["client"]["contact"],
    )

    relay_client.register_challenge_solver(challenge_solver)

    await relay_client.start()

    if path:
        runner, relay = await class_.unix_socket(config_section,
                                                 path,
                                                 client=relay_client)
    elif config_section["hostname"] and config_section["port"]:
        runner, relay = await class_.runner(config_section,
                                            client=relay_client)
    else:
        raise click.UsageError(PATH_OR_HOST_AND_PORT_MSG)

    relay.register_challenge_validator(challenge_validator)

    return runner, relay
Пример #2
0
    def _make_client(self, key_path, email):
        client = AcmeClient(
            directory_url=self.DIRECTORY,
            private_key=key_path,
            contact={"email": email},
            #            server_cert=self.config_sec.get("client", {}).get("server_cert", None),
        )

        client.register_challenge_solver(DummySolver())

        return client
Пример #3
0
    async def asyncSetUp(self) -> None:
        self.loop = asyncio.get_event_loop()

        broker_client = AcmeClient(
            directory_url=self.config_sec["broker"]["client"]["directory"],
            private_key=self.brokerclient_account_key_path,
            contact=self.config_sec["broker"]["client"]["contact"],
        )

        broker = await self._cls.create_app(
            self.config_sec["broker"], client=broker_client
        )
        broker.register_challenge_validator(DummyValidator())

        await broker._db._recreate()

        main_app = web.Application()
        main_app.add_subapp("/broker", broker.app)

        runner = web.AppRunner(main_app)
        await runner.setup()

        site = web.TCPSite(
            runner,
            self.config_sec["broker"]["hostname"],
            self.config_sec["broker"]["port"],
        )
        await site.start()

        await broker_client.start()

        self.runner = runner
        self.broker_client = broker_client
        self.relay = broker