I noticed that an app obfuscated with AgileDotNet is unable to send httpClient.PostAsync
requsts. I trimmed the problem down to 20 lines of code so everyone can try it.
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;
}
}
}
}
The code below will send a Post request if it is not obfucated. If AgileDotNet is used, it will never send a request. Moreover, error is completely silent as is is not shown in Event Viever nor in the console.
Has anyone experienced this? Any known workarounds? I am using AgileDotNet 6.6.0.11
Update: when changing Main's return type to async Task
and calling await Send
I recieved an error:
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)
Apparently, establishing SSL connection causes problems.
agile project .cls file in question:
<?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>