Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Https erros after artifacts 7168 #2299

Closed
MarqSolucoes opened this issue Dec 7, 2023 · 3 comments
Closed

Https erros after artifacts 7168 #2299

MarqSolucoes opened this issue Dec 7, 2023 · 3 comments
Assignees
Labels
bug ScRT: C# Issues/PRs related to either C# scripting runtimes

Comments

@MarqSolucoes
Copy link

What happened?

After update artifacts 7168, http requests in C# throw error

in this example, the same script work on 7166 but on 7168 throw the follow error:

[ script:dll] Erro (https://restcountries.com/v3.1/name/portu): An error occurred while sending the request
[ script:dll]
[ script:dll] Erro (https://restcountries.com/v3.1/name/portu): at System.Net.Http.MonoWebRequestHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00476] in <0c97a591a0114a30937001a943b2c9ac>:0
[ script:dll] at System.Net.Http.HttpClient.SendAsyncWorker (System.Net.Http.HttpRequestMessage request, System.Net.Http.HttpCompletionOption completionOption, System.Threading.CancellationToken cancellationToken) [0x000ca] in <0c97a591a0114a30937001a943b2c9ac>:0
[ script:dll] at MyResource.Server.servermy.Get (System.String url) [0x00106] in <6c64857ecdba48eb8af110f65ef0fd4a>:0
[ script:dll]
[ script:dll] Erro (https://restcountries.com/v3.1/name/portu): System.Net.WebException: Error: SecureChannelFailure (The authentication or decryption has failed.) ---> System.IO.IOException: The authentication or decryption has failed. ---> System.IO.IOException: The authentication or decryption has failed. ---> Mono.Security.Protocol.Tls.TlsException: The authentication or decryption has failed.
[ script:dll] at Mono.Security.Protocol.Tls.RecordProtocol.EndReceiveRecord (System.IAsyncResult asyncResult) [0x00037] in :0
[ script:dll] at Mono.Security.Protocol.Tls.SslClientStream.SafeEndReceiveRecord (System.IAsyncResult ar, System.Boolean ignoreEmpty) [0x00000] in :0
[ script:dll] at Mono.Security.Protocol.Tls.SslClientStream.NegotiateAsyncWorker (System.IAsyncResult result) [0x00071] in :0
[ script:dll] Exception_EndOfInnerExceptionStack
[ script:dll] at Mono.Security.Protocol.Tls.SslClientStream.EndNegotiateHandshake (System.IAsyncResult result) [0x00032] in :0
[ script:dll] at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (System.IAsyncResult asyncResult) [0x0000c] in :0
[ script:dll] Exception_EndOfInnerExceptionStack
[ script:dll] at Mono.Security.Protocol.Tls.SslStreamBase.EndRead (System.IAsyncResult asyncResult) [0x0004b] in :0
[ script:dll] at Mono.Net.Security.Private.LegacySslStream.EndAuthenticateAsClient (System.IAsyncResult asyncResult) [0x0000e] in <42f584362443417994ec5d5c4e2c6478>:0
[ script:dll] at System.Threading.Tasks.TaskFactory1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func2[T,TResult] endFunction, System.Action1[T] endAction, System.Threading.Tasks.Task1[TResult] promise, System.Boolean requiresSynchronization) [0x00019] in :0
[ script:dll] --- End of stack trace from previous location where exception was thrown ---
[ script:dll]
[ script:dll] at Mono.Net.Security.MonoTlsStream.CreateStream (System.Net.WebConnectionTunnel tunnel, System.Threading.CancellationToken cancellationToken) [0x00126] in <42f584362443417994ec5d5c4e2c6478>:0
[ script:dll] at System.Net.WebConnection.CreateStream (System.Net.WebOperation operation, System.Boolean reused, System.Threading.CancellationToken cancellationToken) [0x001ba] in <42f584362443417994ec5d5c4e2c6478>:0
[ script:dll] Exception_EndOfInnerExceptionStack
[ script:dll] at System.Net.WebConnection.CreateStream (System.Net.WebOperation operation, System.Boolean reused, System.Threading.CancellationToken cancellationToken) [0x0021a] in <42f584362443417994ec5d5c4e2c6478>:0
[ script:dll] at System.Net.WebConnection.InitConnection (System.Net.WebOperation operation, System.Threading.CancellationToken cancellationToken) [0x00141] in <42f584362443417994ec5d5c4e2c6478>:0
[ script:dll] at System.Net.WebOperation.Run () [0x0009a] in <42f584362443417994ec5d5c4e2c6478>:0
[ script:dll] at System.Net.WebCompletionSource1[T].WaitForCompletion () [0x00094] in <42f584362443417994ec5d5c4e2c6478>:0 [ script:dll] at System.Net.HttpWebRequest.RunWithTimeoutWorker[T] (System.Threading.Tasks.Task1[TResult] workerTask, System.Int32 timeout, System.Action abort, System.Func1[TResult] aborted, System.Threading.CancellationTokenSource cts) [0x000f8] in <42f584362443417994ec5d5c4e2c6478>:0 [ script:dll] at System.Net.HttpWebRequest.EndGetResponse (System.IAsyncResult asyncResult) [0x00020] in <42f584362443417994ec5d5c4e2c6478>:0 [ script:dll] at System.Threading.Tasks.TaskFactory1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func2[T,TResult] endFunction, System.Action1[T] endAction, System.Threading.Tasks.Task`1[TResult] promise, System.Boolean requiresSynchronization) [0x0000f] in :0
[ script:dll] --- End of stack trace from previous location where exception was thrown ---
[ script:dll]
[ script:dll] at System.Net.Http.MonoWebRequestHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x0041b] in <0c97a591a0114a30937001a943b2c9ac>:0
[ script:dll]

Resource example:
image

Expected result

request must return data from the api

Reproduction steps

Create Server Resource with this script and run on artifacts 7168 to catch error or artifacts 7166 to sucess.

public class servermy : BaseScript
    {
        public servermy()
        {
            RegisterCommand("teste", new Action<int, List<object>, string>(async (source, args, raw) =>
            {
                await this.Get("https://restcountries.com/v3.1/name/portu");
            }), false);

        }
        public async Task Get(string url)
        {
            using (var client = new HttpClient())
            {
                client.Timeout = TimeSpan.FromSeconds(10);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Add("Accept", "*/*");
                var result = string.Empty;
                try
                {
                    ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
                    var req = await client.GetAsync(url);
                    result = await req.Content.ReadAsStringAsync();
                    Debug.WriteLine($"result ({url}): {result}");
                }
                catch (Exception ex)
                {
                    Debug.WriteLine($"\n\tErro ({url}): {ex.Message}");
                    Debug.WriteLine($"\n\tErro ({url}): {ex.StackTrace}");
                    Debug.WriteLine($"\n\tErro ({url}): {ex.InnerException}");
                }
            };
        }
    }

Importancy

Unknown

Area(s)

FiveM, FXServer, ScRT: C#

Specific version(s)

Server 7168 or greater

Additional information

No response

@MarqSolucoes MarqSolucoes added bug triage Needs a preliminary assessment to determine the urgency and required action labels Dec 7, 2023
@github-actions github-actions bot added the ScRT: C# Issues/PRs related to either C# scripting runtimes label Dec 7, 2023
@jakub-cfx
Copy link
Contributor

Hi! Thanks for bringing this to our attention. I was able to find the root cause of this issue and I have a fix ready locally. Will do my best to get it out soon :)

@jakub-cfx
Copy link
Contributor

The fix has been merged in (81f6957)
Please let us know if you experience any further issues

@github-actions github-actions bot removed the triage Needs a preliminary assessment to determine the urgency and required action label Dec 22, 2023
@MarqSolucoes
Copy link
Author

Thanks <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ScRT: C# Issues/PRs related to either C# scripting runtimes
Projects
None yet
Development

No branches or pull requests

2 participants