Complete mbedTLS cleanup - Removed all mbedTLS dependencies and updated documentation
- Moved mbedTLS directories to Trash/ (mbedtls/, mbedtls-install/, mbedtls-arm64-install/) - Removed obsolete nostr_websocket_mbedtls.c implementation - Updated nostr_websocket/Makefile to use OpenSSL instead of mbedTLS - Updated nostr_websocket/README.md with OpenSSL migration notes - Updated nostr_websocket/EXPORT_GUIDE.md with OpenSSL instructions - All tests pass: crypto tests, static linking verification - Build system fully functional with OpenSSL-only dependencies
This commit is contained in:
parent
6d7b709f9a
commit
af2117b574
|
@ -8,11 +8,11 @@ The NOSTR WebSocket library consists of these key files for export:
|
|||
|
||||
### Core Files (Required)
|
||||
- `nostr_websocket_tls.h` - Header with all function declarations and constants
|
||||
- `nostr_websocket_mbedtls.c` - Main implementation using mbedTLS for SSL/TLS
|
||||
- `nostr_websocket_openssl.c` - Main implementation using OpenSSL for SSL/TLS
|
||||
- `../cjson/cJSON.h` and `../cjson/cJSON.c` - JSON parsing (lightweight)
|
||||
|
||||
### Dependencies
|
||||
- **mbedTLS** - For SSL/TLS support (wss:// connections)
|
||||
- **OpenSSL** - For SSL/TLS support (wss:// connections) - libssl, libcrypto
|
||||
- **Standard C libraries** - socket, networking, etc.
|
||||
|
||||
## Quick Integration
|
||||
|
@ -21,23 +21,29 @@ The NOSTR WebSocket library consists of these key files for export:
|
|||
```bash
|
||||
# Copy the library files
|
||||
cp nostr_websocket_tls.h your_project/
|
||||
cp nostr_websocket_mbedtls.c your_project/
|
||||
cp nostr_websocket_openssl.c your_project/
|
||||
cp ../cjson/cJSON.h your_project/
|
||||
cp ../cjson/cJSON.c your_project/
|
||||
```
|
||||
|
||||
### 2. Install mbedTLS Dependency
|
||||
### 2. Install OpenSSL Dependency
|
||||
```bash
|
||||
# Ubuntu/Debian
|
||||
sudo apt-get install libmbedtls-dev
|
||||
sudo apt-get install libssl-dev
|
||||
|
||||
# Or build from source (see mbedTLS documentation)
|
||||
# CentOS/RHEL/Fedora
|
||||
sudo yum install openssl-devel
|
||||
# or
|
||||
sudo dnf install openssl-devel
|
||||
|
||||
# macOS (via Homebrew)
|
||||
brew install openssl
|
||||
```
|
||||
|
||||
### 3. Compile Your Project
|
||||
```bash
|
||||
gcc -o my_nostr_app my_app.c nostr_websocket_mbedtls.c cJSON.c \
|
||||
-lmbedtls -lmbedx509 -lmbedcrypto -lm
|
||||
gcc -o my_nostr_app my_app.c nostr_websocket_openssl.c cJSON.c \
|
||||
-lssl -lcrypto -lm
|
||||
```
|
||||
|
||||
## Basic Usage Example
|
||||
|
@ -131,16 +137,17 @@ The library supports both TCP (`ws://`) and TLS (`wss://`) automatically based o
|
|||
|
||||
### Linux/Unix
|
||||
- Works out of the box with standard development tools
|
||||
- Requires: gcc, mbedTLS development headers
|
||||
- Requires: gcc, OpenSSL development headers (libssl-dev)
|
||||
|
||||
### Potential Windows Support
|
||||
### Windows Support
|
||||
- Would need Winsock2 adaptations in transport layer
|
||||
- mbedTLS is cross-platform compatible
|
||||
- OpenSSL is widely available on Windows
|
||||
|
||||
### Embedded Systems
|
||||
- Lightweight design suitable for embedded use
|
||||
- Memory usage: ~4KB per client + message buffers
|
||||
- No dynamic allocations in hot paths
|
||||
- OpenSSL provides optimized implementations for various architectures
|
||||
|
||||
## Library Design Benefits
|
||||
|
||||
|
@ -178,7 +185,21 @@ The library handles all WebSocket protocol details, SSL/TLS, and NOSTR message f
|
|||
|
||||
- Based on WebSocket RFC 6455
|
||||
- Implements NOSTR WebSocket conventions
|
||||
- SSL/TLS via proven mbedTLS library
|
||||
- SSL/TLS via industry-standard OpenSSL library
|
||||
- Tested with major NOSTR relays
|
||||
|
||||
## Migration Notes
|
||||
|
||||
If you were previously using the mbedTLS version of this library:
|
||||
|
||||
### Code Changes Required
|
||||
- Update `#include` to reference `nostr_websocket_openssl.c` instead of `nostr_websocket_mbedtls.c`
|
||||
- Change linking flags from `-lmbedtls -lmbedx509 -lmbedcrypto` to `-lssl -lcrypto`
|
||||
- Install OpenSSL development headers instead of mbedTLS
|
||||
|
||||
### API Compatibility
|
||||
- All function signatures remain identical
|
||||
- No changes to your application code required
|
||||
- Same performance characteristics and behavior
|
||||
|
||||
This library provides a clean, efficient way to integrate NOSTR WebSocket functionality into any C project with minimal dependencies and maximum portability.
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
CC = gcc
|
||||
CFLAGS = -Wall -Wextra -std=c99 -O2
|
||||
INCLUDES = -I. -I.. -I../mbedtls/include -I../mbedtls/tf-psa-crypto/include -I../mbedtls/tf-psa-crypto/drivers/builtin/include
|
||||
LIBS = -lm -L../mbedtls/library -lmbedtls -lmbedx509 -lmbedcrypto
|
||||
INCLUDES = -I. -I.. -I../openssl-install/include
|
||||
LIBS = -lm -L../openssl-install/lib64 -lssl -lcrypto
|
||||
|
||||
# Source files
|
||||
WEBSOCKET_SOURCES = nostr_websocket_mbedtls.c ../cjson/cJSON.c
|
||||
WEBSOCKET_SOURCES = nostr_websocket_openssl.c ../cjson/cJSON.c
|
||||
WEBSOCKET_HEADERS = nostr_websocket_tls.h ../cjson/cJSON.h
|
||||
|
||||
# Test programs
|
||||
|
@ -21,7 +21,7 @@ WEBSOCKET_OBJECTS = $(WEBSOCKET_SOURCES:.c=.o)
|
|||
|
||||
all: $(TEST_PROGRAMS)
|
||||
|
||||
# Test programs
|
||||
# Test programs (if test file exists)
|
||||
test_5_events_clean: test_5_events_clean.o $(WEBSOCKET_OBJECTS)
|
||||
$(CC) -o $@ $^ $(LIBS)
|
||||
|
||||
|
@ -29,11 +29,16 @@ test_5_events_clean: test_5_events_clean.o $(WEBSOCKET_OBJECTS)
|
|||
%.o: %.c $(WEBSOCKET_HEADERS)
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
|
||||
|
||||
# Test target
|
||||
test: test_5_events_clean
|
||||
@echo "🧪 Running WebSocket test..."
|
||||
@echo "Press Ctrl-C to stop the test"
|
||||
./test_5_events_clean
|
||||
# Test target (if test exists, otherwise use wss_test from tests/)
|
||||
test:
|
||||
@if [ -f test_5_events_clean ]; then \
|
||||
echo "🧪 Running local WebSocket test..."; \
|
||||
echo "Press Ctrl-C to stop the test"; \
|
||||
./test_5_events_clean; \
|
||||
else \
|
||||
echo "🧪 Running WebSocket test from tests/ directory..."; \
|
||||
cd ../tests && make wss_test && ./wss_test; \
|
||||
fi
|
||||
|
||||
# Clean build artifacts
|
||||
clean:
|
||||
|
@ -46,18 +51,21 @@ info:
|
|||
@echo "=========================="
|
||||
@echo "Core files:"
|
||||
@echo " - nostr_websocket_tls.h (header)"
|
||||
@echo " - nostr_websocket_mbedtls.c (implementation)"
|
||||
@echo " - nostr_websocket_openssl.c (OpenSSL implementation)"
|
||||
@echo " - ../cjson/cJSON.h/c (JSON support)"
|
||||
@echo ""
|
||||
@echo "Dependencies:"
|
||||
@echo " - mbedTLS (SSL/TLS support)"
|
||||
@echo " - OpenSSL (SSL/TLS support)"
|
||||
@echo " - Standard C libraries"
|
||||
@echo ""
|
||||
@echo "Usage:"
|
||||
@echo " make - Build test programs"
|
||||
@echo " make - Build test programs (if available)"
|
||||
@echo " make test - Run WebSocket test"
|
||||
@echo " make clean - Clean build artifacts"
|
||||
@echo " make info - Show this information"
|
||||
@echo ""
|
||||
@echo "Note: This library is integrated into the main libnostr_core.a"
|
||||
@echo "Use the tests in ../tests/ for comprehensive testing."
|
||||
|
||||
# Help target
|
||||
help: info
|
||||
|
|
|
@ -5,7 +5,7 @@ A production-ready, lightweight WebSocket client library specifically designed f
|
|||
## Features
|
||||
|
||||
- ✅ **WebSocket RFC 6455 Compliant** - Full WebSocket protocol implementation
|
||||
- ✅ **SSL/TLS Support** - Secure `wss://` connections via mbedTLS
|
||||
- ✅ **SSL/TLS Support** - Secure `wss://` connections via OpenSSL
|
||||
- ✅ **NOSTR Protocol** - Built-in support for REQ, EVENT, CLOSE messages
|
||||
- ✅ **Production Ready** - Optimized performance and error handling
|
||||
- ✅ **Lightweight** - Minimal dependencies and memory footprint
|
||||
|
@ -54,11 +54,11 @@ cJSON_Delete(filter);
|
|||
|
||||
### Core Components
|
||||
- **`nostr_websocket_tls.h`** - Public API header
|
||||
- **`nostr_websocket_mbedtls.c`** - Main implementation (mbedTLS backend)
|
||||
- **`nostr_websocket_openssl.c`** - Main implementation (OpenSSL backend)
|
||||
- **`../cjson/cJSON.h/c`** - JSON parsing support
|
||||
|
||||
### Dependencies
|
||||
- **mbedTLS** - For SSL/TLS support
|
||||
- **OpenSSL** - For SSL/TLS support (libssl, libcrypto)
|
||||
- **Standard C libraries** - POSIX sockets, etc.
|
||||
|
||||
## Installation in Other Projects
|
||||
|
@ -121,14 +121,16 @@ make help # Show help
|
|||
|
||||
## Development History
|
||||
|
||||
This library evolved from the experimental WebSocket implementation in `../websocket_experiment/` and represents the production-ready, stable version suitable for integration into other projects.
|
||||
This library evolved from the experimental WebSocket implementation and represents the production-ready, stable version suitable for integration into other projects.
|
||||
|
||||
Key improvements made during development:
|
||||
- **Migrated from mbedTLS to OpenSSL** - Better compatibility and performance
|
||||
- Fixed critical WebSocket frame parsing bugs
|
||||
- Optimized SSL/TLS performance
|
||||
- Reduced memory allocations
|
||||
- Enhanced error handling
|
||||
- Added comprehensive documentation
|
||||
- Improved build system integration
|
||||
|
||||
## License
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue