@@ -225,22 +225,38 @@ jobs:
225225 if ("${{ matrix.server_key_source }}" -eq "store") {
226226 # Get server cert subject from environment
227227 $serverSubject = (Get-Content env:SERVER_CERT_SUBJECT)
228+ if ([string]::IsNullOrEmpty($serverSubject)) {
229+ Write-Host "ERROR: SERVER_CERT_SUBJECT not set"
230+ exit 1
231+ }
232+ Write-Host "Using cert store host key with subject: $serverSubject"
228233 $configContent += @"
229234
230235 HostKeyStore My
231236 HostKeyStoreSubject $serverSubject
232237 HostKeyStoreFlags CURRENT_USER
233238 "@
234239 } else {
240+ # Use absolute path for file-based key
241+ $keyPath = Join-Path "${{ github.workspace }}" "wolfssh\keys\server-key-rsa.der"
242+ $keyPathFull = (Resolve-Path $keyPath -ErrorAction SilentlyContinue)
243+ if (-not $keyPathFull) {
244+ Write-Host "ERROR: Host key file not found at: $keyPath"
245+ Write-Host "Checking for key files..."
246+ Get-ChildItem -Path "${{ github.workspace }}\wolfssh\keys" -Filter "server-key*.der" | Select-Object FullName
247+ exit 1
248+ }
249+ Write-Host "Using file-based host key: $($keyPathFull.Path)"
235250 $configContent += @"
236251
237- HostKey keys\server-key-rsa.der
252+ HostKey $($keyPathFull.Path)
238253 "@
239254 }
240255
241256 $configContent | Out-File -FilePath sshd_config_test -Encoding ASCII
242257 Write-Host "=== wolfSSHd Config ==="
243258 Get-Content sshd_config_test
259+ Write-Host "=== End Config ==="
244260
245261 - name : Find wolfSSH executables
246262 working-directory : ${{ github.workspace }}\wolfssh
@@ -291,6 +307,126 @@ jobs:
291307 Write-Host "WARNING: wolfssh.exe not found (SSH client test will be skipped)"
292308 }
293309
310+ - name : Copy wolfSSL DLL to executable directory
311+ working-directory : ${{ github.workspace }}
312+ shell : pwsh
313+ run : |
314+ $sshdPath = (Get-Content env:SSHD_PATH)
315+ if (-not (Test-Path $sshdPath)) {
316+ Write-Host "ERROR: wolfsshd.exe path not found in environment"
317+ exit 1
318+ }
319+
320+ $sshdDir = Split-Path -Parent $sshdPath
321+ Write-Host "wolfsshd.exe directory: $sshdDir"
322+
323+ # Find wolfssl.dll in wolfSSL build output
324+ $searchRoot = "${{ github.workspace }}\wolfssl"
325+ $wolfsslDll = Get-ChildItem -Path $searchRoot -Recurse -Filter "wolfssl.dll" -ErrorAction SilentlyContinue |
326+ Where-Object { $_.FullName -like "*Release*" -or $_.FullName -like "*Debug*" } |
327+ Select-Object -First 1
328+
329+ if ($wolfsslDll) {
330+ $targetDll = Join-Path $sshdDir "wolfssl.dll"
331+ Write-Host "Found wolfssl.dll at: $($wolfsslDll.FullName)"
332+ Write-Host "Copying to: $targetDll"
333+ Copy-Item -Path $wolfsslDll.FullName -Destination $targetDll -Force
334+ Write-Host "Successfully copied wolfssl.dll"
335+ } else {
336+ Write-Host "WARNING: wolfssl.dll not found - checking for static build"
337+ # Check if it's a static build (no DLL needed)
338+ $wolfsslLib = Get-ChildItem -Path $searchRoot -Recurse -Filter "wolfssl.lib" -ErrorAction SilentlyContinue |
339+ Where-Object { $_.FullName -like "*Release*" -or $_.FullName -like "*Debug*" } |
340+ Select-Object -First 1
341+ if ($wolfsslLib) {
342+ Write-Host "Found wolfssl.lib (static build) - DLL not needed at runtime"
343+ } else {
344+ Write-Host "WARNING: Neither wolfssl.dll nor wolfssl.lib found"
345+ Write-Host "Searching for any wolfssl files..."
346+ Get-ChildItem -Path $searchRoot -Recurse -Filter "wolfssl.*" -ErrorAction SilentlyContinue |
347+ Select-Object FullName | Format-Table
348+ }
349+ }
350+
351+ # Also check for wolfssl.lib if user specifically needs it
352+ $wolfsslLib = Get-ChildItem -Path $searchRoot -Recurse -Filter "wolfssl.lib" -ErrorAction SilentlyContinue |
353+ Where-Object { $_.FullName -like "*Release*" -or $_.FullName -like "*Debug*" } |
354+ Select-Object -First 1
355+
356+ if ($wolfsslLib) {
357+ $targetLib = Join-Path $sshdDir "wolfssl.lib"
358+ Write-Host "Found wolfssl.lib at: $($wolfsslLib.FullName)"
359+ Write-Host "Copying to: $targetLib"
360+ Copy-Item -Path $wolfsslLib.FullName -Destination $targetLib -Force
361+ Write-Host "Successfully copied wolfssl.lib"
362+ }
363+
364+ - name : Verify host key configuration
365+ working-directory : ${{ github.workspace }}\wolfssh
366+ shell : pwsh
367+ run : |
368+ Write-Host "=== Verifying Host Key Configuration ==="
369+ $configPath = "sshd_config_test"
370+ if (-not (Test-Path $configPath)) {
371+ Write-Host "ERROR: Config file not found: $configPath"
372+ exit 1
373+ }
374+
375+ $configContent = Get-Content $configPath -Raw
376+ Write-Host "Config file content:"
377+ Write-Host $configContent
378+
379+ # Check if host key is configured
380+ $hasHostKey = $false
381+ if ($configContent -match "HostKey\s+") {
382+ Write-Host "Found HostKey directive (file-based)"
383+ $hasHostKey = $true
384+ # Verify the key file exists
385+ if ($configContent -match "HostKey\s+([^\r\n]+)") {
386+ $keyPath = $matches[1].Trim()
387+ Write-Host "Host key path: $keyPath"
388+ if (Test-Path $keyPath) {
389+ Write-Host "Host key file exists: OK"
390+ } else {
391+ Write-Host "ERROR: Host key file not found: $keyPath"
392+ exit 1
393+ }
394+ }
395+ }
396+ if ($configContent -match "HostKeyStore\s+") {
397+ Write-Host "Found HostKeyStore directive (cert store-based)"
398+ $hasHostKey = $true
399+ # Verify cert store subject is set
400+ if ($configContent -match "HostKeyStoreSubject\s+([^\r\n]+)") {
401+ $subject = $matches[1].Trim()
402+ Write-Host "Host key store subject: $subject"
403+ if ([string]::IsNullOrEmpty($subject)) {
404+ Write-Host "ERROR: HostKeyStoreSubject is empty"
405+ exit 1
406+ }
407+ # Verify cert exists in store
408+ $cert = Get-ChildItem -Path "Cert:\CurrentUser\My" | Where-Object { $_.Subject -eq $subject } | Select-Object -First 1
409+ if ($cert) {
410+ Write-Host "Certificate found in store: OK (Thumbprint: $($cert.Thumbprint))"
411+ } else {
412+ Write-Host "ERROR: Certificate not found in store with subject: $subject"
413+ Write-Host "Available certificates in Cert:\CurrentUser\My:"
414+ Get-ChildItem -Path "Cert:\CurrentUser\My" | Select-Object Subject, Thumbprint | Format-Table
415+ exit 1
416+ }
417+ } else {
418+ Write-Host "ERROR: HostKeyStoreSubject not found in config"
419+ exit 1
420+ }
421+ }
422+
423+ if (-not $hasHostKey) {
424+ Write-Host "ERROR: No host key configuration found in config file!"
425+ exit 1
426+ }
427+
428+ Write-Host "Host key configuration verified: OK"
429+
294430 - name : Start wolfSSHd as Windows service
295431 working-directory : ${{ github.workspace }}\wolfssh
296432 shell : pwsh
@@ -358,7 +494,20 @@ jobs:
358494 if ($service.Status -ne 'Running') {
359495 Write-Host "ERROR: Service is not running. Status: $($service.Status)"
360496 # Get more details
497+ Write-Host "=== Service Query ==="
361498 sc.exe query $serviceName
499+ Write-Host "=== Event Log (last 20 entries) ==="
500+ Get-EventLog -LogName Application -Source "wolfsshd" -Newest 20 -ErrorAction SilentlyContinue | Format-List
501+ Get-EventLog -LogName System -Source "Service Control Manager" -Newest 10 -ErrorAction SilentlyContinue |
502+ Where-Object { $_.Message -like "*wolfsshd*" } | Format-List
503+ Write-Host "=== Checking if process is running ==="
504+ $processes = Get-Process | Where-Object { $_.ProcessName -like "*wolfsshd*" }
505+ if ($processes) {
506+ Write-Host "Found processes:"
507+ $processes | Format-Table Id, ProcessName, StartTime
508+ } else {
509+ Write-Host "No wolfsshd processes found"
510+ }
362511 exit 1
363512 }
364513
0 commit comments