if i type:
certbot renew
at the PS console prompt (in PS ISE), then the following is written to the console:
certbot : Saving debug log to C:\Certbot\log\letsencrypt.log
At line:1 char:1certbot : Saving debug log to C:\Certbot\log\letsencr
+ certbot renew
+ ~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Saving debug lo...letsencrypt.log:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Processing C:\Certbot\renewal\*****.conf
Certificate not yet due for renewal
The following certificates are not due for renewal yet:
C:\Certbot\live\*******\fullchain.pem expires on 2022-**-** (skipped)
No renewals were attempted.
(Note: I used * character to obfuscate my domain name info.)
It seems like certbot ran the subcommand ok, but there was some issue and a Powershell exception that seems related to the output of the first line output:
certbot : Saving debug log to C:\Certbot\log\letsencrypt.log
From the debug log:
2022-06-05 15:14:37,649:DEBUG:certbot._internal.main:certbot version: 1.24.0
2022-06-05 15:14:37,649:DEBUG:certbot._internal.main:Location of certbot entry point: C:\Program Files (x86)\Certbot\bin\certbot.exe
2022-06-05 15:14:37,649:DEBUG:certbot._internal.main:Arguments: ['--preconfigured-renewal']
2022-06-05 15:14:37,649:DEBUG:certbot._internal.main:Discovered plugins: PluginsRegistry(PluginEntryPoint#manual,PluginEntryPoint#null,PluginEntryPoint#standalone,PluginEntryPoint#webroot)
2022-06-05 15:14:37,649:DEBUG:certbot.compat.misc:Failed to set console mode
Traceback (most recent call last):
File "C:\Program Files (x86)\Certbot\pkgs\certbot\compat\misc.py", line 60, in prepare_virtual_console
h.SetConsoleMode(h.GetConsoleMode() | ENABLE_VIRTUAL_TERMINAL_PROCESSING)
pywintypes.error: (6, 'GetConsoleMode', 'The handle is invalid.')
2022-06-05 15:14:37,759:DEBUG:certbot._internal.log:Root logging level set at 30
And comparing this to debug log contents for the execution of the same command except from the Windows CMD console (wherein the output is exactly the same except that there is no PS remote exception):
2022-06-05 15:13:26,430:DEBUG:certbot._internal.main:certbot version: 1.24.0
2022-06-05 15:13:26,430:DEBUG:certbot._internal.main:Location of certbot entry point: C:\Program Files (x86)\Certbot\bin\certbot.exe
2022-06-05 15:13:26,430:DEBUG:certbot._internal.main:Arguments: ['--preconfigured-renewal']
2022-06-05 15:13:26,430:DEBUG:certbot._internal.main:Discovered plugins: PluginsRegistry(PluginEntryPoint#manual,PluginEntryPoint#null,PluginEntryPoint#standalone,PluginEntryPoint#webroot)
2022-06-05 15:13:26,524:DEBUG:certbot._internal.log:Root logging level set at 30
It seems the issue may be related to the virtual terminal processing in the misc.py code when certbot is invoked from powershell.
I get similar results when calling certbot from a PS script using the & (Powershell call operator).
When I look at a debug log from execution of the scheduled task add by the earlier "certbot run" with windows command:
Powershell.exe -NoProfile -WindowStyle Hidden -Command "certbot renew"
the first few lines of output are:
2022-06-04 12:00:06,572:DEBUG:certbot._internal.main:certbot version: 1.24.0
2022-06-04 12:00:06,572:DEBUG:certbot._internal.main:Location of certbot entry point: C:\Program Files (x86)\Certbot\bin\certbot.exe
2022-06-04 12:00:06,572:DEBUG:certbot._internal.main:Arguments: ['--preconfigured-renewal']
2022-06-04 12:00:06,572:DEBUG:certbot._internal.main:Discovered plugins: PluginsRegistry(PluginEntryPoint#manual,PluginEntryPoint#null,PluginEntryPoint#standalone,PluginEntryPoint#webroot)
2022-06-04 12:00:06,666:DEBUG:certbot._internal.log:Root logging level set at 30
So, past the point of issue when invoked from console or execution of script in ISE.
Any ideas, on why the exception is happening and how this could be avoided?