# Variables
$PFX_PATH = "C:\Users\oimer\.aspnet\https\aspnetapp.pfx"
$PASSWORD = "tGTF2025"

Write-Host "Conversion du certificat via Docker..." -ForegroundColor Yellow

# Convertir en certificat (.crt)
docker run --rm -v C:\Users\oimer\.aspnet\https:/certs alpine/openssl pkcs12 -in /certs/aspnetapp.pfx -clcerts -nokeys -out /certs/aspnetapp.crt -passin pass:$PASSWORD

# Convertir en clé privée (.key)
docker run --rm -v C:\Users\oimer\.aspnet\https:/certs alpine/openssl pkcs12 -in /certs/aspnetapp.pfx -nocerts -nodes -out /certs/aspnetapp.key -passin pass:$PASSWORD

Write-Host "`n✓ Certificats convertis avec succès!" -ForegroundColor Green
Write-Host "Fichiers créés:" -ForegroundColor Cyan
Write-Host "  - C:\Users\oimer\.aspnet\https\aspnetapp.crt" -ForegroundColor White
Write-Host "  - C:\Users\oimer\.aspnet\https\aspnetapp.key" -ForegroundColor White