how to enable tls 1.3 on macos ventura - c#

This is weird thing, I'm not able to run tls 1.3 under .net 6 while running same configuration for windows 11 that's works, the configuration is pretty simple:
builder.WebHost.UseKestrel(k =>
{
k.ConfigureHttpsDefaults(options =>
{
options.SslProtocols = SslProtocols.Tls13;
});
});
On mac I'm receiving this issue from chrome: err_ssl_version_or_cipher_mismatch and from postman: Error: write EPROTO 140186045514584:error:1000042e:SSL routines:OPENSSL_internal:TLSV1_ALERT_PROTOCOL_VERSION:../../../../src/third_party/boringssl/src/ssl/tls_record.cc:594:SSL alert number 70
I've also have tried to modify mac configuration with:
sudo defaults write /Library/Preferences/com.apple.networkd tcp_connect_enable_tls13 1
But this didn't help me at all, does anyone faced with similar issue?

Related

dotnet core 3.1 IIS Error "An attempt was made to access a socket in a way forbidden by its access permissions (10013)"

I've dotnet core 3.1 project. I launched a few machines on iis. But today i can't launched the app on iis. I can launch with "dotnet <app.dll>" command and everything's good. But when i launch on IIS, it gives this error.
"crit: Microsoft.AspNetCore.Server.Kestrel[0]
Unable to start Kestrel.
System.Net.Sockets.SocketException (10013): An attempt was made to access a socket in a way forbidden by its access permissions.
at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)"
Any suggestion ?
PS: I checked my ports in use with command netstat -o. There is no using from any application
netsh interface ipv4 show excludedportrange protocol=tcp
Look at the ports listed and see if it overlaps with your port.
If so, rebooting your PC or changing the port has fixed this for me.
I'm using port 56240, Windows Update sometimes takes that range.
Finally I found my solution on my own. I removed UseKestrel() line from program.cs and everything's good.
var config = new ConfigurationBuilder().AddCommandLine(args).Build();
return Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
webBuilder.UseKestrel(); **//remove this line.**
webBuilder.UseUrls();
webBuilder.UseIISIntegration();
}).ConfigureServices((context, services) =>
{
services.AddHostedService<Worker>();
services.AddHostedService<MonitorWorker>();
services.AddHostedService<TransferWorker>();
});
}

IIS8.5 .NET Core 3.1 Web API POST - No response externally/on public domain

I have a fully working Web API, as long as I'm making calls from the host environment. If I make a Postman call remotely to my IIS 8.5 server using the public DNS hostname it "Could not get any response".
UPDATE 21/05/2020: I've narrowed the issue down to app.UseHttpsRedirection(), which leads me to believe that the CORS preflight (OPTIONS) request that's sent is being rejected somehow once it enters the server through the redirection middleware. Probably thinks its malicious and rejects but if anyone can provide insight as to why this is, it would be GREATLY appreciated.
Please note the following:
Its a .NET Core 3.1.4 Web API template with two controllers.
These controllers can only perform POST (JSON Data From Body) requests.
I'm using IIS 8.5 on Windows Server 2012 R2, it exists alongside other live .NET framework apps.
I've installed the .NET Core hosting 3.1.4 package on the IIS server.
To visit it an example would be https://localhost/[MyProjectsName]/api/Customers
I've given the app its own dedicated app pool and dedicated identity/user to run on.
I've set .NET CLR version to No Managed Code.
The app is published with dotnet.exe using a TFS2015 build agent with the following arguments
publish "[CSPROJ LOCATION]" -c "TEST" -o "$(build.artifactstagingdirectory)\published" -f "netcoreapp3.1" -r "win81-x64"
I'm using InProcess hosting and specified webBuilder.UseIIS().
I've tried UseUrls("http://*:80;https://*:443") although I fear that's only relevant to Kestrel users.
I've defined <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel> within my CSPROJ.
For the sake of troubleshooting I've opened up my CORS policy with the following...
services.AddCors(options =>
{
options.AddPolicy(name: specificOrigins,
builder =>
{
builder.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod()
.SetIsOriginAllowedToAllowWildcardSubdomains();
});
});
...And added app.UseCors(specificOrigins) to the Configure method within Startup.
I've also added [EnableCors("_AllowSpecificOrigins")] attribute to the controllers.
Any help would be greatly appreciated. If more code snippets or info is needed I'll try to update if possible. First time poster, long time lurker, so very unfamiliar with Stack Overflow posting.

Process terminated. Couldn't find a valid ICU package installed on the system in Asp.Net Core 3 - ubuntu

I am trying to run a Asp.Net Core 3 application in Ubuntu 19.10 thru terminal using dotnet run command but it does not seem to work. I get this error.
Process terminated. Couldn't find a valid ICU package installed on the system.
Set the configuration flag System.Globalization.Invariant to true if you want
to run with no globalization support.
at System.Environment.FailFast(System.String)
at System.Globalization.GlobalizationMode.GetGlobalizationInvariantMode()
at System.Globalization.GlobalizationMode..cctor()
at System.Globalization.CultureData.CreateCultureWithInvariantData()
at System.Globalization.CultureData.get_Invariant()
at System.Globalization.CultureInfo..cctor()
at System.StringComparer..cctor()
at System.StringComparer.get_OrdinalIgnoreCase()
at Microsoft.Extensions.Configuration.ConfigurationProvider..ctor()
at Microsoft.Extensions.Configuration.EnvironmentVariables.EnvironmentVariablesConfigurationSource.Build(Microsoft.Extensions.Configuration.IConfigurationBuilder)
at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder..ctor(Microsoft.Extensions.Hosting.IHostBuilder)
at Microsoft.Extensions.Hosting.GenericHostWebHostBuilderExtensions.ConfigureWebHost(Microsoft.Extensions.Hosting.IHostBuilder, System.Action'1<Microsoft.AspNetCore.Hosting.IWebHostBuilder>)
at Microsoft.Extensions.Hosting.GenericHostBuilderExtensions.ConfigureWebHostDefaults(Microsoft.Extensions.Hosting.IHostBuilder, System.Action'1<Microsoft.AspNetCore.Hosting.IWebHostBuilder>)
at WebApplication.Program.CreateHostBuilder(System.String[])
at WebApplication.Program.Main(System.String[])
I installed the dotnet core sdk using the ubuntu store and after that I also installed Rider IDE.
The weird thing here is that when I run the app using Rider it runs fine, the only issue is using terminal dotnet core commands.
Does anybody know what might be the issue ?
The application is created using Rider. I don't think that this plays a role but just as a side fact.
I know there are also other ways to install dotnet core in ubuntu but since the sdk is available in the ubuntu story I thought it should work out of the box and of course its an easier choice.
Also tried this one but does not seem to work for me. Still the same issue happens after running the commands.
The alternative solution as described in Microsoft documentation is to set environment variable before running your app
export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
If you want to run with no globalization support, you need to get "System.Globalization.Invariant": true into your published output AppName.runtimeconfig.json file as shown in the example below:
{
"runtimeOptions": {
"tfm": "netcoreapp3.0",
"configProperties": {
"System.GC.Server": true,
"System.Globalization.Invariant": true
}
}
}
You can add it manually every time you deploy by adding or updating the AppName.runtimeconfig.json file. Better yet, add it once to a runtimeconfig.template.json file like this:
{
"configProperties": {
"System.Globalization.Invariant": true
}
}
Make sure that runtimeconfig.template.json is included in build/publish.
It seem the package libicu63 will provide the ico support for dotnet on Linux, at least on Debian'ish distros.
Update:
And it seems it's "missing" when doing a small installing of Debian (i.e. deselect all applications/system-options in the installation program, except for SSH server)
The trick around it on Ubuntu 20.04 based on this thread https://github.com/dotnet/core/issues/2186#issuecomment-671105420
$export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
Yes. When installing Github action in Debian. It is also required.
As the response from MrCalvin,
sudo apt-get update && sudo apt-get install -qqq libicu63 resolve my issue.
edit your .bashrc file by adding the following line, e.g.:
nano ~/.bashrc
add
export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
Ctrl+o, Ctrl+x
restart terminal and run pwsh again
I had this issue while trying to run Umbraco version 9.2.0. Fiddling with System.Globalization.Invariant was not a good solution as it broke globalization in the backoffice. This issue has been solved in v9.4: https://github.com/umbraco/Umbraco-CMS/pull/11961
I didn't want to upgrade my Umbraco version to solve this, so I just copied the change in that commit to my project.
Simply go into the .csproj file of your web project and change the ICU package reference lines to:
<!-- Force windows to use ICU. Otherwise Windows 10 2019H1+ will do it, but older windows 10 and most if not all winodws servers will run NLS -->
<ItemGroup>
<PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="68.2.0.9" />
<RuntimeHostConfigurationOption
Condition="$(RuntimeIdentifier.StartsWith('linux')) Or $(RuntimeIdentifier.StartsWith('win')) Or ('$(RuntimeIdentifier)' == '' And !$([MSBuild]::IsOSPlatform('osx')))"
Include="System.Globalization.AppLocalIcu"
Value="68.2.0.9" />
</ItemGroup>
In my case, I followed the Windows documentation to install SDK dependencies and Runtime, watch out for the corresponding version to each Linux distribution to avoid compatibility issues.
This helped me override the default ICU version to the one that's installed on the machine running arch linux.
export CLR_ICU_VERSION_OVERRIDE=$(pacman -Q icu | awk '{split($0,a," ");print a[2]}' | awk '{split($0,a,"-");print a[1]}')

DotNet core 3.0 compilation issues in VSCode

I am new to DotnetCore and MS programming. With the new push from MS to be more platform neutral, I had an interest in me to try it out and see if it works the way it promises. That said, I have had problem even getting a helloworld program work on DotNetCore on windows from VSCode. Everything seems to work fine on my command prompt and VisualStudio 2019, my mac's VS Studio for mac. Real strain seems to be on VSCode in Windows 10. I'd appreciate all your help, if you can
The error I receive is "Cannot find debug adapter for type coreclr". No matter what I do, I end up with this error.
1. INstalled Dotnet core 3.0
2. Set up MSBuildSDKsPath env variable that points to C:\Program Files\dotnet\sdk\3.0.100\Sdks
3. Restarted machine as many times
Nothing works. Here's the sample code as well as my launch.json.
using System;
namespace OOPExample
{
public struct Dimensions {
public double Length { get; }
public double Width { get; }
public Dimensions(double length, double width) {
Length = length;
Width= width;
}
public double Diagonal => Math.Sqrt(Length * Length + Width * Width);
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine($"Hello World - {new Dimensions(10.0, 15.0).Diagonal}");
}
}
}
Here's my launch.json
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/netcoreapp3.0/OOPExample.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
When I execute dotnet build and dotnet run from command prompt, everything is fine
dotnet build:
C:\Users\Krishnan\Projects\DotNet\OOPExample> dotnet build
Microsoft (R) Build Engine version 16.3.0+0f4c62fea for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 12.86 ms for C:\Users\Krishnan\Projects\DotNet\OOPExample\OOPExample.csproj.
OOPExample -> C:\Users\Krishnan\Projects\DotNet\OOPExample\bin\Debug\netcoreapp3.0\OOPExample.dll
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.77
dotnet run:
PS C:\Users\Krishnan\Projects\DotNet\OOPExample> dotnet run
Hello World - 18.027756377319946
If you are wondering how I created this project, it was nothing more than a simple
dotnet new console command. So nothing fancy
Maybe this can help someone having this problem: Twice in the past week I have resolved this error.
First time by uninstalling/re-installing the OmniSharp C# extension.
Second time by updating VSCode to latest.
I haven't figured out if the two things are related, but I don't see anything in OmniSharp or VSC release notes about it specifically.
first of all, ensure that you had install official Microsoft C# extension for vs-code.
then, if still doesn't run it would be a problem with your launch.json file.
The following error message appeared when I tried to start debugging.
"Cannot find debug adapter for type 'coreclr'".
If the following error message was appearing too, like in my case, I'd recommend you to also consider to click on "Developer Tools" because I think there's a very good chance that you would be able to get a good hint there.
"Extension host terminated unexpectedly".
In the box of the above message, I clicked "Developer Tools" and then I could see some error messages containing a string "kite" that made me guess that, in my case, these error messages could've been coming from the extension "kite" that I had installed a long time ago. After disabling this extension and restarting VS Code, neither error message appeared again. (Now I'm not sure if restarting was essential.) I'm not saying that the extension kite is troublesome. In your case, the problem could've been coming from some other extensions or something other than an extension. I'm saying that the "Developer Tools" could be a goldmine of hints.
I've one more piece of happy news. Later on, these error messages didn't appear even after enabling this extension "kite". I could start debugging without giving up this extension.
I was getting OPs error message, but only when using Run & Debug with ".NET Core Launch (web)" configuration in a Dev Container:
Couldn't find a debug adapter descriptor for debug type 'coreclr' (extension might have failed to activate)
I noticed in VS Code's Output tab, on the C# console, the following additional output:
Installing C# dependencies...
Platform: linux, x86_64, name=ubuntu, version=20.04
Downloading package 'OmniSharp for Linux (x64)'
Retrying from 'https://roslynomnisharp.blob.core.windows.net/releases/1.37.8/omnisharp-linux-x64-1.37.8.zip'
Failed at stage: downloadPackage
Error: Failed to establish a socket connection to proxies: ["PROXY 127.0.0.1:8118"]
It seems that the Dev Container picks up the HTTP_PROXY and HTTPS_PROXY environment variables from the host but, being a guest container, its 127.0.0.1 address is different than the host computer's 127.0.0.1 address.
I fixed this by way of Windows-Pause > Advanced System Settings > Advanced > Environment Variables... > with the host computer's "public" IP address as returned from ipconfig /all, e.g.:
HTTP_PROXY = http://192.168.0.111:8118/
HTTPS_PROXY = http://192.168.0.111:8118/
Followed by closing and reopening VS Code, with Run & Debug now working as expected in the Dev Container.
I had the same problem, I just uninstalled the Omnisharp and all extensions from dotnet, closed the VSCode and after reopened it, and install everything again(package Omnisharp). Now is working as expected.
Just to let registered my SO is Linux Ubuntu 20.04.
I had my share of this debug error today. The following steps I took to resolve the issue might be helpful to someone.
Uninstalled "C# for Visual Studio Code (powered by OmniSharp)" and then installed it back.
Closed Visual Studio Code
Restarted VS Code
Launched the debug button
I hope this is helpful!
I was also getting same error after running dotnet clean
-i simply closed vscode
-then open vscode
-dotnet restore
-dotnet build
my error solved

Latency issues with self-hosting a simple NancyFX HelloWorld application running under Mono

Background
I'm testing the NancyFX framework by running a simple HelloWorld example under different conditions.
public class IndexModule : NancyModule
{
public IndexModule()
{
Get["/"] = _ => "Hello World!";
}
}
Example seems to run fine on both Windows and Linux, the problem is Mono's response time. Under Windows the HTTP response takes aprox. 3-4ms, whereas the same code under Linux (Mono) always takes 200ms+. After some additional testing (and switching to ServiceStack AppHost) the problem persists, so my guess would be this has something to do with Mono. Any ideas?
HTTP response (CentOS 6.5, Mono 3.10)
Test results
OS Runtime Response time Location
Windows 7 .NET 4.5.1 3ms Local
CentOS 6.5 Mono 3.10 200ms Local
Ubuntu 12.04 LTS Mono 2.10.8.1 295ms Remote
Other
Source code
Profile dump
Strangely enough, if you put a reverse proxy on top of the self-hosted app, the latency issues disappear.
Here's the nginx proxy_pass config used:
# /etc/nginx/virtual.d/nancydemo.conf
server {
listen 80;
server_name nancydemo.local;
root /media/sf_dev/nancydemo/bin/Debug;
location / {
proxy_pass http://127.0.0.1:1234;
}
}

Categories

Resources