Xamarin/Mono TLS Exception - c#

I am putting together a Xamarin Android project and am trying to build a small app that makes calls to an API. The Xamarin project creates an instance of an ApiWrapper class that I have in another solution and that class is what makes the Http calls (not sure if that's important or not).
The stack trace that I keep getting at runtime is pasted below:
06-25 12:36:13.696 E/mono-rt ( 3365): [ERROR] FATAL UNHANDLED EXCEPTION:
System.Net.Http.HttpRequestException: An error occurred while sending the
request
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.
Here's what I've tried so far:
I have tried installing the ModernHttpClient and passing in the NativeMessageHandler into the constructor of HttpClient() with no success.
Made sure my app has INTERNET permissions
Added a custom validator class that returns true and gets passed into ServicePointManager.ServerCertificateValidationCallback
Run both mozroots and cert-sync to try and pull in the proper certificates for the site.
Also, just to be clear, I have a test project that is calling that same ApiWrapper class only through .NET's network stack and it's having no trouble with the encryption and is working properly.
I'm out of ideas and am struggling here. Any suggestions are very helpful! Thanks.

I had the same issue. Integration test was able to call the service and passed but running the code from the Android emulator threw that error. Also tried all the steps you outlined above.
What finally worked for me was changing the settings of the Android project. Right click on the project and click Properties. Go to Android Options and click the Advanced button.
Set..
HttpClient implementation -> Android
SSL/TLS implementation -> Native TLS 1.2+

Related

An error has occurred during web site deployment in App Service Editor

I made some changes in the QnAMakerBasDialog.cs file, in trying to edit the default threshold. I did not change any other thing. When I tried deploying my changes at first, I was not getting the expected response and so I went back the editor to reverse my changes. It was at this point I started getting this error message.
I need help in reversing all changes if possible but most expecially in getting "test web chart" and all my channels working again.
Please see error message error:
kindly note that I tried this in the kudu console but still got the same error message
\> build.cmd
1 file(s) copied.
Installing Kudu Sync
D:\local\AppData\npm\kudusync -> D:\local\AppData\npm\node_modules\kudusync\bin\kudusync
+ kudusync#0.3.0
added 7 packages from 8 contributors in 3.22s
Handling ASP.NET Core Web Application deployment.
Failed to add 'D:\local\UserProfile\.dotnet\tools' to the PATH environment variable. Add this directory to your PATH to use tools installed with 'dotnet tool install'.
Welcome to .NET Core 3.1!
---------------------
SDK Version: 3.1.301
Telemetry
---------
The .NET Core tools collect usage data in order to help us improve your experience. The data is anonymous. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
Read more about .NET Core CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry
----------------
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Find out what's new: https://aka.ms/dotnet-whats-new
Learn about the installed HTTPS developer cert: https://aka.ms/aspnet-core-https
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs
Write your first app: https://aka.ms/first-net-core-app
--------------------------------------------------------------------------------------
Unhandled exception. System.ComponentModel.Win32Exception (5): Access is denied.
at System.Diagnostics.Process.set_PriorityClassCore(ProcessPriorityClass value)
at System.Diagnostics.Process.set_PriorityClass(ProcessPriorityClass value)
at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine)
at Microsoft.Build.CommandLine.MSBuildApp.Main(String[] args)
MSBUILD : error MSB1025: An internal failure occurred while running MSBuild.
System.ComponentModel.Win32Exception (5): Access is denied.
at System.Diagnostics.Process.set_PriorityClassCore(ProcessPriorityClass value)
at System.Diagnostics.Process.set_PriorityClass(ProcessPriorityClass value)
at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine)
Failed exitCode=-532462766, command=dotnet restore "QnABot.sln"
An error has occurred during web site deployment.
Surprisingly, I also encountered this problem. I also encountered this problem in Buid after modifying the Azure Bot code!
Even with this error, my build is successful

VR application (Unity with TrinusVR lib) Windows build: Connection reset

I am developing a VR application using Unity 2018.2.8f1 and the TrinusVR lib (a framework that does serverside rendering). When I press play in the editor or build for Linux it works as expected. However, when using the Windows build, only about one frame gets transmitted to the client, then the connection is reset. On the client it shows the errors:
Error streaming video error: java.net.SocketException: Connection reset
Error Error delivering sensor data: java.net.SocketException: Connection reset
Digging into into the logs of the server it seems that this reset is caused by a null reference exception:
Disconnected (Reason: ERROR:ERR_IMG_PROC:Could not deliver frame to client.
System.TypeInitializationException: The type initializer for 'ManagedToNativeWrapper' threw an exception. --->
System.NullReferenceException: Object reference not set to an instance of an object
at System.Drawing.ComIStreamMarshaler+ManagedToNativeWrapper..cctor () [0x00049] in :0`
Does somebody know, what is wrong here? Has anybody seen this problem before?
You can find the complete log files (Windows 10 server and android 7 client) here:
https://transfernow.net/419cp2m92898
Thank you
Turns out that it actually is a problem of the .NET version on Windows as the trinus lib is made for an older version. Setting the right parameters in Edit > Project Settings > Player, section Other Settings, resolves:
Scripting Runtime Version: .NET 3.5 Equivalent
Api Compatibility Level: .NET 2.0

SSL/TLS Error during connecting vCenter via VMware Web Services SDK

I'd like to write some application to manage vSphere environment but first I want to try SDK_5.5 Samples. After building solution I tried to run simpleclient.exe and I've received following message: "Could not establish a trust relationship for the SSL/TLS secure channel".
Here is the command I'm typing to run the program:
SimpleClient.exe --url https://192.168.xxx.xxx/sdk --username administrator#vsphere.local --disablesso
I've installed esxi 5.5 and vCenter with default settings. Is there something i'm missing with certs?
Wired thing... The problem was I didn't place username in " "... after that everything works fine.

Error: Unable to generate a temporary class (result=1) ... When Invoking Methods on a Web Service

Error: Unable to generate a temporary class (result=1) ... When Invoking Methods on a Web Service. I am using VS 2008 C# ASP.NET 3.5. I am invoking a remote webservice to my application.
Server Error in '/' Application.
Server was unable to process request. ---> Unable to generate a temporary class (result=1).
error CS2001: Source file 'C:\WINDOWS\TEMP\6sbkwt2d.0.cs' could not be found
error CS2008: No inputs specified
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> Unable to generate a temporary class (result=1).
error CS2001: Source file 'C:\WINDOWS\TEMP\6sbkwt2d.0.cs' could not be found
error CS2008: No inputs specified
Source Error:
Line 775: [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/CheckLogin", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
Line 776: public System.Data.DataSet CheckLogin(string uname, string pswd) {
Line 777: object[] results = this.Invoke("CheckLogin", new object[] {
Line 778: uname,
Line 779: pswd});
Source File: c:\windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\14127ae4\96323535\App_WebReferences.u9ldrmk1.0.cs Line: 777
First, credit where credit is due. The OP solved this problem and answers it in the comments section of the question. However, I understand that many people come to StackOverflow and will read through the question, and not look at the comments. Therefore, I'm relaying the above answer here. Be sure to up-vote the question if this is useful.
This problem occurs because the account that is associated with your web service's application pool in IIS does not have read/write permission to the C:\Windows\Temp folder. I have no clue why the account needs access to this folder, but it does. From my casual observation it looks like it just writes an empty file with a random name to the Temp folder.
To solve this problem browse to the C:\Windows folder, and right-click on the Temp folder. Select Properties, and on the Security tab add the account associated with your web services application pool. Hit the OK button, go to IIS and recycle your application pool. This should fix your web service request.
It is worth noting that the circumstances around this error can be a bit deceptive. I've ran into this problem a couple times over 5 years. (I've forgotten about it each time.) The reason why it's not so noticeable is because you can publish a web service, successfully browse to the associated asmx page and see the outline of your web service methods. Furthermore, your Visual Studio project can add a reference to the Web Service and Visual Studio will auto-generate all associated classes for the web service in your VS project.
This gives the impression that everything is working properly until you make your first request to execute a method on the web service. The web service will fail when it begins executing code because it wants access to the temp directory.
Further information regarding this bug can be found at the acknowledged bug report at Microsoft.com.
That happens when your web site doesn't work with Application Pool "DefaultAppPool" and you chose its own pool.
In that case you need to add an user with the name of your pool.

Allowing partially trusted callers security exception is been thrown althought running on Full trust mode

While developing using ASP.net 2.0 (C#) and NHibernate 2.1.0
I am getting the error:
System.TypeInitializationException: The type initializer for 'NHibernate.ByteCode.LinFu.ProxyFactory' threw an exception. ---> System.Security.SecurityException: That assembly does not allow partially trusted callers.
This error is been thrown only in the production server (a web hosting company) and in my development environment everything is fine.
I also ran this code below on the production server to see the Code Access Security (CAS) level and got True from:
System.Security.SecurityManager.IsGranted(new AspNetHostingPermission(AspNetHostingPermissionLevel.Unrestricted))
so I can assume I am currently running in a full trusted mode..
After reading some articles about this kind of problem (not specifically for NHibernate)
I understood that I need to add
[assembly: AllowPartiallyTrustedCallers()]
to my AssebmlyInfo.cs file.
My question is:
Is there a way to solve this exception without having to edit the NHibernate.ByteCode.LinFu.dll's AssmeblyInfo.cs ? Is there something that can be configured in the web.config to allow this kind of action?
Thanks,
Tal.
Have you tried the steps called out here?
Using NHibernate in a Medium Trust web environment

Categories

Resources