c# - AgileDotNet 混淆器弄乱了 httpClient.PostAsync
问题描述
我注意到使用 AgileDotNet 混淆的应用程序无法发送请求httpClient.PostAsync
。我将问题缩减为 20 行代码,以便每个人都可以尝试。
internal class Program
{
public static void Main(string[] args){
Send("lala", "https://url");
Console.ReadLine();
}
public static async Task<string> Send(string jsonString, string url){
using (var client = new HttpClient()){
StringContent stringContent = new StringContent(jsonString, Encoding.UTF8, "application/json");
var result = await client.PostAsync(url, stringContent);
Console.WriteLine(result.StatusCode);
if (result.StatusCode == HttpStatusCode.OK){
string response = await result.Content.ReadAsStringAsync();
Console.WriteLine(response);
return response;
}else{
string response = await result.Content.ReadAsStringAsync();
Console.WriteLine(response);
return response;
}
}
}
}
如果没有被混淆,下面的代码将发送一个 Post 请求。如果使用 AgileDotNet,它永远不会发送请求。此外,错误是完全无声的,因为 Event Viever 和控制台中都没有显示。
有没有人经历过这个?任何已知的解决方法?我正在使用 AgileDotNet 6.6.0.11
更新:将 Main 的返回类型更改为async Task
并调用时,await Send
我收到一个错误:
Unhandled Exception: System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.
at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar)
--- End of inner exception stack trace ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at ohM=.oRM=.<Send>d__1.MoveNext() in C:\Users\User\source\repos\PostAsyncTests\PostAsyncTests\Program.cs:line 24
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at ohM=.oRM=.<Main>d__0.MoveNext() in C:\Users\User\source\repos\PostAsyncTests\PostAsyncTests\Program.cs:line 14
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at ohM=.oRM=.pRM=(String[] args)
显然,建立 SSL 连接会导致问题。
有问题的敏捷项目 .cls 文件:
<?xml version="1.0" encoding="utf-16"?>
<AgileDotNet Version="6.6.0.11">
<AssemblyList>
<Assembly Path="PostAsyncTests.exe" Secure="true" Obfuscation="true" FlowObfuscation="true" MethodCallObfuscation="true" ILMerge="none" />
</AssemblyList>
<Settings>
<General OutputDirectory="Secured" SignatureFile="" PfxPassword="" FilePathMode="relativepath" GenerateDebugInfo="True" SdkPath="" />
<Obfuscation ObfuscationMapFile="ObfuscationMap" RenamingScheme="printablechars" CrossAssemblyObfuscation="true" ExcludeXamlTypes="false" ControlFlowObfuscation="basic" PredefindSymbolNamesFilePath="" RenameMethodParameters="False">
<RenamingExclusions />
<AssemblyLoadPaths />
</Obfuscation>
<Secure SecureUserStrings="true" EncryptManagedResources="true" RedistName="AgileDotNetRT" RedistName64="AgileDotNetRT64" DisableRuntimeEmbedding="False" AntiDebuggerDetection="False" SkipSmallMethods="False" />
<Tracking ConfigureErrorReporting="false" ProductName="PostAsyncTests" ProductVersion="1.0.0.0" CompanyName="SecureTeam Software Ltd." />
<CodeVirtualization PerformCodeVirtualization="false" RedistName="AgileDotNet.VMRuntime" />
<LicenseFeatures />
</Settings>
<Licensing>
<Licenses />
</Licensing>
</AgileDotNet>
解决方案
推荐阅读
- javascript - Express.js 无法使用异步等待从查询 mysql 中获取结果
- tcp - 如何获取通过 TCP 传输的 RTP 有效负载(关于删除标头)
- npm - 如何修复“npm ERR!code ELIFECYCLE npm ERR!errno 1”
- automated-tests - 使用 testCafe 执行数据驱动测试的文档?
- php - ec2实例上的PHP exec bash脚本
- c# - 在本机 iOS 应用程序中构建 Unity 时出错
- javascript - 开玩笑的模拟导航服务
- javascript - 如何访问 componentWillMount 中的历史道具?
- python - matplotlib如何用定义的颜色绘制多条线?
- c# - 如何根据用户输入从列表中提取