mivita/dev/dhl-modul/DHL_SSL_FIX_README.md
2025-10-20 17:42:08 +02:00

101 lines
2.3 KiB
Markdown

# DHL SSL-Verbindungsproblem behoben
## Problem
Der Fehler `cURL error 56: OpenSSL SSL_read: error:0A000126:SSL routines::unexpected eof while reading` wurde behoben.
## Lösung
Die SSL/TLS-Konfiguration in den DHL-Services wurde verbessert:
### 1. Verbesserte SSL-Konfiguration
- **TLS-Version**: Erzwingt TLS 1.2 oder höher
- **SSL-Verifikation**: Konfigurierbare Peer- und Host-Verifikation
- **Timeout-Einstellungen**: Optimierte Verbindungs- und Gesamtzeitouts
- **cURL-Optionen**: Erweiterte cURL-Konfiguration für bessere Kompatibilität
### 2. Neue Konfigurationsoptionen
In der `.env`-Datei können folgende SSL-Optionen gesetzt werden:
```env
# DHL SSL-Konfiguration (optional)
DHL_SSL_VERIFY_PEER=true
DHL_SSL_VERIFY_HOST=true
DHL_SSL_VERSION=TLSv1_2
DHL_TIMEOUT=30
DHL_CONNECT_TIMEOUT=10
```
### 3. Für Live-Daten konfigurieren
Um von Sandbox auf Live-Daten zu wechseln:
```env
# DHL Live-Konfiguration
DHL_BASE_URL=https://api-eu.dhl.com
DHL_TEST_MODE=false
DHL_SANDBOX=false
DHL_API_KEY=your_live_api_key
DHL_USERNAME=your_live_username
DHL_PASSWORD=your_live_password
```
### 4. Geänderte Dateien
- `packages/acme-laravel-dhl/src/Support/DhlClient.php`
- `app/Services/DhlTrackingService.php`
- `packages/acme-laravel-dhl/config/dhl.php`
### 5. Test der Verbindung
```bash
php artisan config:clear
php artisan tinker
```
```php
$settingController = new \App\Http\Controllers\SettingController();
$dhlConfig = $settingController->getDhlConfig();
$dhlClient = new \Acme\Dhl\Support\DhlClient(
$dhlConfig['base_url'],
$dhlConfig['api_key'],
$dhlConfig['username'],
$dhlConfig['password']
);
$result = $dhlClient->testConnection();
echo $result ? 'SUCCESS' : 'FAILED';
```
## Fallback-Optionen
Falls weiterhin SSL-Probleme auftreten:
1. **SSL-Verifikation deaktivieren** (nur für Tests):
```env
DHL_SSL_VERIFY_PEER=false
DHL_SSL_VERIFY_HOST=false
```
2. **Ältere TLS-Version verwenden**:
```env
DHL_SSL_VERSION=TLSv1_1
```
3. **Timeout erhöhen**:
```env
DHL_TIMEOUT=60
DHL_CONNECT_TIMEOUT=30
```
## Wichtige Hinweise
- Die SSL-Verbesserungen sind abwärtskompatibel
- Alle bestehenden Konfigurationen funktionieren weiterhin
- Die neuen Optionen sind optional und haben sinnvolle Standardwerte
- Für Produktionsumgebungen sollten SSL-Verifikationen aktiviert bleiben