Skip to main content

TLS / mTLS unicast transport for Swarmauri.

Project description

Swarmauri TLS Unicast Transport

Transport Icon Security Lifecycle

The Swarmauri TLS Unicast Transport brings encrypted, authenticated connections to the unified transport lifecycle. It wraps asyncio's TLS streams with the .server(...) / .client(...) contexts so you can safely manage secure sockets directly from the transport.

Installation

Using uv

uv add --directory pkgs/standards/swarmauri_transport_tls_unicast swarmauri_transport_tls_unicast

Using pip

pip install swarmauri_transport_tls_unicast

Usage

The snippet below demonstrates creating a mutually-authenticated TLS echo server and client.

import asyncio
import ssl
from swarmauri_transport_tls_unicast import TlsUnicastTransport

srv_ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
srv_ctx.load_cert_chain("srv.pem", "srv.key")
# srv_ctx.verify_mode = ssl.CERT_REQUIRED
# srv_ctx.load_verify_locations("ca.pem")

cli_ctx = ssl.create_default_context()
# cli_ctx.load_cert_chain("cli.pem", "cli.key")

async def main():
    server = TlsUnicastTransport(srv_ctx)

    async def run_server():
        async with server.server(host="0.0.0.0", port=8443):
            data = await server.recv()
            await server.send("peer", b"tls:" + data)

    async def run_client():
        client = TlsUnicastTransport(cli_ctx, sni="localhost")
        async with client.client(host="127.0.0.1", port=8443):
            await client.send("server", b"hello")
            response = await client.recv()
            print(response.decode())

    await asyncio.gather(run_server(), run_client())

asyncio.run(main())

Configure the SSL contexts with your own certificates (and CA trust) to enable TLS or full mTLS verification.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file swarmauri_transport_tls_unicast-0.1.0.dev14.tar.gz.

File metadata

  • Download URL: swarmauri_transport_tls_unicast-0.1.0.dev14.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_transport_tls_unicast-0.1.0.dev14.tar.gz
Algorithm Hash digest
SHA256 5d23a157692ea8598156ac3e47b1a1b88af31822daa0b09471e8705dc97b21ac
MD5 5a46238746d07b190a1eeec303b0d44e
BLAKE2b-256 119fd87c0c8bf6f35fe1eb60df81800f55f0eb8c30206f66c956892eecb390ec

See more details on using hashes here.

File details

Details for the file swarmauri_transport_tls_unicast-0.1.0.dev14-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_transport_tls_unicast-0.1.0.dev14-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_transport_tls_unicast-0.1.0.dev14-py3-none-any.whl
Algorithm Hash digest
SHA256 04a0ad0122c3fb31577bb7604692f86a7dd4d6699b244ee754cfb68d43945a38
MD5 5619578d292af8dfef26eb6d9421b679
BLAKE2b-256 25fe77bfdbf4c9c2d7bddb93144c422ea69e84ef0c30fa13ccf086735642d1df

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page