ws-rs-0.1.2 has been yanked.
ws-rs
A secure WebSocket library for OCPP communications with TLS support, built in Rust.
Features
- TLS Support - Secure communications with TLS encryption and certificate validation
- Mutual TLS (mTLS) - Client and server mutual authentication
- Async Architecture - Built on Tokio and Tokio-Tungstenite for high performance
- Flexible API - Simple yet powerful API for both client and server implementations
Installation
Add the following to your Cargo.toml:
[]
= { = "0.1.0", = ["client", "server"] }
Usage
Server Example
use ;
use PathBuf;
async
Client Example
use ;
use PathBuf;
async
Certificate Setup
This library expects TLS certificates for secure communication. You can use the companion crate_cert tool to generate test certificates:
&&
The generated certificates should be placed in a certs directory with the following structure:
certs/
|- ca_cert.pem # CA certificate
|- a_cert.pem # Client certificate
|- a_key.pem # Client private key
|- b_cert.pem # Server certificate
|- b_key.pem # Server private key
Logging
This library uses the log crate for logging. To enable logging, configure an implementation such as env_logger:
// Initialize with default settings
init;
// Or with a specific log level
set_var;
init;
Control log levels using the RUST_LOG environment variable:
error: Only errorswarn: Warnings and errorsinfo: General information (default)debug: Debug informationtrace: All logs
Security Notes
- Always validate certificates in production environments
- Protect private keys appropriately
- Use custom certificate validation for specific security requirements
- Consider certificate revocation checking for critical applications
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request