🎉 Improved script naming and removed unnecessary file 🎇
This commit is contained in:
parent
c849e37493
commit
eadb7eedc4
@ -1,374 +0,0 @@
|
|||||||
# Mercedes-Benz SSL-Zertifikat-Installationsskript für Windows
|
|
||||||
# Installiert notwendige Zertifikate für sichere Netzwerkverbindungen
|
|
||||||
|
|
||||||
param(
|
|
||||||
[switch]$Force,
|
|
||||||
[switch]$Verbose
|
|
||||||
)
|
|
||||||
|
|
||||||
# Fehlerbehandlung
|
|
||||||
$ErrorActionPreference = "Stop"
|
|
||||||
|
|
||||||
# Emojis und Farben für bessere Ausgabe
|
|
||||||
$SUCCESS = "✅"
|
|
||||||
$ERROR = "❌"
|
|
||||||
$WARNING = "⚠️"
|
|
||||||
$INFO = "ℹ️"
|
|
||||||
$CERT = "🔐"
|
|
||||||
$MERCEDES = "🏎️"
|
|
||||||
|
|
||||||
# Logging-Funktionen
|
|
||||||
function Write-Success { param($Message) Write-Host "$SUCCESS $Message" -ForegroundColor Green }
|
|
||||||
function Write-Error { param($Message) Write-Host "$ERROR $Message" -ForegroundColor Red }
|
|
||||||
function Write-Warning { param($Message) Write-Host "$WARNING $Message" -ForegroundColor Yellow }
|
|
||||||
function Write-Info { param($Message) Write-Host "$INFO $Message" -ForegroundColor Blue }
|
|
||||||
|
|
||||||
# Header
|
|
||||||
Write-Host ""
|
|
||||||
Write-Host "$MERCEDES Mercedes-Benz SSL-Zertifikat-Installation $MERCEDES" -ForegroundColor Blue
|
|
||||||
Write-Host "=================================================================="
|
|
||||||
Write-Host ""
|
|
||||||
|
|
||||||
# Administrator-Rechte prüfen
|
|
||||||
function Test-Administrator {
|
|
||||||
$currentUser = [Security.Principal.WindowsIdentity]::GetCurrent()
|
|
||||||
$principal = New-Object Security.Principal.WindowsPrincipal($currentUser)
|
|
||||||
return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (-not (Test-Administrator)) {
|
|
||||||
Write-Error "Dieses Skript muss als Administrator ausgeführt werden!"
|
|
||||||
Write-Info "Starten Sie PowerShell als Administrator und führen Sie das Skript erneut aus."
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Zertifikat-Verzeichnisse erstellen
|
|
||||||
function New-CertificateDirectories {
|
|
||||||
Write-Info "Erstelle Zertifikat-Verzeichnisse..."
|
|
||||||
|
|
||||||
$directories = @(
|
|
||||||
"certs\mercedes\root",
|
|
||||||
"certs\mercedes\intermediate",
|
|
||||||
"certs\mercedes\server",
|
|
||||||
"certs\backup"
|
|
||||||
)
|
|
||||||
|
|
||||||
foreach ($dir in $directories) {
|
|
||||||
if (-not (Test-Path $dir)) {
|
|
||||||
New-Item -ItemType Directory -Path $dir -Force | Out-Null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Success "Zertifikat-Verzeichnisse erstellt"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Mercedes-Benz Root-Zertifikate erstellen
|
|
||||||
function New-MercedesRootCertificates {
|
|
||||||
Write-Info "$CERT Erstelle Mercedes-Benz Root-Zertifikate..."
|
|
||||||
|
|
||||||
# Mercedes-Benz Corporate Root CA (Platzhalter)
|
|
||||||
$mercedesRootCert = @"
|
|
||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIIDXTCCAkWgAwIBAgIJAKoK/heBjcOuMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV
|
|
||||||
BAYTAkRFMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX
|
|
||||||
aWRnaXRzIFB0eSBMdGQwHhcNMjQwMTAxMDAwMDAwWhcNMzQwMTAxMDAwMDAwWjBF
|
|
||||||
MQswCQYDVQQGEwJERTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50
|
|
||||||
ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
|
|
||||||
CgKCAQEAuIj/82u+f1n3c3fpjwNnFOKBY4/l0f+uKKDVzYWOQbIQc+7qvgfKGoI+
|
|
||||||
UqK3QmXRJb26fidjMuFdC4XJBOmLg+mSRnZskQdJVFI5gVBELWw+YC+cINhycXy4
|
|
||||||
V8turPrzhkfinDiB40+hLRlhGtjdQWspUXLoRhNT+Hf6+5rOKFHPbFHjzuDMFXXF
|
|
||||||
XrVhLVyIjYK+wFXGAVBgAsEAtLA+KjIww+eApVL+bJXhkws1Vx+cPkvsYGSGcq2ϕ
|
|
||||||
QIDAQABMA0GCSqGSIb3DQEBBQUAA4IBAQCfmyGoGWI0+1QQiap6EcOXAXJeIpkPGU
|
|
||||||
-----END CERTIFICATE-----
|
|
||||||
"@
|
|
||||||
|
|
||||||
# Daimler AG Root CA (Platzhalter)
|
|
||||||
$daimlerRootCert = @"
|
|
||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIIDXTCCAkWgAwIBAgIJAKoK/heBjcOuMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV
|
|
||||||
BAYTAkRFMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX
|
|
||||||
aWRnaXRzIFB0eSBMdGQwHhcNMjQwMTAxMDAwMDAwWhcNMzQwMTAxMDAwMDAwWjBF
|
|
||||||
MQswCQYDVQQGEwJERTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50
|
|
||||||
ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
|
|
||||||
CgKCAQEAuIj/82u+f1n3c3fpjwNnFOKBY4/l0f+uKKDVzYWOQbIQc+7qvgfKGoI+
|
|
||||||
UqK3QmXRJb26fidjMuFdC4XJBOmLg+mSRnZskQdJVFI5gVBELWw+YC+cINhycXy4
|
|
||||||
V8turPrzhkfinDiB40+hLRlhGtjdQWspUXLoRhNT+Hf6+5rOKFHPbFHjzuDMFXXF
|
|
||||||
XrVhLVyIjYK+wFXGAVBgAsEAtLA+KjIww+eApVL+bJXhkws1Vx+cPkvsYGSGcq2ϕ
|
|
||||||
QIDAQABMA0GCSqGSIb3DQEBBQUAA4IBAQCfmyGoGWI0+1QQiap6EcOXAXJeIpkPGU
|
|
||||||
-----END CERTIFICATE-----
|
|
||||||
"@
|
|
||||||
|
|
||||||
# Zertifikate in Dateien speichern
|
|
||||||
$mercedesRootCert | Out-File -FilePath "certs\mercedes\root\mercedes-root-ca.crt" -Encoding ASCII
|
|
||||||
$daimlerRootCert | Out-File -FilePath "certs\mercedes\root\daimler-root-ca.crt" -Encoding ASCII
|
|
||||||
|
|
||||||
Write-Success "Mercedes-Benz Root-Zertifikate erstellt"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Zertifikate in Windows-Zertifikatsspeicher installieren
|
|
||||||
function Install-WindowsCertificates {
|
|
||||||
Write-Info "Installiere Zertifikate in Windows-Zertifikatsspeicher..."
|
|
||||||
|
|
||||||
try {
|
|
||||||
# Root-Zertifikate installieren
|
|
||||||
$certFiles = Get-ChildItem -Path "certs\mercedes\root\*.crt"
|
|
||||||
|
|
||||||
foreach ($certFile in $certFiles) {
|
|
||||||
Write-Info "Installiere: $($certFile.Name)"
|
|
||||||
|
|
||||||
# Zertifikat in Trusted Root Certification Authorities installieren
|
|
||||||
Import-Certificate -FilePath $certFile.FullName -CertStoreLocation "Cert:\LocalMachine\Root" -Verbose:$Verbose
|
|
||||||
|
|
||||||
# Zertifikat auch in Current User installieren
|
|
||||||
Import-Certificate -FilePath $certFile.FullName -CertStoreLocation "Cert:\CurrentUser\Root" -Verbose:$Verbose
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Success "Windows-Zertifikate erfolgreich installiert"
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Write-Error "Fehler beim Installieren der Windows-Zertifikate: $($_.Exception.Message)"
|
|
||||||
throw
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Internet Explorer/Edge Zertifikate aktualisieren
|
|
||||||
function Update-IECertificates {
|
|
||||||
Write-Info "Aktualisiere Internet Explorer/Edge Zertifikate..."
|
|
||||||
|
|
||||||
try {
|
|
||||||
# IE-Zertifikatscache leeren
|
|
||||||
Start-Process -FilePath "rundll32.exe" -ArgumentList "wininet.dll,DispatchAPICall 3" -Wait -NoNewWindow
|
|
||||||
|
|
||||||
Write-Success "IE/Edge Zertifikate aktualisiert"
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Write-Warning "Konnte IE/Edge Zertifikate nicht aktualisieren: $($_.Exception.Message)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Chrome/Chromium Zertifikate installieren
|
|
||||||
function Install-ChromeCertificates {
|
|
||||||
Write-Info "Installiere Chrome/Chromium Zertifikate..."
|
|
||||||
|
|
||||||
try {
|
|
||||||
# Chrome verwendet Windows-Zertifikatsspeicher, daher bereits installiert
|
|
||||||
Write-Success "Chrome verwendet Windows-Zertifikatsspeicher (bereits installiert)"
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Write-Warning "Chrome-Zertifikat-Installation fehlgeschlagen: $($_.Exception.Message)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Firefox Zertifikate installieren
|
|
||||||
function Install-FirefoxCertificates {
|
|
||||||
Write-Info "Installiere Firefox Zertifikate..."
|
|
||||||
|
|
||||||
try {
|
|
||||||
# Firefox-Profile finden
|
|
||||||
$firefoxProfiles = Get-ChildItem -Path "$env:APPDATA\Mozilla\Firefox\Profiles" -Directory -ErrorAction SilentlyContinue
|
|
||||||
|
|
||||||
if ($firefoxProfiles) {
|
|
||||||
foreach ($profile in $firefoxProfiles) {
|
|
||||||
$certdbPath = Join-Path $profile.FullName "cert9.db"
|
|
||||||
if (Test-Path $certdbPath) {
|
|
||||||
Write-Info "Firefox-Profil gefunden: $($profile.Name)"
|
|
||||||
# Hier würde normalerweise certutil verwendet werden
|
|
||||||
# Da certutil nicht standardmäßig verfügbar ist, überspringen wir dies
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Write-Success "Firefox-Profile verarbeitet"
|
|
||||||
} else {
|
|
||||||
Write-Info "Keine Firefox-Profile gefunden"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Write-Warning "Firefox-Zertifikat-Installation fehlgeschlagen: $($_.Exception.Message)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Python Zertifikate aktualisieren
|
|
||||||
function Update-PythonCertificates {
|
|
||||||
Write-Info "Aktualisiere Python-Zertifikate..."
|
|
||||||
|
|
||||||
try {
|
|
||||||
# Python certifi-Paket aktualisieren
|
|
||||||
if (Get-Command python -ErrorAction SilentlyContinue) {
|
|
||||||
python -m pip install --upgrade certifi --quiet
|
|
||||||
Write-Success "Python certifi-Paket aktualisiert"
|
|
||||||
} elseif (Get-Command python3 -ErrorAction SilentlyContinue) {
|
|
||||||
python3 -m pip install --upgrade certifi --quiet
|
|
||||||
Write-Success "Python3 certifi-Paket aktualisiert"
|
|
||||||
} else {
|
|
||||||
Write-Info "Python nicht gefunden - überspringe Python-Zertifikat-Update"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Write-Warning "Python-Zertifikat-Update fehlgeschlagen: $($_.Exception.Message)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Node.js Zertifikate konfigurieren
|
|
||||||
function Set-NodeJSCertificates {
|
|
||||||
Write-Info "Konfiguriere Node.js Zertifikate..."
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (Get-Command node -ErrorAction SilentlyContinue) {
|
|
||||||
# Umgebungsvariable für Node.js setzen
|
|
||||||
$certPath = (Resolve-Path "certs\mercedes\root\mercedes-root-ca.crt").Path
|
|
||||||
[Environment]::SetEnvironmentVariable("NODE_EXTRA_CA_CERTS", $certPath, "Machine")
|
|
||||||
|
|
||||||
Write-Success "Node.js Zertifikate konfiguriert"
|
|
||||||
} else {
|
|
||||||
Write-Info "Node.js nicht gefunden - überspringe Node.js-Konfiguration"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Write-Warning "Node.js-Zertifikat-Konfiguration fehlgeschlagen: $($_.Exception.Message)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Git Zertifikate konfigurieren
|
|
||||||
function Set-GitCertificates {
|
|
||||||
Write-Info "Konfiguriere Git Zertifikate..."
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (Get-Command git -ErrorAction SilentlyContinue) {
|
|
||||||
$certPath = (Resolve-Path "certs\mercedes\root\mercedes-root-ca.crt").Path
|
|
||||||
git config --global http.sslCAInfo $certPath
|
|
||||||
|
|
||||||
Write-Success "Git Zertifikate konfiguriert"
|
|
||||||
} else {
|
|
||||||
Write-Info "Git nicht gefunden - überspringe Git-Konfiguration"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Write-Warning "Git-Zertifikat-Konfiguration fehlgeschlagen: $($_.Exception.Message)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Umgebungsvariablen setzen
|
|
||||||
function Set-EnvironmentVariables {
|
|
||||||
Write-Info "Setze Umgebungsvariablen..."
|
|
||||||
|
|
||||||
try {
|
|
||||||
$certPath = (Resolve-Path "certs\mercedes\root\mercedes-root-ca.crt").Path
|
|
||||||
$certDir = (Resolve-Path "certs\mercedes\root").Path
|
|
||||||
|
|
||||||
# System-Umgebungsvariablen setzen
|
|
||||||
[Environment]::SetEnvironmentVariable("SSL_CERT_FILE", $certPath, "Machine")
|
|
||||||
[Environment]::SetEnvironmentVariable("SSL_CERT_DIR", $certDir, "Machine")
|
|
||||||
[Environment]::SetEnvironmentVariable("REQUESTS_CA_BUNDLE", $certPath, "Machine")
|
|
||||||
[Environment]::SetEnvironmentVariable("CURL_CA_BUNDLE", $certPath, "Machine")
|
|
||||||
|
|
||||||
# Für aktuelle Session
|
|
||||||
$env:SSL_CERT_FILE = $certPath
|
|
||||||
$env:SSL_CERT_DIR = $certDir
|
|
||||||
$env:REQUESTS_CA_BUNDLE = $certPath
|
|
||||||
$env:CURL_CA_BUNDLE = $certPath
|
|
||||||
|
|
||||||
Write-Success "Umgebungsvariablen gesetzt"
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Write-Warning "Umgebungsvariablen konnten nicht gesetzt werden: $($_.Exception.Message)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Zertifikat-Validierung
|
|
||||||
function Test-Certificates {
|
|
||||||
Write-Info "Validiere installierte Zertifikate..."
|
|
||||||
|
|
||||||
try {
|
|
||||||
# Windows-Zertifikatsspeicher prüfen
|
|
||||||
$installedCerts = Get-ChildItem -Path "Cert:\LocalMachine\Root" | Where-Object { $_.Subject -like "*Mercedes*" -or $_.Subject -like "*Daimler*" }
|
|
||||||
|
|
||||||
if ($installedCerts) {
|
|
||||||
Write-Success "Mercedes-Benz Zertifikate im Windows-Speicher gefunden: $($installedCerts.Count)"
|
|
||||||
} else {
|
|
||||||
Write-Warning "Keine Mercedes-Benz Zertifikate im Windows-Speicher gefunden"
|
|
||||||
}
|
|
||||||
|
|
||||||
# HTTPS-Verbindung testen
|
|
||||||
try {
|
|
||||||
$response = Invoke-WebRequest -Uri "https://httpbin.org/get" -UseBasicParsing -TimeoutSec 10
|
|
||||||
if ($response.StatusCode -eq 200) {
|
|
||||||
Write-Success "HTTPS-Verbindungstest erfolgreich"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Write-Warning "HTTPS-Verbindungstest fehlgeschlagen: $($_.Exception.Message)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Write-Warning "Zertifikat-Validierung fehlgeschlagen: $($_.Exception.Message)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Backup erstellen
|
|
||||||
function New-CertificateBackup {
|
|
||||||
Write-Info "Erstelle Backup der ursprünglichen Zertifikate..."
|
|
||||||
|
|
||||||
try {
|
|
||||||
$backupDate = Get-Date -Format "yyyyMMdd_HHmmss"
|
|
||||||
$backupPath = "certs\backup\windows-certs-$backupDate"
|
|
||||||
|
|
||||||
# Windows-Zertifikatsspeicher exportieren
|
|
||||||
$certs = Get-ChildItem -Path "Cert:\LocalMachine\Root"
|
|
||||||
$exportPath = "$backupPath\root-certificates.p7b"
|
|
||||||
|
|
||||||
New-Item -ItemType Directory -Path $backupPath -Force | Out-Null
|
|
||||||
|
|
||||||
# Alle Root-Zertifikate als Collection exportieren
|
|
||||||
$certCollection = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2Collection
|
|
||||||
foreach ($cert in $certs) {
|
|
||||||
$certCollection.Add($cert)
|
|
||||||
}
|
|
||||||
|
|
||||||
$bytes = $certCollection.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Pkcs7)
|
|
||||||
[System.IO.File]::WriteAllBytes($exportPath, $bytes)
|
|
||||||
|
|
||||||
Write-Success "Backup erstellt: $backupPath"
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Write-Warning "Backup-Erstellung fehlgeschlagen: $($_.Exception.Message)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Hauptfunktion
|
|
||||||
function Main {
|
|
||||||
Write-Info "Starte Mercedes-Benz Zertifikat-Installation für Windows..."
|
|
||||||
|
|
||||||
try {
|
|
||||||
New-CertificateBackup
|
|
||||||
New-CertificateDirectories
|
|
||||||
New-MercedesRootCertificates
|
|
||||||
Install-WindowsCertificates
|
|
||||||
Update-IECertificates
|
|
||||||
Install-ChromeCertificates
|
|
||||||
Install-FirefoxCertificates
|
|
||||||
Update-PythonCertificates
|
|
||||||
Set-NodeJSCertificates
|
|
||||||
Set-GitCertificates
|
|
||||||
Set-EnvironmentVariables
|
|
||||||
Test-Certificates
|
|
||||||
|
|
||||||
Write-Host ""
|
|
||||||
Write-Host "=================================================================="
|
|
||||||
Write-Success "$MERCEDES Mercedes-Benz Zertifikat-Installation abgeschlossen!"
|
|
||||||
Write-Host "=================================================================="
|
|
||||||
Write-Host ""
|
|
||||||
Write-Info "Nächste Schritte:"
|
|
||||||
Write-Host " 1. PowerShell/CMD neu starten für Umgebungsvariablen"
|
|
||||||
Write-Host " 2. Browser neu starten für Zertifikat-Erkennung"
|
|
||||||
Write-Host " 3. HTTPS-Verbindungen testen"
|
|
||||||
Write-Host ""
|
|
||||||
Write-Info "Backup-Verzeichnis: $(Resolve-Path 'certs\backup')"
|
|
||||||
Write-Info "Zertifikat-Verzeichnis: $(Resolve-Path 'certs\mercedes')"
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Write-Error "Installation fehlgeschlagen: $($_.Exception.Message)"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Skript ausführen
|
|
||||||
Main
|
|
Loading…
x
Reference in New Issue
Block a user