|
1 | | -# enclaved-bitgo-express |
2 | | -Enclaved BitGo Express for Advanced Key Management |
| 1 | +# Enclaved Express |
| 2 | + |
| 3 | +Enclaved Express is a secure signer implementation for cryptocurrency operations. It's designed to run in a secure enclave environment with flexible security options. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +This module provides a lightweight, dedicated signing server with these features: |
| 8 | + |
| 9 | +- Focused on signing operations only - no BitGo API dependencies |
| 10 | +- Optional TLS security for secure connections |
| 11 | +- Client certificate validation when operating in mTLS mode |
| 12 | +- Simple configuration and deployment |
| 13 | + |
| 14 | +## Supported Operations |
| 15 | + |
| 16 | +Currently, the following operations are supported: |
| 17 | + |
| 18 | +- `/ping` - Health check endpoint |
| 19 | + |
| 20 | +## Configuration |
| 21 | + |
| 22 | +Configuration is done via environment variables: |
| 23 | + |
| 24 | +### Network Settings |
| 25 | + |
| 26 | +- `PORT` - Port to listen on (default: 3080) |
| 27 | +- `BIND` - Address to bind to (default: localhost) |
| 28 | +- `TIMEOUT` - Request timeout in milliseconds (default: 305000) |
| 29 | + |
| 30 | +### TLS Settings |
| 31 | + |
| 32 | +- `MASTER_BITGO_EXPRESS_KEYPATH` - Path to server key file (required for TLS) |
| 33 | +- `MASTER_BITGO_EXPRESS_CRTPATH` - Path to server certificate file (required for TLS) |
| 34 | +- `MTLS_ENABLED` - Enable mTLS mode (default: false) |
| 35 | +- `MTLS_REQUEST_CERT` - Whether to request client certificates (default: false) |
| 36 | +- `MTLS_REJECT_UNAUTHORIZED` - Whether to reject unauthorized connections (default: false) |
| 37 | +- `MTLS_ALLOWED_CLIENT_FINGERPRINTS` - Comma-separated list of allowed client certificate fingerprints (optional) |
| 38 | + |
| 39 | +### Other Settings |
| 40 | + |
| 41 | +- `LOGFILE` - Path to log file (optional) |
| 42 | +- `DEBUG` - Debug namespaces to enable (e.g., 'enclaved:*') |
| 43 | + |
| 44 | +## Running Enclaved Express |
| 45 | + |
| 46 | +### Basic Setup (HTTP only) |
| 47 | + |
| 48 | +```bash |
| 49 | +yarn start --port 3080 |
| 50 | +``` |
| 51 | + |
| 52 | +### TLS Setup (with mTLS) |
| 53 | + |
| 54 | +For testing purposes, you can use self-signed certificates with relaxed verification: |
| 55 | + |
| 56 | +```bash |
| 57 | +MASTER_BITGO_EXPRESS_KEYPATH=./test-ssl-key.pem \ |
| 58 | +MASTER_BITGO_EXPRESS_CRTPATH=./test-ssl-cert.pem \ |
| 59 | +MTLS_ENABLED=true \ |
| 60 | +MTLS_REQUEST_CERT=true \ |
| 61 | +MTLS_REJECT_UNAUTHORIZED=false \ |
| 62 | +yarn start --port 3080 |
| 63 | +``` |
| 64 | + |
| 65 | +### Connecting from Regular Express |
| 66 | + |
| 67 | +To connect to Enclaved Express from the regular Express server: |
| 68 | + |
| 69 | +```bash |
| 70 | +yarn start --port 4000 \ |
| 71 | + --enclavedExpressUrl='https://localhost:3080' \ |
| 72 | + --enclavedExpressSSLCert='./test-ssl-cert.pem' \ |
| 73 | + --disableproxy \ |
| 74 | + --debug |
| 75 | +``` |
| 76 | + |
| 77 | +## Understanding mTLS Configuration |
| 78 | + |
| 79 | +### Server Side (Enclaved Express) |
| 80 | +- Uses both certificate and key files |
| 81 | +- The key file (`test-ssl-key.pem`) is used to prove the server's identity |
| 82 | +- The certificate file (`test-ssl-cert.pem`) is what the server presents to clients |
| 83 | + |
| 84 | +### Client Side (Regular Express) |
| 85 | +- For testing, only needs the server's certificate |
| 86 | +- `rejectUnauthorized: false` allows testing without strict certificate verification |
| 87 | +- In production, proper client certificates should be used |
| 88 | + |
| 89 | +## Security Considerations |
| 90 | + |
| 91 | +- The testing configuration (`MTLS_REJECT_UNAUTHORIZED=false`) should only be used in development |
| 92 | +- In production: |
| 93 | + - Use proper CA-signed certificates |
| 94 | + - Enable strict certificate verification |
| 95 | + - Use client certificate allowlisting |
| 96 | + - Keep private keys secure |
| 97 | + - Regularly rotate certificates |
| 98 | + |
| 99 | +## Troubleshooting |
| 100 | + |
| 101 | +### Common Issues |
| 102 | + |
| 103 | +1. **Certificate Errors** |
| 104 | + - Ensure paths to certificate files are correct |
| 105 | + - Check file permissions on certificate files |
| 106 | + - Verify certificate format is correct |
| 107 | + |
| 108 | +2. **Connection Issues** |
| 109 | + - Verify ports are not in use |
| 110 | + - Check firewall settings |
| 111 | + - Ensure URLs are correct (including https:// prefix) |
| 112 | + |
| 113 | +3. **mTLS Errors** |
| 114 | + - Verify mTLS is enabled on both sides |
| 115 | + - Check certificate configuration |
| 116 | + - Ensure client certificate is trusted by server |
| 117 | + |
| 118 | +## License |
| 119 | + |
| 120 | +MIT |
0 commit comments