.NET 4.8控制台程序手动正常,自动化启动TLS握手失败求助
TLS握手错误10013:手动启动.NET程序正常,自动化启动失败
我遇到一个棘手问题,已经困扰一两天了:
我有一个升级到.NET 4.8的老旧控制台程序,通过HTTP请求连接Broadsoft服务器。手动双击启动时,程序能正常和服务器完成TLS 1.2握手;但通过PowerShell、Python脚本或Batch脚本启动时,会抛出错误:
A fatal error occurred while creating a TLS client credential. The internal error state is 10013
环境配置
- 操作系统:Windows Server 2022 标准版
- 组策略已禁用TLS 1.0和TLS 1.1
- .NET程序已完整升级至4.8(包含所有依赖项)
已尝试的解决方法(均无效)
- 设置PowerShell会话的TLS 1.2标记(仅对PS自身请求生效,不影响启动的.exe程序)
- 以管理员权限运行自动化脚本
- 使用拥有桌面交互权限的特定用户身份启动程序
已尝试的Python脚本
import subprocess import time # Path to the console program executable console_program_path = "S:\Broadsoft\Broadsoft_CC\Broadsoft_CC.exe" # Open the prompts text file with open("S:\Broadsoft\Parameters\Parameters_CC.txt", "r", encoding="utf-16") as prompts_file: prompts = prompts_file.readlines() # Run the console program using subprocess with subprocess.Popen(console_program_path, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) as process: for index, prompt in enumerate(prompts): process.stdin.write(prompt) process.stdin.flush() # Wait for a limited time to read output from the subprocess timeout_seconds = 2 # Adjust this timeout as needed start_time = time.time() while time.time() - start_time < timeout_seconds: # Non-blocking read from stdout output = process.stdout.readline().strip() if output: print(output) break # Exit loop if output is read time.sleep(0.1) # Wait a short interval before trying again # Add an "Enter" keypress after the last line if index == len(prompts) - 1: process.stdin.write("Start()\n") process.stdin.flush() # Close the process and streams process.stdin.close() process.wait()
恳请各位提供排查方向或解决建议,感谢!
内容的提问来源于stack exchange,提问作者Mario
相关产品推荐
相关产品推荐

