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.dev12.tar.gz.

File metadata

  • Download URL: swarmauri_transport_tls_unicast-0.1.0.dev12.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.dev12.tar.gz
Algorithm Hash digest
SHA256 0b4afdaf9337854f3e1d2c7caeecec7a2247ad91244e6b1fb3cbc4bc4f07a879
MD5 18cf4f8b58832494f50ffb4566d12356
BLAKE2b-256 6d88eca707e55a15b3f6938252de22c8f72823b6f9f1ed303b2f445ea8bc6c96

See more details on using hashes here.

File details

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

File metadata

  • Download URL: swarmauri_transport_tls_unicast-0.1.0.dev12-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.dev12-py3-none-any.whl
Algorithm Hash digest
SHA256 d399f2a13fa2131ac45c13a11cfd7c75907700011389eef93ff2506456c267ab
MD5 1aa9ff0d827f404dd289a912e3a2198f
BLAKE2b-256 8a008cc8f2bc6a8753761aaa3306a6c63cf975ed3f87999b7ed12d119e26bfb1

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