This document outlines the security features implemented in the SIPREC server, focusing on secure signaling and media transmission.
The SIPREC server implements multiple security layers to protect both signaling and media:
- Transport Layer Security (TLS) for SIP signaling encryption
- Secure Real-time Transport Protocol (SRTP) for media encryption
- Certificate-based authentication for server identity verification
- Secure context handling for resource protection
The TLS implementation enables secure SIP signaling by:
- Configuring the SIP server to listen on a dedicated TLS port (default 5063)
- Using X.509 certificates for server identity verification
- Enforcing TLS 1.2+ for enhanced security
- Providing proper validation of certificates
TLS is configured in the .env
file with:
ENABLE_TLS=true
TLS_PORT=5063
TLS_CERT_PATH=/path/to/cert.pem
TLS_KEY_PATH=/path/to/key.pem
The TLS implementation uses the sipgo library's ListenAndServeTLS
method with the "tls" network type. Key implementation aspects include:
- Separate goroutines for each listener type (UDP, TCP, TLS)
- Proper error handling and propagation from listener threads
- Port verification to ensure the TLS server is correctly bound
- Graceful shutdown of TLS connections
SRTP (Secure RTP) implementation enables secure media transport by:
- Adding SRTP support to RTP forwarders
- Generating secure crypto attributes in SDP
- Implementing proper SRTP packet processing with authentication
- Supporting AES_CM_128_HMAC_SHA1_80 profile (per RFC 4568)
SRTP is enabled in the .env
file with:
ENABLE_SRTP=true
The SRTP implementation includes:
SRTPKeyInfo
struct for managing crypto attributes- Key management for secure key exchange
- Crypto suite negotiation through SDP
- Media packet encryption/decryption
When deploying the SIPREC server in production, follow these security recommendations:
-
Certificate Management:
- Use trusted certificates for production environments
- Implement certificate rotation and monitoring
- Validate certificate chain when connecting to external systems
-
Network Security:
- Place the server behind a firewall limiting access to essential ports
- Use separate networks for management and media traffic
- Implement network-level encryption when possible
-
Key Management:
- Store cryptographic keys securely
- Implement key rotation policies
- Use secure methods for key distribution
-
Monitoring and Logging:
- Monitor for security events and connection attempts
- Log security-relevant information (authentication attempts, TLS handshakes)
- Implement alerts for security anomalies
To test the security features:
-
TLS Testing:
- Use OpenSSL to verify TLS connections
- Check certificate validation
- Verify TLS version negotiation
# Test TLS connection openssl s_client -connect your-server:5063
-
SRTP Testing:
- Use SIP clients that support SRTP
- Verify SRTP negotiation in SDP
- Check secure media transmission
# The repository includes test utilities in test_tls/ directory cd test_tls go build -o mock_invite_tls mock_invite_tls.go ./mock_invite_tls
The implementation follows these security-related RFCs:
- RFC 3261: Session Initiation Protocol (SIP)
- RFC 3711: The Secure Real-time Transport Protocol (SRTP)
- RFC 4568: Session Description Protocol (SDP) Security Descriptions
- RFC 5246: The Transport Layer Security (TLS) Protocol Version 1.2
- RFC 6347: Datagram Transport Layer Security Version 1.2
- RFC 7245: SIP-Based Media Recording: Session-Aware Monitoring
Planned security improvements include:
- DTLS-SRTP Support: Implement DTLS for SRTP key exchange
- Enhanced Authentication: Add digest authentication for SIP
- Key Rotation: Automatic key rotation for long-lived sessions
- TLS 1.3 Support: Update to latest TLS version when library support is available