NetBurner SSL/TLS Server Example
Overview
This application demonstrates a simple SSL/TLS server implementation using the NetBurner RTOS platform. The server uses Elliptic Curve Cryptographic (ECC) keys to establish secure connections and serves as an example of how to implement SSL/TLS communication in embedded systems.
Features
- SSL/TLS server listening on port 8883 (MQTT secure port)
- Elliptic Curve Cryptography (ECC) support
- Client connection handling with secure data transmission
- Large data buffer transmission demonstration
- Real-time connection status reporting
Application Architecture
Main Components
- TcpServerTask: The main server task that handles incoming SSL/TLS connections
- Certificate and Key Files: Pre-generated ECC certificate and private key
- Network Interface Management: Automatic network configuration and IP address handling
Key Files
main.cpp
- Main application logic and server implementation
ServerCert.cpp
- Auto-generated SSL certificate data (672 bytes)
ServerKey.cpp
- Auto-generated ECC private key data (310 bytes)
How It Works
- Initialization: The application initializes the NetBurner system and waits for network connectivity
- Server Setup: Creates a listening socket on port 8883 using SSL/TLS
- Client Handling: Accepts incoming connections and establishes secure sessions
- Data Exchange:
- Sends a welcome message to connected clients
- Transmits a large buffer containing pi digits (demonstration data)
- Displays client IP address and port information
- Echoes back any data received from clients
- Connection Management: Properly closes connections and cleans up resources
Testing the Application
Using OpenSSL Command Line
You can test the SSL/TLS server using OpenSSL from a command line:
For ECC Cipher Suite
int connect(const IPADDR &ipAddress, uint16_t remotePort, uint32_t timeout)
Establish a TCP connection to a remote host.
Definition tcp.h:1547
Example:
openssl s_client -cipher ECDHE-ECDSA-AES256-GCM-SHA384 -
connect 10.1.1.191:8883
For RSA (if using RSA keys)
Example:
openssl s_client -
connect 10.1.1.191:8883
Expected Behavior
When a client connects successfully, you should see:
- Welcome message: "Welcome to the NetBurner SSL/TLS Server Example"
- A large buffer of pi digits (demonstration data)
- Server IP address and port information
- Echo of any data you send to the server
Configuration
Network Settings
- Listen Port: 8883 (MQTT secure port)
- Buffer Size: 4096 bytes for receiving data
- Network Wait: 5 seconds timeout for DHCP address acquisition
Task Configuration
- Stack Size: USER_TASK_STK_SIZE
- Priority: MAIN_PRIO - 1 (higher priority than main task)
- Task Name: "TcpServerTask"
Customization Options
Using RSA Keys Instead of ECC
If your application requires RSA keys instead of ECC:
- Navigate to
\nburn\CreateCerts\RSA
directory
- Run the key generation scripts
- Replace
ServerKey.cpp
and ServerCert.cpp
with the newly generated files
- Rebuild the application
The RSA version can be tested with the standard OpenSSL command without specifying cipher suites.
Technical Details
SSL/TLS Implementation
- Uses NetBurner's built-in SSL/TLS stack
- Supports modern cipher suites including ECDHE-ECDSA-AES256-GCM-SHA384
- Automatic certificate and key loading from embedded data
Memory Usage
- RX Buffer: 4KB for incoming data
- Task Stack: Configurable via USER_TASK_STK_SIZE
- Certificate: 672 bytes
- Private Key: 310 bytes
Error Handling
- Connection timeout handling
- Graceful client disconnection
- Resource cleanup on connection termination
Security Considerations
- Uses strong ECC encryption by default
- Certificates are embedded in the application binary
- For production use, consider:
- Using production certificates from a trusted CA
- Implementing certificate validation
- Adding additional security measures as required
Dependencies
- NetBurner RTOS
- NetBurner SSL/TLS library
- Standard NetBurner networking stack
Troubleshooting
Common Issues
- Connection Refused: Ensure the device has a valid IP address and port 8883 is not blocked
- SSL Handshake Failure: Verify that the client supports the cipher suites used by the server
- Network Issues: Check DHCP configuration and network connectivity