====== 3.4 Linux Build (WSL) ====== Diese Anleitung zeigt, wie Sie OpenSSL unter Linux in WSL2 kompilieren. ---- ===== Wann brauche ich einen Linux-Build? ===== ^ Anwendung ^ Linux-Build nötig? ^ | Docker Container | **Ja** | | Linux Server | **Ja** | | L4Re Microkernel | **Ja** (Cross-Compilation für aarch64) | | .NET auf Windows | Nein (Windows-Build nutzen) | | WASM/Blazor | Separat (siehe WASM Build) | ---- ===== Voraussetzungen ===== * ☑ WSL2 mit Ubuntu 24.04 LTS (empfohlen) oder Fedora * ☑ Build-Werkzeuge installiert * ☑ Für aarch64: Cross-Compiler installiert → [[.:vorbereitung:wsl-einrichten|WSL einrichten]] ---- ===== WSL2 Ubuntu 24.04 Installation ===== # PowerShell (Administrator) wsl --install Ubuntu-24.04 --no-launch wsl -d Ubuntu-24.04 ---- ===== Build-Schritte ===== ==== Schritt 1: Build-Abhängigkeiten installieren ==== **Ubuntu 24.04 (empfohlen):** sudo apt-get update sudo apt-get install -y \ build-essential \ perl \ git \ wget \ file # Für aarch64 Cross-Compilation: sudo apt-get install -y \ gcc-aarch64-linux-gnu \ g++-aarch64-linux-gnu \ binutils-aarch64-linux-gnu **Fedora:** sudo dnf install -y gcc make perl git wget file # Cross-Compiler für aarch64 sind in Fedora schwieriger zu installieren # Ubuntu 24.04 wird empfohlen ==== Schritt 2: Quellen zum Linux-Dateisystem kopieren ==== **WICHTIG: NTFS-Symlink-Problem** Der Build direkt auf dem Windows-Dateisystem (''/mnt/d/...'') schlägt fehl, weil NTFS keine Linux-Symlinks unterstützt. OpenSSL erstellt Symlinks wie ''libcrypto.so → libcrypto.so.3''. **Lösung:** Quellen immer ins Linux-Dateisystem (''/opt/...'') kopieren! # Build-Verzeichnis erstellen sudo mkdir -p /opt/openssl-build sudo chown $(id -u):$(id -g) /opt/openssl-build # Windows-Laufwerk mounten (falls nicht auto-gemountet) sudo mkdir -p /mnt/d sudo mount -t drvfs D: /mnt/d 2>/dev/null || true # Quellen kopieren (mit tar für vollständige Kopie) cd /mnt/d/Workspace/openssl-3.6.0/l4re/src tar cf - . | tar xf - -C /opt/openssl-build ==== Schritt 3: Konfigurieren (x86_64) ==== cd /opt/openssl-build # Standard-Konfiguration ./Configure linux-x86_64 \ --prefix=/opt/openssl-3.6 \ --openssldir=/opt/openssl-3.6/ssl \ shared # ODER mit FIPS-Modul (empfohlen für Produktion): ./Configure linux-x86_64 \ --prefix=/opt/openssl-3.6 \ --openssldir=/opt/openssl-3.6/ssl \ enable-fips \ shared ==== Schritt 4: Kompilieren ==== # Mit allen CPU-Kernen bauen make -j$(nproc) ''$(nproc)'' gibt die Anzahl der CPU-Kerne zurück. Auf einer 8-Kern-CPU: ''make -j8'' ==== Schritt 5: Installieren ==== sudo make install ---- ===== aarch64 Cross-Compilation (für L4Re/ARM64) ===== Für ARM64-Targets wie L4Re Microkernel: # Separates Build-Verzeichnis für aarch64 sudo rm -rf /opt/openssl-aarch64-build sudo mkdir -p /opt/openssl-aarch64-build sudo chown $(id -u):$(id -g) /opt/openssl-aarch64-build # Quellen kopieren cd /mnt/d/Workspace/openssl-3.6.0/l4re/src tar cf - . | tar xf - -C /opt/openssl-aarch64-build # Konfigurieren für aarch64 cd /opt/openssl-aarch64-build ./Configure linux-aarch64 \ --cross-compile-prefix=aarch64-linux-gnu- \ --prefix=/opt/openssl-3.6-aarch64 \ --openssldir=/opt/openssl-3.6-aarch64/ssl \ shared \ enable-fips \ no-async # Bauen make -j$(nproc) # Ergebnis prüfen file libcrypto.so.3 # Erwartete Ausgabe: ELF 64-bit LSB shared object, ARM aarch64 ---- ===== Ergebnis ===== ==== x86_64 Build Output ==== /opt/openssl-3.6/ ├── bin/ │ └── openssl # CLI Tool ├── include/ │ └── openssl/ # Header für FFI ├── lib64/ │ ├── libcrypto.so.3 # ~7.4 MB - Crypto Library │ ├── libssl.so.3 # ~1.3 MB - SSL/TLS Library │ ├── libcrypto.a # Static Library │ ├── libssl.a │ └── ossl-modules/ │ └── fips.so # ~3.2 MB - FIPS Provider └── ssl/ ├── openssl.cnf └── fipsmodule.cnf # FIPS-Konfiguration ==== aarch64 Build Output ==== ^ Datei ^ Größe ^ Beschreibung ^ | ''libcrypto.so.3'' | ~6.8 MB | Crypto Library (ARM64) | | ''libssl.so.3'' | ~1.2 MB | SSL/TLS Library (ARM64) | | ''fips.so'' | ~2.3 MB | FIPS Provider (ARM64) | | ''fipsmodule.cnf'' | ~1 KB | FIPS-Konfiguration | ---- ===== Testen ===== # Version prüfen /opt/openssl-3.6/bin/openssl version -a # Erwartete Ausgabe: OpenSSL 3.6.0 1 Oct 2025 # Provider prüfen (FIPS sollte aufgelistet sein) /opt/openssl-3.6/bin/openssl list -providers # Post-Quantum Algorithmen prüfen /opt/openssl-3.6/bin/openssl list -signature-algorithms | grep -i mldsa /opt/openssl-3.6/bin/openssl list -kem-algorithms | grep -i mlkem # Shared Library Format prüfen file /opt/openssl-3.6/lib64/libcrypto.so.3 # x86_64: ELF 64-bit LSB shared object, x86-64 ---- ===== Ergebnisse nach Windows kopieren ===== # x86_64 Libraries mkdir -p /mnt/d/Workspace/openssl-3.6.0/l4re/bin/x86_64 cp /opt/openssl-3.6/lib64/libcrypto.so.3 /mnt/d/Workspace/openssl-3.6.0/l4re/bin/x86_64/ cp /opt/openssl-3.6/lib64/libssl.so.3 /mnt/d/Workspace/openssl-3.6.0/l4re/bin/x86_64/ cp /opt/openssl-3.6/lib64/ossl-modules/fips.so /mnt/d/Workspace/openssl-3.6.0/l4re/bin/x86_64/ cp /opt/openssl-3.6/ssl/fipsmodule.cnf /mnt/d/Workspace/openssl-3.6.0/l4re/bin/x86_64/ # aarch64 Libraries mkdir -p /mnt/d/Workspace/openssl-3.6.0/l4re/bin/aarch64 cp /opt/openssl-aarch64-build/libcrypto.so.3 /mnt/d/Workspace/openssl-3.6.0/l4re/bin/aarch64/ cp /opt/openssl-aarch64-build/libssl.so.3 /mnt/d/Workspace/openssl-3.6.0/l4re/bin/aarch64/ cp /opt/openssl-aarch64-build/providers/fips.so /mnt/d/Workspace/openssl-3.6.0/l4re/bin/aarch64/ cp /opt/openssl-aarch64-build/providers/fipsmodule.cnf /mnt/d/Workspace/openssl-3.6.0/l4re/bin/aarch64/ ---- ===== Für Docker-Images ===== ==== Dockerfile Beispiel ==== FROM ubuntu:24.04 AS builder # Build-Tools installieren RUN apt-get update && apt-get install -y \ build-essential perl git wget file # OpenSSL Quellen kopieren COPY openssl-src/ /build/src/ # Bauen mit FIPS WORKDIR /build/src RUN ./Configure linux-x86_64 enable-fips --prefix=/opt/openssl && \ make -j$(nproc) && \ make install # Runtime Image FROM ubuntu:24.04 # Nur die fertigen Binaries kopieren COPY --from=builder /opt/openssl /opt/openssl # Pfad setzen ENV PATH="/opt/openssl/bin:$PATH" ENV LD_LIBRARY_PATH="/opt/openssl/lib64:$LD_LIBRARY_PATH" ==== Multi-Stage Build für .NET ==== FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build # OpenSSL-Libraries kopieren COPY --from=openssl-builder /opt/openssl/lib64/libcrypto.so.3 /app/ COPY --from=openssl-builder /opt/openssl/lib64/libssl.so.3 /app/ WORKDIR /src COPY . . RUN dotnet build -c Release ---- ===== Fehlerbehebung ===== ==== "ln: failed to create symbolic link: Operation not permitted" ==== **Problem:** Build auf NTFS-Dateisystem (''/mnt/d/...'') **Lösung:** Quellen ins Linux-Dateisystem kopieren (siehe Schritt 2) ==== USB-Laufwerke werden nicht erkannt ==== **Problem:** USB-Datenträger (externe Festplatten, USB-Sticks) werden in WSL2 nicht automatisch gemountet. **Lösung:** Manuell mounten mit ''metadata''-Flag: sudo mkdir -p /mnt/d sudo mount -t drvfs D: /mnt/d -o metadata Ohne ''metadata''-Flag werden Dateien möglicherweise nicht korrekt auf das Windows-Dateisystem geschrieben! ==== "Can't locate OpenSSL/fallback.pm" ==== **Problem:** Unvollständige Quellen (''util/perl/'' fehlt) **Lösung:** Quellen mit ''tar'' kopieren statt ''cp -r'' ==== Cross-Compilation: "file in wrong format" ==== **Problem:** Alte x86_64-Artefakte im Build-Verzeichnis **Lösung:** ''make clean'' vor dem Build ausführen ---- ===== Weiter zu ===== * [[.:vorbereitung:wsl-einrichten|WSL einrichten]] * [[.:testen:start|4. Testen]] * [[.:build:start|Zurück zur Build-Übersicht]] ---- //Wolfgang van der Stille @ EMSR DATA d.o.o. - Post-Quantum Cryptography Professional// //Letzte Aktualisierung: 2025-12-16 (verifiziert mit OpenSSL 3.6.0)//