I have an ASP.NET Core Web API that was working perfectly on my Windows machine. I needed to deploy it on an Ubuntu Linux 22.04 LTS server. I followed this guide.
The application runs and can be accessed through the browser using localhost:5169. in Linux However, when a client tries to fetch data using the Linux server's IP address and port endpoint, it throws the following exception: I am using HTTP currently
Client Window app access then this exception shows in the terminal of Linux. If I use Client android app then it does not throw any exception it just says Time out.
> fail: Microsoft.EntityFrameworkCore.Database.Connection[20004]
> An error occurred using the connection to database '****' on server '******'.
> fail: Microsoft.EntityFrameworkCore.Query[10100]
> An exception occurred while iterating over the results of a query for context type '****.ApiContext.apiContext'.
> Microsoft.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 31 - Encryption(ssl/tls) handshake failed)
> System.IO.IOException: Received an unexpected EOF or 0 bytes from the transport stream........
Microsoft.EntityFrameworkCore.SqlServer 8.0.2 (Installed)
Added this is Program.cs
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; var app = builder.Build();
Connection String
"ApiString": "Data Source=DB***;Initial Catalog=;User Id=user;Password=*******;Connect Timeout=30;Encrypt=false;TrustServerCertificate=true;Persist Security Info=false;Application Intent=ReadWrite;MultiSubnetFailover=false"
LaunchSettings.Json
`"profiles": {
"Image_catalogue": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5169",
"nativeDebugging": false
},
`
Any assistance in resolving this issue would be greatly appreciated.
This solution worked for me:
https://askubuntu.com/questions/1233186/ubuntu-20-04-how-to-set-lower-ssl-security-level
CipherString = DEFAULT@SECLEVEL=0