148 lines
3.4 KiB
Markdown
148 lines
3.4 KiB
Markdown
# SSL/TLS Setup für YourPart Daemon
|
|
|
|
Dieses Dokument beschreibt, wie Sie SSL/TLS-Zertifikate für den YourPart Daemon einrichten können.
|
|
|
|
## 🚀 Schnellstart
|
|
|
|
### 1. Self-Signed Certificate (Entwicklung/Testing)
|
|
```bash
|
|
./setup-ssl.sh
|
|
# Wählen Sie Option 1
|
|
```
|
|
|
|
### 2. Let's Encrypt Certificate (Produktion)
|
|
```bash
|
|
./setup-ssl.sh
|
|
# Wählen Sie Option 2
|
|
```
|
|
|
|
### 3. DNS-01 Challenge (für komplexe Setups)
|
|
```bash
|
|
./setup-ssl-dns.sh
|
|
# Für Cloudflare, Route53, etc.
|
|
```
|
|
|
|
## 📋 Voraussetzungen
|
|
|
|
### Für Let's Encrypt (HTTP-01 Challenge):
|
|
- Port 80 muss verfügbar sein
|
|
- Domain `your-part.de` muss auf den Server zeigen
|
|
- Kein anderer Service auf Port 80
|
|
|
|
### Für DNS-01 Challenge:
|
|
- DNS-Provider Account (Cloudflare, Route53, etc.)
|
|
- API-Credentials für DNS-Management
|
|
|
|
## 🔧 Konfiguration
|
|
|
|
Nach der Zertifikats-Erstellung:
|
|
|
|
1. **SSL in der Konfiguration aktivieren:**
|
|
```ini
|
|
# /etc/yourpart/daemon.conf
|
|
WEBSOCKET_SSL_ENABLED=true
|
|
WEBSOCKET_SSL_CERT_PATH=/etc/yourpart/server.crt
|
|
WEBSOCKET_SSL_KEY_PATH=/etc/yourpart/server.key
|
|
```
|
|
|
|
2. **Daemon neu starten:**
|
|
```bash
|
|
sudo systemctl restart yourpart-daemon
|
|
```
|
|
|
|
3. **Verbindung testen:**
|
|
```bash
|
|
# WebSocket Secure
|
|
wss://your-part.de:4551
|
|
|
|
# Oder ohne SSL
|
|
ws://your-part.de:4551
|
|
```
|
|
|
|
## 🔄 Automatische Erneuerung
|
|
|
|
Let's Encrypt-Zertifikate werden automatisch erneuert:
|
|
- **Cron Job:** Täglich um 2:30 Uhr
|
|
- **Script:** `/etc/yourpart/renew-ssl.sh`
|
|
- **Log:** `/var/log/yourpart/ssl-renewal.log`
|
|
|
|
## 📁 Dateistruktur
|
|
|
|
```
|
|
/etc/yourpart/
|
|
├── server.crt # Zertifikat (Symlink zu Let's Encrypt)
|
|
├── server.key # Private Key (Symlink zu Let's Encrypt)
|
|
├── renew-ssl.sh # Auto-Renewal Script
|
|
└── cloudflare.ini # Cloudflare Credentials (falls verwendet)
|
|
|
|
/etc/letsencrypt/live/your-part.de/
|
|
├── fullchain.pem # Vollständige Zertifikatskette
|
|
├── privkey.pem # Private Key
|
|
├── cert.pem # Zertifikat
|
|
└── chain.pem # Intermediate Certificate
|
|
```
|
|
|
|
## 🛠️ Troubleshooting
|
|
|
|
### Zertifikat wird nicht akzeptiert
|
|
```bash
|
|
# Prüfe Zertifikats-Gültigkeit
|
|
openssl x509 -in /etc/yourpart/server.crt -text -noout
|
|
|
|
# Prüfe Berechtigungen
|
|
ls -la /etc/yourpart/server.*
|
|
```
|
|
|
|
### Let's Encrypt Challenge fehlgeschlagen
|
|
```bash
|
|
# Prüfe Port 80
|
|
sudo netstat -tlnp | grep :80
|
|
|
|
# Prüfe DNS
|
|
nslookup your-part.de
|
|
|
|
# Prüfe Firewall
|
|
sudo ufw status
|
|
```
|
|
|
|
### Auto-Renewal funktioniert nicht
|
|
```bash
|
|
# Prüfe Cron Jobs
|
|
sudo crontab -l
|
|
|
|
# Teste Renewal Script
|
|
sudo /etc/yourpart/renew-ssl.sh
|
|
|
|
# Prüfe Logs
|
|
tail -f /var/log/yourpart/ssl-renewal.log
|
|
```
|
|
|
|
## 🔒 Sicherheit
|
|
|
|
### Berechtigungen
|
|
- **Zertifikat:** `644` (readable by all, writable by owner)
|
|
- **Private Key:** `600` (readable/writable by owner only)
|
|
- **Owner:** `yourpart:yourpart`
|
|
|
|
### Firewall
|
|
```bash
|
|
# Öffne Port 80 für Let's Encrypt Challenge
|
|
sudo ufw allow 80/tcp
|
|
|
|
# Öffne Port 4551 für WebSocket
|
|
sudo ufw allow 4551/tcp
|
|
```
|
|
|
|
## 📚 Weitere Informationen
|
|
|
|
- [Let's Encrypt Dokumentation](https://letsencrypt.org/docs/)
|
|
- [Certbot Dokumentation](https://certbot.eff.org/docs/)
|
|
- [libwebsockets SSL](https://libwebsockets.org/lws-api-doc-master/html/group__ssl.html)
|
|
|
|
## 🆘 Support
|
|
|
|
Bei Problemen:
|
|
1. Prüfen Sie die Logs: `sudo journalctl -u yourpart-daemon -f`
|
|
2. Testen Sie die Zertifikate: `openssl s_client -connect your-part.de:4551`
|
|
3. Prüfen Sie die Firewall: `sudo ufw status`
|