This project implements a secure, industrial-style file transfer pipeline using OPC UA for ingestion and an SMB mover for final delivery.
- A client uploads a file to an OPC UA server in chunks (hex-encoded payload).
- The server reconstructs the file and stores it in a staging directory.
- The client sets a transfer trigger (
TransferRequest = True) and can provide a target file name. - A mover service listens for that trigger, validates the staged file, copies it to the SMB target, verifies integrity, and reports status back to OPC UA.
This creates a controlled handoff between file ingestion and file distribution.
-
OPC_Secured_Server.py- Hosts the secure OPC UA endpoint.
- Enforces trusted client certificates.
- Exposes file-related methods (
Open,WriteHex,Close) and coordination variables:TransferRequestRequestedFileNameLastTransferStatusLastTransferTime
-
OPC_Client.py/core/opc_client.py- Connects to the server.
- Opens a remote file handle, sends chunks, closes the file.
- Sets
TransferRequestwhen upload completes.
-
opcua_smb_mover.py- Polls
TransferRequest. - Waits for the staged file, validates size/extension.
- Copies to
SMB_TARGET_DIR, verifies size + SHA-256 hash, optionally deletes staging file. - Updates
LastTransferStatusand timestamp, then resets request flags.
- Polls
-
app.py(Streamlit dashboard)- Provides UI for upload, status, progress, and transfer history.
- Uses
core/file_handler.pyfor chunking anddata/transfer_log.pyfor audit logging.
-
Secure session setup
- Client and mover connect using certificate-based security (
Basic256Sha256, SignAndEncrypt).
- Client and mover connect using certificate-based security (
-
Upload stage
- Client calls server methods to open and write file chunks.
- Server writes reconstructed bytes into
uploaded_files.
-
Transfer request stage
- Client sets
TransferRequest = Trueand optionallyRequestedFileName.
- Client sets
-
SMB delivery stage
- Mover detects request, selects the requested/newest file, validates policy constraints.
- File is copied to SMB target and verified.
-
Completion and reset
- Mover sets status (
DONE: <file>orERROR: ...), updates time, clears request values.
- Mover sets status (
- Security first: certificate trust validation reduces unauthorized OPC UA access.
- Reliability: staged upload + separate mover decouples ingestion from network share availability.
- Integrity: post-copy size and SHA-256 checks detect corruption.
- Operational visibility: explicit status/timestamp nodes and transfer logs simplify troubleshooting.
- Automation-friendly:
TransferRequesthandshake provides deterministic machine-to-machine coordination.
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt- Start the secure OPC UA server:
python .\OPC_Secured_Server.py- Start the SMB mover service:
python .\opcua_smb_mover.py- Upload a file using either:
- CLI client:
python .\OPC_Client.py "C:\path\to\file.gcode"- Dashboard:
streamlit run .\app.py- Confirm paths in
OPC_Secured_Server.pyandopcua_smb_mover.pymatch your environment. - Ensure
SMB_TARGET_DIRis reachable and writable by the mover process. - Place trusted client certificates under
pki/server/trusted/certsfor authenticated access.
- Client -> OPC UA Server: allow outbound/inbound TCP
4840(or your configured OPC UA endpoint port). - SMB Mover -> SMB Share: allow SMB traffic on TCP
445(and TCP139only if your environment still requires NetBIOS session service). - Host-based firewall: create explicit allow rules between the involved hosts (Client, OPC UA Server host, SMB host) and deny unused ports by default.
- Rationale: these rules ensure secure OPC UA connectivity and reliable SMB file delivery while limiting unnecessary network exposure.
