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

File metadata

  • Download URL: swarmauri_transport_tls_unicast-0.1.0.dev11.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.dev11.tar.gz
Algorithm Hash digest
SHA256 7b6e0ed525071c4f0adb102147c9b79ed92b3444a9355db7cf7f6c809c4a41b3
MD5 5485753fa52ac5ce78c0ba22a8797cdb
BLAKE2b-256 afc3557b9ab56b88cbaef7bce8fae9b155cee0f0a32794ef3fbd20f1f265768a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: swarmauri_transport_tls_unicast-0.1.0.dev11-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.dev11-py3-none-any.whl
Algorithm Hash digest
SHA256 3c4f5fbcf31478f8c1b84a39c68c82be8779c95800e2a1b25e62fa52a9a61224
MD5 804f7353070bb9ca4534c0d5a3c72072
BLAKE2b-256 a1bb11e8ed7f8f917ef1896c62fae877f18fe3a91e10a48c80d53082d17a602d

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