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

swarmauri_transport_tls_unicast-0.1.0.dev9.tar.gz (3.2 kB view details)

Uploaded Source

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

File metadata

  • Download URL: swarmauri_transport_tls_unicast-0.1.0.dev9.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.dev9.tar.gz
Algorithm Hash digest
SHA256 a08c219e1a48d5479b8fa6f1c774b5af8faff211ef1740e9a2918517080d09b5
MD5 256a9c354c23bcf7168dc66f71bff3a0
BLAKE2b-256 e65ad8a37ac4adc4fc3ccf20417dbfd2a3c1f191468cb5c98fa0008cc50910ae

See more details on using hashes here.

File details

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

File metadata

  • Download URL: swarmauri_transport_tls_unicast-0.1.0.dev9-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.dev9-py3-none-any.whl
Algorithm Hash digest
SHA256 e65d0eb4773eada9e5f5a8bd98c93597b1450da1f9e3e2a56a29e3ea74afd6db
MD5 b45e7f2745d1ef9cfdd4dfda24e5f4e8
BLAKE2b-256 18c88b83f75c01bf652a89e2a1de76ce96ad998eb4a4e958844b2b8ad3c8123f

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