A Python TLSTCPIPServer sample that can communicate with ObjectDelivererV2 TLSClient.
This sample provides:
- CA/server certificate generation with OpenSSL
- Client certificate generation for mTLS with OpenSSL
- Packet framing compatible with ObjectDeliverer
PacketRuleSizeBody - Echo-back behavior (returns exactly what it receives)
- macOS / Linux / Windows (WSL)
python3(3.9+ recommended)openssl
Check:
python3 --version
openssl versionserver.py: TLS + SizeBody + echo-back serverscripts/create_ca_and_server_cert.sh: Generates CA and server certificatesscripts/create_client_cert.sh: Generates a client certificate for mTLScerts/: Certificate output directory
cd /TLSServerSample
./scripts/create_ca_and_server_cert.sh ./certs localhost localhost 127.0.0.1Arguments:
- Output directory (default:
./certs) - Server certificate CN (default:
localhost) - SAN DNS name (default:
localhost) - SAN IP address (default:
127.0.0.1)
Generated files (example):
./certs/ca.crt.pem./certs/ca.key.pem./certs/server.crt.pem./certs/server.key.pem./certs/server.fullchain.pem
cd /TLSServerSample
./scripts/create_client_cert.sh ./certs od-clientArguments:
- Output directory (default:
./certs) - Client name/CN (default:
od-client) - CA certificate path (default:
./certs/ca.crt.pem) - CA private key path (default:
./certs/ca.key.pem)
Generated files (example):
./certs/od-client.crt.pem./certs/od-client.key.pem
cd /TLSServerSample
python3 server.py \
--host 0.0.0.0 \
--port 8765 \
--cert ./certs/server.crt.pem \
--key ./certs/server.key.pem \
--ca-cert ./certs/ca.crt.pem \
--client-auth required \
--size-length 4 \
--size-endian bigcd /TLSServerSample
python3 server.py \
--host 0.0.0.0 \
--port 8765 \
--cert ./certs/server.crt.pem \
--key ./certs/server.key.pem \
--client-auth none \
--size-length 4 \
--size-endian bigWhen configuring ObjectDeliverer TLSClient, match these values:
- Connection target
- Host: Must match server certificate SAN/CN
- Port: Must match
server.py --port
- TLS server verification
- Set
Trusted CA Certificateto./certs/ca.crt.pem - Keep certificate verification enabled
- mTLS (when server uses
--client-auth required)
- Client Certificate:
./certs/od-client.crt.pem - Client Private Key:
./certs/od-client.key.pem
- Packet rule
- Select
PacketRuleSizeBody SizeLength:4(or match server value)SizeBufferEndian:Big(or match server value)
This server follows the same framing as ObjectDeliverer PacketRuleSizeBody:
- First
SizeLengthbytes: unsigned body size - Next N bytes: body payload
- Endian:
bigorlittle
Example (SizeLength=4, big, body=\x01\x02\x03):
- Sent:
00 00 00 03 01 02 03 - Echoed response:
00 00 00 03 01 02 03
--client-auth:none | optional | required(default:required)--size-length:1 | 2 | 3 | 4(default:4)--size-endian:big | little(default:big)--max-body-size: Max body bytes per packet (default: 8 MiB)--min-tls-version:1.2 | 1.3(default:1.2)
Help:
python3 server.py --helpopenssl s_client \
-connect 127.0.0.1:8765 \
-CAfile ./certs/ca.crt.pem \
-cert ./certs/od-client.crt.pem \
-key ./certs/od-client.key.pemTLS handshake failed- Confirm
--ca-certmatches the CA that issued the client certificate - Confirm client certificate/key pair is correct
- Confirm
certificate verify failed- Confirm ObjectDeliverer host value matches cert SAN/CN
- Confirm
Trusted CA Certificatepoints toca.crt.pem
body too large- Increase
--max-body-sizeif needed
- Increase
ca.key.pemis sensitive. Do not expose it.- For production, use proper certificate lifecycle management and rotation.