Skip to content

"(IOException): The handle is invalid" when running wacs.exe in some consoles #2519

@davist

Description

@davist

Describe the bug
Running wacs.exe (with or without arguments) in some Windows consoles results in "(IOException): The handle is invalid" error.

  • Fails in: PowerShell ISE, Azure VM RunPowerShellScript
  • Works in: PowerShell, Command Prompt

To Reproduce

  1. Open PowerShell ISE
  2. run wacs.exe

This error is on v2.2.7. It works with v2.2.6.

Log
With --verbose:

 [DBUG] Exception details: IOException {TargetSite=CONSOLE_SCREEN_BUFFER_INFO GetBufferInfo(Boolean, Boolean ByRef), Message="The handle is invalid.", Data=[], InnerExcep
tion=null, HelpLink=null, Source="System.Console", HResult=-2147024890, StackTrace="   at System.ConsolePal.GetBufferInfo(Boolean throwOnNoConsole, Boolean& succeeded)\r\
n   at System.ConsolePal.get_WindowWidth()\r\n   at PKISharp.WACS.Services.InputService.WriteLine(String text, Nullable`1 color)\r\n   at PKISharp.WACS.Services.InputServ
ice.CreateSpace()\r\n   at PKISharp.WACS.Services.InputService.WritePagedList(IEnumerable`1 listItems)\r\n   at PKISharp.WACS.Services.InputService.ChooseFromMenu[T](Stri
ng what, List`1 choices, Func`2 unexpected)\r\n   at PKISharp.WACS.Host.MainMenu.MainMenuEntry(RunLevel runLevel)\r\n   at PKISharp.WACS.Host.Wacs.Start()"}

Full verbose output:

PS C:\Users\timd> C:\tools\win-acme\wacs.exe --verbose
 [DBUG] Logging at level Verbose
 [VERB] W3SVC detected and running
 [VERB] No FTPSVC detected
 [VERB] Looking for settings.json in C:\tools\win-acme\
 [DBUG] Use existing configuration folder C:\ProgramData\win-acme
 [DBUG] Use existing configuration folder C:\ProgramData\win-acme\acme-v02.api.letsencrypt.org
 [DBUG] Use existing log folder C:\ProgramData\win-acme\acme-v02.api.letsencrypt.org\Log
 [DBUG] Use existing cache folder C:\ProgramData\win-acme\acme-v02.api.letsencrypt.org\Certificates
 [DBUG] secrets.json not found
 [DBUG] Renewal period: 55 days
 [VERB] Sending e-mails False
 [VERB] Arguments: --verbose
 [VERB] ExePath: C:\tools\win-acme\wacs.exe
 [VERB] ResourcePath: C:\tools\win-acme\
 [VERB] PluginPath: C:\tools\win-acme\

 [INFO] A simple Windows ACMEv2 client (WACS)
 [INFO] Software version 2.2.7.1612 (release, pluggable, standalone, 64-bit)
 [INFO] Connecting to https://acme-v02.api.letsencrypt.org/...
 [DBUG] [HTTP] Send GET to https://acme-v02.api.letsencrypt.org/directory
 [VERB] [HTTP] Request completed with status OK
 [VERB] [HTTP] Response content: {
  "keyChange": "https://acme-v02.api.letsencrypt.org/acme/key-change",
  "meta": {
    "caaIdentities": [
      "letsencrypt.org"
    ],
    "termsOfService": "https://letsencrypt.org/documents/LE-SA-v1.3-September-21-2022.pdf",
    "website": "https://letsencrypt.org"
  },
  "mysnCVMBRJ4": "https://community.letsencrypt.org/t/adding-random-entries-to-the-directory/33417",
  "newAccount": "https://acme-v02.api.letsencrypt.org/acme/new-acct",
  "newNonce": "https://acme-v02.api.letsencrypt.org/acme/new-nonce",
  "newOrder": "https://acme-v02.api.letsencrypt.org/acme/new-order",
  "renewalInfo": "https://acme-v02.api.letsencrypt.org/draft-ietf-acme-ari-02/renewalInfo/",
  "revokeCert": "https://acme-v02.api.letsencrypt.org/acme/revoke-cert"
}
 [INFO] Connection OK!
 [DBUG] Running with administrator credentials
 [DBUG] IIS version 10.0
 [WARN] Scheduled task not configured yet
 [INFO] Please report issues at https://github.com/win-acme/win-acme
 [VERB] Unicode display test: Chinese/語言 Russian/�зык Arab/لغة
 [EROR] (IOException): The handle is invalid.
 [DBUG] Exception details: IOException {TargetSite=CONSOLE_SCREEN_BUFFER_INFO GetBufferInfo(Boolean, Boolean ByRef), Message="The handle is invalid.", Data=[], InnerExcep
tion=null, HelpLink=null, Source="System.Console", HResult=-2147024890, StackTrace="   at System.ConsolePal.GetBufferInfo(Boolean throwOnNoConsole, Boolean& succeeded)\r\
n   at System.ConsolePal.get_WindowWidth()\r\n   at PKISharp.WACS.Services.InputService.WriteLine(String text, Nullable`1 color)\r\n   at PKISharp.WACS.Services.InputServ
ice.CreateSpace()\r\n   at PKISharp.WACS.Services.InputService.WritePagedList(IEnumerable`1 listItems)\r\n   at PKISharp.WACS.Services.InputService.ChooseFromMenu[T](Stri
ng what, List`1 choices, Func`2 unexpected)\r\n   at PKISharp.WACS.Host.MainMenu.MainMenuEntry(RunLevel runLevel)\r\n   at PKISharp.WACS.Host.Wacs.Start()"}
 [VERB] Exiting with status code -1

Platform:

  • OS: Windows Server 2019 Datacenter, English
  • Version: 2.2.7.1612, 64-bit, pluggable

Additional context
win-acme was installed using Chocolatey on an Azure VM.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions