Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for client TLS certificates #9

Closed
wants to merge 2 commits into from

Conversation

examknow
Copy link

@examknow examknow commented Dec 6, 2021

closes #7

working implementation:

import asyncio

from irctokens import build, Line
from ircrobots import Bot as BaseBot
from ircrobots import Server as BaseServer
from ircrobots import ConnectionParams, SASLExternal, SASLSCRAM, ClientTLSCertificate

class Server(BaseServer):
    async def line_read(self, line: Line):
        print(f"{self.name} < {line.format()}")

        if line.command == "001":
            # whois ourself so we can see our client certfp
            await self.send(build("WHOIS", [self.nickname]))
    async def line_send(self, line: Line):
        print(f"{self.name} > {line.format()}")

class Bot(BaseBot):
    def create_server(self, name: str):
        return Server(self, name)

async def main():
    bot = Bot()

    sasl_params = SASLExternal()
    certificate = ClientTLSCertificate("libera.pem")
    params      = ConnectionParams(
        "tlstest1",
        host = "irc.libera.chat",
        port = 6697,
        tls  = True,
        sasl = sasl_params,
        certificate = certificate)

    await bot.add_server("libera", params)
    await bot.run()

if __name__ == "__main__":
    asyncio.run(main())

ircrobots/params.py Outdated Show resolved Hide resolved
@jesopo jesopo force-pushed the master branch 2 times, most recently from 2e7336f to 5b347f9 Compare January 24, 2022 09:53
@examknow examknow closed this Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support client TLS certificates
2 participants