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

File metadata

  • Download URL: swarmauri_transport_tls_unicast-0.1.0.dev10.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.dev10.tar.gz
Algorithm Hash digest
SHA256 594c9ac67a9c65f7f4d941996056dac1e609b3034b3da3de72ab05b6c3e49422
MD5 d052c9b2ad28d512be1bcdbc90290f75
BLAKE2b-256 e1c1c9628c1aa2445a07be7ef196744697126527dbd5e7b82acec7c2e8081c12

See more details on using hashes here.

File details

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

File metadata

  • Download URL: swarmauri_transport_tls_unicast-0.1.0.dev10-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.dev10-py3-none-any.whl
Algorithm Hash digest
SHA256 15451bf0c824736aa3ede0e2ac8cc58a856b72f86ee8c9eb09f54ae2834e2127
MD5 d95f97c57fe2f8942d894dc17b7dd594
BLAKE2b-256 0435c6fc1244309823a93af5d4f09202d423ab3fb27918df70b2941224e485e7

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