Skip to content

Commit 9a3f570

Browse files
updates on checking with test
1 parent 85e887d commit 9a3f570

1 file changed

Lines changed: 194 additions & 72 deletions

File tree

.github/workflows/windows-cert-store-test.yml

Lines changed: 194 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -345,34 +345,60 @@ jobs:
345345
}
346346
}
347347
348-
# If not found in common paths, search recursively
348+
# If not found in common paths, search recursively (more broadly)
349349
if (-not $wolfsslDll) {
350-
Write-Host "Not found in common paths, searching recursively..."
351-
$wolfsslDll = Get-ChildItem -Path $wolfsslRoot -Recurse -Filter "wolfssl.dll" -ErrorAction SilentlyContinue |
352-
Where-Object {
353-
$_.FullName -like "*$buildConfig*" -and
354-
($_.FullName -like "*$buildPlatform*" -or $_.DirectoryName -notlike "*Debug*")
355-
} |
356-
Select-Object -First 1
350+
Write-Host "Not found in common paths, searching recursively (all DLLs)..."
351+
$allDlls = Get-ChildItem -Path $wolfsslRoot -Recurse -Filter "*.dll" -ErrorAction SilentlyContinue
352+
Write-Host "Found $($allDlls.Count) DLL files total in wolfSSL directory"
353+
354+
# Try to find wolfssl.dll specifically
355+
$wolfsslDll = $allDlls | Where-Object { $_.Name -eq "wolfssl.dll" } | Select-Object -First 1
356+
357+
if (-not $wolfsslDll) {
358+
Write-Host "wolfssl.dll not found. Listing all DLL files:"
359+
$allDlls | Select-Object FullName, Length, LastWriteTime | Format-Table -AutoSize
360+
361+
# Check if it might be in a different location or named differently
362+
Write-Host "Checking for similar DLL names..."
363+
$similarDlls = $allDlls | Where-Object { $_.Name -like "*wolf*" -or $_.Name -like "*ssl*" }
364+
if ($similarDlls) {
365+
Write-Host "Found similar DLLs:"
366+
$similarDlls | Select-Object FullName, Name | Format-Table
367+
}
368+
}
357369
}
358370
359371
if ($wolfsslDll) {
360372
$targetDll = Join-Path $sshdDir "wolfssl.dll"
361373
Write-Host "Copying wolfssl.dll from: $($wolfsslDll.FullName)"
362374
Write-Host "Copying to: $targetDll"
375+
376+
# Ensure target directory exists
377+
if (-not (Test-Path $sshdDir)) {
378+
Write-Host "ERROR: Target directory does not exist: $sshdDir"
379+
exit 1
380+
}
381+
363382
Copy-Item -Path $wolfsslDll.FullName -Destination $targetDll -Force
383+
Start-Sleep -Milliseconds 500 # Give filesystem time to sync
384+
364385
if (Test-Path $targetDll) {
365-
Write-Host "Successfully copied wolfssl.dll"
386+
$copiedDll = Get-Item $targetDll
387+
Write-Host "✓ Successfully copied wolfssl.dll"
388+
Write-Host " Size: $($copiedDll.Length) bytes"
389+
Write-Host " Location: $targetDll"
366390
} else {
367391
Write-Host "ERROR: Copy failed - target file not found after copy"
392+
Write-Host "Source file exists: $(Test-Path $wolfsslDll.FullName)"
393+
Write-Host "Target directory exists: $(Test-Path $sshdDir)"
394+
Write-Host "Target directory contents:"
395+
Get-ChildItem -Path $sshdDir | Select-Object Name | Format-Table
368396
exit 1
369397
}
370398
} else {
371-
Write-Host "WARNING: wolfssl.dll not found"
372-
Write-Host "Listing all DLL files in wolfSSL directory:"
373-
Get-ChildItem -Path $wolfsslRoot -Recurse -Filter "*.dll" -ErrorAction SilentlyContinue |
374-
Where-Object { $_.FullName -like "*$buildConfig*" } |
375-
Select-Object FullName | Format-Table
399+
Write-Host "ERROR: wolfssl.dll not found - service will likely fail to start"
400+
Write-Host "This is a critical error. The DLL must be available for the service to run."
401+
# Don't exit here - let the service start attempt show the actual error
376402
}
377403
378404
# Also copy wolfssl.lib if found
@@ -475,65 +501,44 @@ jobs:
475501
476502
Write-Host "Host key configuration verified: OK"
477503
478-
- name: Test wolfSSHd startup (diagnostic)
504+
- name: Verify dependencies and environment
479505
working-directory: ${{ github.workspace }}\wolfssh
480506
shell: pwsh
481507
run: |
482508
$sshdPath = (Get-Content env:SSHD_PATH)
483-
if (-not (Test-Path $sshdPath)) {
484-
Write-Host "ERROR: wolfsshd.exe not found at $sshdPath"
485-
exit 1
509+
$sshdDir = Split-Path -Parent $sshdPath
510+
511+
Write-Host "=== Verifying wolfsshd.exe environment ==="
512+
Write-Host "Executable: $sshdPath"
513+
Write-Host "Directory: $sshdDir"
514+
515+
# Check if DLL is present
516+
$dllPath = Join-Path $sshdDir "wolfssl.dll"
517+
if (Test-Path $dllPath) {
518+
Write-Host "✓ wolfssl.dll found"
519+
$dllInfo = Get-Item $dllPath
520+
Write-Host " Size: $($dllInfo.Length) bytes"
521+
Write-Host " Modified: $($dllInfo.LastWriteTime)"
522+
} else {
523+
Write-Host "✗ wolfssl.dll NOT FOUND in $sshdDir"
524+
Write-Host "Files in directory:"
525+
Get-ChildItem -Path $sshdDir | Select-Object Name, Length | Format-Table
486526
}
487527
528+
# Check config file
488529
$configPath = "sshd_config_test"
489-
if (-not (Test-Path $configPath)) {
490-
Write-Host "ERROR: Config file not found: $configPath"
491-
exit 1
530+
if (Test-Path $configPath) {
531+
Write-Host "✓ Config file found: $configPath"
532+
} else {
533+
Write-Host "✗ Config file NOT FOUND: $configPath"
492534
}
493535
494-
Write-Host "=== Testing wolfsshd.exe startup (direct run) ==="
495-
Write-Host "Executable: $sshdPath"
496-
Write-Host "Config: $configPath"
497-
498-
# Try to run it directly to see error messages
499-
$processInfo = New-Object System.Diagnostics.ProcessStartInfo
500-
$processInfo.FileName = $sshdPath
501-
$processInfo.Arguments = "-f $configPath -p ${{env.TEST_PORT}}"
502-
$processInfo.UseShellExecute = $false
503-
$processInfo.RedirectStandardOutput = $true
504-
$processInfo.RedirectStandardError = $true
505-
$processInfo.CreateNoWindow = $true
506-
507-
$process = New-Object System.Diagnostics.Process
508-
$process.StartInfo = $processInfo
509-
510-
try {
511-
$process.Start() | Out-Null
512-
Start-Sleep -Seconds 2
513-
514-
if (-not $process.HasExited) {
515-
Write-Host "Process is running (good sign)"
516-
$process.Kill()
517-
$process.WaitForExit(5000)
518-
} else {
519-
Write-Host "Process exited immediately (exit code: $($process.ExitCode))"
520-
$stdout = $process.StandardOutput.ReadToEnd()
521-
$stderr = $process.StandardError.ReadToEnd()
522-
if ($stdout) {
523-
Write-Host "STDOUT: $stdout"
524-
}
525-
if ($stderr) {
526-
Write-Host "STDERR: $stderr"
527-
}
528-
}
529-
} catch {
530-
Write-Host "ERROR running process: $_"
531-
} finally {
532-
if (-not $process.HasExited) {
533-
$process.Kill()
534-
}
535-
$process.Dispose()
536-
}
536+
# Note: Direct execution will fail with "StartServiceCtrlDispatcher failed"
537+
# This is expected - the executable is built as a service and must run via SCM
538+
Write-Host ""
539+
Write-Host "Note: wolfsshd.exe is built as a Windows service."
540+
Write-Host "Direct execution will fail (this is expected)."
541+
Write-Host "It must be started via Service Control Manager (sc.exe)."
537542
538543
- name: Start wolfSSHd as Windows service
539544
working-directory: ${{ github.workspace }}\wolfssh
@@ -564,8 +569,70 @@ jobs:
564569
Start-Sleep -Seconds 2
565570
}
566571
572+
# Verify DLL is present before creating service
573+
$sshdDir = Split-Path -Parent $sshdPathFull
574+
$dllPath = Join-Path $sshdDir "wolfssl.dll"
575+
Write-Host "=== Pre-service checks ==="
576+
Write-Host "Executable: $sshdPathFull"
577+
Write-Host "Config: $configPathFull"
578+
Write-Host "DLL path: $dllPath"
579+
Write-Host "Working directory (sshd dir): $sshdDir"
580+
581+
# Verify DLL exists - this is critical
582+
if (-not (Test-Path $dllPath)) {
583+
Write-Host "ERROR: wolfssl.dll not found at $dllPath"
584+
Write-Host "This will cause the service to fail immediately!"
585+
Write-Host "Files in $sshdDir :"
586+
Get-ChildItem -Path $sshdDir | Select-Object Name, Length, LastWriteTime | Format-Table
587+
Write-Host ""
588+
Write-Host "Attempting to find and copy DLL now..."
589+
590+
# Try to find and copy DLL one more time
591+
$wolfsslRoot = "${{ github.workspace }}\wolfssl"
592+
$buildConfig = "${{env.WOLFSSL_BUILD_CONFIGURATION}}"
593+
$buildPlatform = "${{env.BUILD_PLATFORM}}"
594+
595+
$allDlls = Get-ChildItem -Path $wolfsslRoot -Recurse -Filter "wolfssl.dll" -ErrorAction SilentlyContinue
596+
if ($allDlls) {
597+
$wolfsslDll = $allDlls | Select-Object -First 1
598+
Write-Host "Found wolfssl.dll at: $($wolfsslDll.FullName)"
599+
Copy-Item -Path $wolfsslDll.FullName -Destination $dllPath -Force
600+
Start-Sleep -Milliseconds 500
601+
if (Test-Path $dllPath) {
602+
Write-Host "✓ Successfully copied DLL"
603+
} else {
604+
Write-Host "ERROR: Copy still failed"
605+
exit 1
606+
}
607+
} else {
608+
Write-Host "ERROR: Could not find wolfssl.dll anywhere in $wolfsslRoot"
609+
Write-Host "This is a critical error - the service cannot start without the DLL"
610+
exit 1
611+
}
612+
} else {
613+
Write-Host "✓ wolfssl.dll found"
614+
$dllInfo = Get-Item $dllPath
615+
Write-Host " Size: $($dllInfo.Length) bytes"
616+
}
617+
618+
if (-not (Test-Path $configPathFull)) {
619+
Write-Host "ERROR: Config file not found: $configPathFull"
620+
exit 1
621+
} else {
622+
Write-Host "✓ Config file found"
623+
# Verify config file is readable
624+
try {
625+
$configContent = Get-Content $configPathFull -Raw
626+
Write-Host " Size: $($configContent.Length) bytes"
627+
} catch {
628+
Write-Host "ERROR: Cannot read config file: $_"
629+
exit 1
630+
}
631+
}
632+
567633
# Create the service with proper binpath
568-
# binpath format: "path\to\exe" -f "config" -p port
634+
# Note: sc.exe requires the binPath to have the executable path and arguments
635+
# The entire command line goes in binPath, with the exe path in quotes
569636
$binPath = "`"$sshdPathFull`" -f `"$configPathFull`" -p ${{env.TEST_PORT}}"
570637
Write-Host "Creating service with binpath: $binPath"
571638
@@ -577,6 +644,10 @@ jobs:
577644
}
578645
Write-Host "Service created: $createResult"
579646
647+
# Set service to auto-start on failure (for debugging)
648+
# This won't help if it exits cleanly, but might help with crashes
649+
sc.exe failure $serviceName reset= 86400 actions= restart/5000/restart/5000/restart/5000 | Out-Null
650+
580651
# Start the service
581652
Write-Host "Starting $serviceName service"
582653
$startResult = sc.exe start $serviceName
@@ -590,7 +661,7 @@ jobs:
590661
Write-Host "Service started: $startResult"
591662
592663
# Wait a bit for service to start
593-
Start-Sleep -Seconds 3
664+
Start-Sleep -Seconds 5
594665
595666
# Check service status
596667
$service = Get-Service -Name $serviceName -ErrorAction SilentlyContinue
@@ -601,21 +672,72 @@ jobs:
601672
602673
if ($service.Status -ne 'Running') {
603674
Write-Host "ERROR: Service is not running. Status: $($service.Status)"
604-
# Get more details
675+
676+
# Get detailed service information
605677
Write-Host "=== Service Query ==="
606678
sc.exe query $serviceName
607-
Write-Host "=== Event Log (last 20 entries) ==="
608-
Get-EventLog -LogName Application -Source "wolfsshd" -Newest 20 -ErrorAction SilentlyContinue | Format-List
609-
Get-EventLog -LogName System -Source "Service Control Manager" -Newest 10 -ErrorAction SilentlyContinue |
610-
Where-Object { $_.Message -like "*wolfsshd*" } | Format-List
679+
680+
# Get service configuration to see the actual command
681+
Write-Host "=== Service Configuration ==="
682+
sc.exe qc $serviceName
683+
684+
# Check service error code and details
685+
Write-Host "=== Service Error Code ==="
686+
$serviceInfo = Get-CimInstance -ClassName Win32_Service -Filter "Name='$serviceName'" -ErrorAction SilentlyContinue
687+
if ($serviceInfo) {
688+
Write-Host "ExitCode: $($serviceInfo.ExitCode)"
689+
Write-Host "State: $($serviceInfo.State)"
690+
Write-Host "Status: $($serviceInfo.Status)"
691+
Write-Host "PathName: $($serviceInfo.PathName)"
692+
Write-Host "StartMode: $($serviceInfo.StartMode)"
693+
}
694+
695+
# Try to get process exit code if it ran briefly
696+
Write-Host "=== Checking for recent process exit ==="
697+
$recentProcesses = Get-WinEvent -FilterHashtable @{LogName='System'; ID=7034,7035,7036} -MaxEvents 50 -ErrorAction SilentlyContinue |
698+
Where-Object { $_.Message -like "*wolfsshd*" } |
699+
Select-Object -First 5
700+
if ($recentProcesses) {
701+
Write-Host "Recent service events:"
702+
$recentProcesses | ForEach-Object { Write-Host " $($_.TimeCreated): $($_.Message)" }
703+
}
704+
705+
# Check event logs for errors
706+
Write-Host "=== System Event Log (Service Control Manager) ==="
707+
Get-EventLog -LogName System -Source "Service Control Manager" -Newest 20 -ErrorAction SilentlyContinue |
708+
Where-Object { $_.Message -like "*wolfsshd*" -or $_.Message -like "*$serviceName*" } |
709+
Select-Object TimeGenerated, EntryType, Message | Format-List
710+
711+
Write-Host "=== Application Event Log ==="
712+
Get-EventLog -LogName Application -Newest 30 -ErrorAction SilentlyContinue |
713+
Where-Object { $_.Source -like "*wolf*" -or $_.Message -like "*wolf*" } |
714+
Select-Object TimeGenerated, Source, EntryType, Message | Format-List
715+
716+
# Check if DLL is accessible from service context
717+
Write-Host "=== Checking DLL accessibility ==="
718+
$sshdDir = Split-Path -Parent $sshdPathFull
719+
$dllPath = Join-Path $sshdDir "wolfssl.dll"
720+
Write-Host "DLL path: $dllPath"
721+
if (Test-Path $dllPath) {
722+
Write-Host "DLL exists: YES"
723+
$dllInfo = Get-Item $dllPath
724+
Write-Host "DLL size: $($dllInfo.Length) bytes"
725+
} else {
726+
Write-Host "DLL exists: NO - This is likely the problem!"
727+
Write-Host "Files in $sshdDir :"
728+
Get-ChildItem -Path $sshdDir | Select-Object Name, Length | Format-Table
729+
}
730+
731+
# Check if process is running
611732
Write-Host "=== Checking if process is running ==="
612733
$processes = Get-Process | Where-Object { $_.ProcessName -like "*wolfsshd*" }
613734
if ($processes) {
614735
Write-Host "Found processes:"
615-
$processes | Format-Table Id, ProcessName, StartTime
736+
$processes | Format-Table Id, ProcessName, StartTime, Path
616737
} else {
617738
Write-Host "No wolfsshd processes found"
618739
}
740+
619741
exit 1
620742
}
621743

0 commit comments

Comments
 (0)