Mono TLS1.2 issues - btls-cert-sync "command not found" - c#

Summary:
My company uses TargetProcess (TP) to track progress on open projects and we've created a relatively small bit of code that imports updates to TargetProcess.
Currently upon build submission, we spin up a debian docker image, with Mono pre-installed, and it runs our small .NET(C#) program to connect our updates to TP.
Repro:
It appears TP recently updated their API to only accept TLS1.2 connections, so we had to create a new docker image with Mono 4.8, the Alpha channel, on it (per this article).
The program still doesn't work out of the box with this new Mono installation on a docker image so we took a few steps: (following the prompting from Mono's Security FAQ)
// Made sure that the most current version ca-certificates-mono is installed
// and it seems to have been installed upon installation of mono 4.8
apt-get install ca-certificates-mono
// This should be an unnecessary step from what I read, but ran anyway
cert-sync /etc/ssl/certs/ca-certificates.crt
// lastly btls-cert-sync command, but can't seem to get it to not return
// "command not found" no matter wher I try running it
btls-cert-sync
Testing:
There seems to be a really helpful thread on how to test if your certs are formatted correctly. After running this test command in my docker image, I'm still seeing the failure message below.
MONO_TLS_PROVIDER=btls csharp -e 'Console.WriteLine (new System.Net.WebClient ().DownloadString ("https://www.howsmyssl.com/").IndexOf ("1.2"))'
// error message
System.Net.WebException: Error: TrustFailure (Ssl error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED) ---> Mono.Btls.MonoBtlsException: Ssl error:1000007d:SSLroutines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED
Any help or advice to get our instance of mono to accept TLS1.2 connections would be awesome.

btls-cert-sync is a shell script for btls-cert-sync.exe
Find btls-cert-sync.exe, normally installed in 4.8.0/lib/mono/4.8 and run it with mono:
mono btls-cert-sync.exe

As of mono 4.8 beta 3, btls-cert-sync seems to have been merged into cert-sync.
Do make sure that you have an up-to-date version of cert-sync as it is possible to get old versions of cert-sync still installed even if you have updated mono because the ca-certificates-mono package has not been updated (Linux).
If you look at the cert-sync output you will see
Mono Certificate Store Sync - version 4.8.0.0
...
Importing into legacy system store:
...
Importing into BTLS system store:
...

Related

Dotnet: Works in VSCode's OWN TERMINAL, but OMNISHARP: 'dotnet.exe' is not recognized

How is this possible?
I installed .net sdk 6.0.405: dotnet-sdk-6.0.405-win-x64.exe
I can in windows terminal and power shell run: dotnet --version: 6.0.405 ✅
I CAN ALSO IN VSCODE IN ITS BUILTIN TERMINAL, run: dotnet --version: 6.0.405 ✅✅
But in the OUTPUT tab, choosing OmniSharp Log from the dropdown, it says:
[ERROR] A .NET 6 SDK for x86_64 was not found. Please install the latest x86_64 SDK from ...
I switched vscode explorer settings to use external terminal.
And this terminal setting to command prompt:
Terminal › Integrated › Default Profile: Windows
The default profile used on Windows. This setting will currently be ignored if either terminal.integrated.shell.windows or terminal.integrated.shellArgs.windows are set.
I have dotnet in the PATH (and it works in terminals and in vscode's terminal)
I restarted vscode, AND REINSTALLED the dotnettools "C# for Visual Studio Code (powered by OmniSharp)" extension. I went to the online store and from the right column under Resources I downloaded the ms-dotnettools.csharp-1.25.2#win32-x64.vsix to make sure I get the right one. And restarted vscode.
I tried this setting:
Omnisharp: Dotnet Path
Specified the path to a dotnet installation to use when "useModernNet" is set to true, instead of the default system one. This only influences the dotnet installation to use for hosting Omnisharp itself. Example: "/home/username/mycustomdotnetdirectory".
C:/Program Files/dotnet/sdk/6.0.405
And this setting:
Omnisharp: Sdk Path
Specifies the path to a .NET SDK installation to use for project loading instead of the highest version installed. Applies when "useModernNet" is set to true. Example: /home/username/dotnet/sdks/6.0.300.
C:/Program Files/dotnet/sdk/6.0.405
And restarted vscode. And now it says:
[ERROR] Error: Command failed: dotnet.exe --version
'dotnet.exe' is not recognized as an internal or external command,
operable program or batch file.
What? W H A T? lol
What could be wrong? Why isn't it saying where it expected to find it and what to do to locate it? Is there a setting to specify the dotnet.exe path to this C# extension? Does it need always-on internet or something? Does it have DRM? Does it need Edge installed? Wtf?🙂
🙃😭 I just need intellisense; and I've wasted 2h, on only microsoft-owned products.
#Microsoft 0/5 stars
Still don't know why it happens, but here's how to solve it:
The problem was from this: I like to keep all my visual studio code extensions as .vsix files locally in folders so I can remember and get them easily & offline. Sensible enough choice, and I had the correct ms-dotnettools.csharp-1.25.2#win32-x64.vsix for my platform.
But in VSCode, when I install this particular extension via VSIX, even though it succeeds, it can't find .net. If you instead install the extension "normally", ie via vscode's own download, it seems vscode does some extra configuration steps while installing, and probably sets the .net paths correctly or something. Because now it works.
So TL;DR: don't install ms-dotnettools.csharp via vsix, it seems bugged. 😶
Would love to see an answer explaining what's wrong / how to actually do via vsix; but I don't have any more time to debug this rn.

DebugAdapter bin folder not found on path "....vscode/extensions/ms-vscode.csharp-0.3.7/coreclr-debug/debugAdapters/OpenDebugAD7.exe."

OS: Windows 10
dotnet-cli:
Version: 1.0.0-beta-001598
Commit Sha: 7582649f88
This is after following the instructions here for C# debugging. Does it work yet for windows?
According to the error message, it looks like you did not install the C# extension as per the instructions https://microsoft.gallery.vsassets.io/items?itemName=ms-vscode.csharp
Open your command pallet and verify that the correct version is installed. Or, if it is, remove it and try installing again

.NET, Topshelf service, Mono and different build machines

I experience a problem with running my .NET application service built with TopShelf on Mono.
The development setup is: Win 8.1, VS 2015, .NET 4.5.2 as a target framework
The CI setup: Win Server 2012, TeamCity 9.1.6, both server and build agent are running at the same machine
The execution (test server) setup: CentOS 6 x86_64, Mono 4.2.2
So I've implemented an application running as both a console application and background service (with the TopShelf) and successfully debugged and tested it locally.
I've set up the CI server in the way it builds an application on a build agent and produces as a folder with multiple dlls and .exe runner file inside (Release configuration) as a output. Finally CI publishes this folder to the remote CentOS server.
When I connect to the CentOS server via ssh and try to run it with the mono myapp.exe command, I get an error:
# mono myapp.exe
Configuration Result:
[Success] Name myapp
[Success] DisplayName myapp
[Success] Description myapp
[Success] ServiceName myapp
Topshelf v3.3.154.0, .NET Framework v4.0.30319.17020
[DEBUG][2/4/2016 7:42:57 PM][Thread 0001][EventStream] StandardOutLogger started
[INFO][2/4/2016 7:42:57 PM][Thread 0006][[akka://AkkaGrid/system/log1-NLogLogger]] NLogLogger started
[DEBUG][2/4/2016 7:42:57 PM][Thread 0001][EventStream(AkkaGrid)] Logger log1-NLogLogger [NLogLogger] started
[DEBUG][2/4/2016 7:42:57 PM][Thread 0001][EventStream(AkkaGrid)] StandardOutLogger being removed
2016-02-04 22:42:57.4509 DEBUG Start
2016-02-04 22:42:57.4538 DEBUG Logger log1-NLogLogger [NLogLogger] started
2016-02-04 22:42:57.4714 DEBUG StandardOutLogger being removed
2016-02-04 22:42:57.4714 DEBUG Default Loggers started
The myapp service is now running, press Control+C to exit.
2016-02-04 22:42:57.5075 ERROR Error while creating actor instance of type MyApp.Actors.Supervisor with 0 args: ()EXCEPTION OCCURRED:Akka.Actor.ActorInitializationException Exception during creation Void Create(System.Exception)
TypeLoadException Error while creating actor instance of type MyApp.Actors.Supervisor with 0 args: () Akka.Actor.ActorBase NewActor()
TargetInvocationException Exception has been thrown by the target of an invocation. System.Object InternalInvoke(System.Object, System.Object[])
MissingMethodException Method 'Array.Empty' not found.
2016-02-04 22:42:57.5216 INFO Message FetchEntityMessage from NoSender to akka://AkkaGrid/user/$b was not delivered. 1 dead letters encountered.
Ignoring the fact that there are also Akka.net and NLogger inside, the core issue seems to be in this line:
MissingMethodException Method 'Array.Empty' not found.
So, in order to test the compatibility of my code with Mono itself I've manually copied the application folder (Release) from my local machine (right after VS2015/MsBuild) to CentOS server and ran mono myapp.exe command again.
This way the execution succeeded and produced no errors in the output.
To ensure that the issue is not connected to the copying process, I've connected to the Win2012 server (with CI running on it), went to the build agent's working directory and executed myapp.exe as a simple windows console application. It ran successfully. Then I copied the application folder manually to the CentOS server via scp command from git bash and... got the same issue as above.
To provide some extra details, the build log is the following:
Step 2/7: Build .NET subsystem (MSBuild) (6s)
[22:36:32][Step 2/7] Starting: C:\TeamCity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.MsBuildBootstrap.exe /workdir:C:\TeamCity\buildAgent\work\17605015421235b0 "/msbuildPath:C:\Program Files (x86)\MSBuild\14.0\bin\amd64\MSBuild.exe"
[22:36:32][Step 2/7] in directory: C:\TeamCity\buildAgent\work\17605015421235b0
[22:36:33][Step 2/7] .net\MyApp.sln.teamcity: Build target: TeamCity_Generated_Build (4s)
[22:36:33][.net\MyApp.sln.teamcity] TeamCity_Generated_Build (4s)
[22:36:33][Step 2/7] MSBuild command line parameters contain "/property:" or "/p:". It is recommended to define System Property on Build Parameters instead.
[22:36:38][Step 2/7] Process exited with code 0
So I can see that TeamCity doesn't run the MSBuild directly, but some MsBuildBootstrap application. MSBuild Tools 2015 are set in the build step settings. So... that's all the details, any help appreciated :)
MissingMethodException Method 'Array.Empty' not found.
This method is new in .NET 4.6 as specified in the documentation.
The problem is that Mono 4.2.2 is not compatible with this version of .NET.
I've looked at the sources, and it looks that Mono from the master branch already includes this. However, the commit in which it was introduced is not yet marked as being present in any tag or branch. That means you will have to wait until Mono 4.3 or 4.4 is released, or compile Mono from sources yourself, or maybe try to look for a weekly/nightly build that you could use.
An easier fix may be trying to depend on binaries that are not so bleeding edge (i.e. that were compiled using the framework version 3.5 or 4.0).

Upgrading wp8 to wp8.1 silverlight, debugger cannot be launched

I have now had an error with VS2013 and WP8.1 silverlight for a couple of days.
I get a couple of different errors, ..Ensure unlocked screen.., AgHost.exe could not be launched, port is in use by another program and ensure the device is unlocked.
These errors came suddenly after I retarged the solution. I have no compiling errors.
Solution Attempts
Restart PC
Restart program
unregister and reregister the phone
reinstall Update 3
reinstall VS2013
Windows Phone 8 Application crash once its launched AgHost.exe' has exited with code -532265403
Install VS2015 with no luck.
reinstall VS2013 Update 4
Nothing worked. The error is also the same for emulator as well as different devices. I can however get the release mode installed. Break points can be used when using release mode, but I have to Clean, Rebuild and then deploy for every time I want to deploy the application. Further the deploy time has gone up exponentially. Before upgrading I used a maximum of 10 seconds. Now it is above a minute in wait time. :/
Anyone has a solution for this ?
Extra
If I run the solution before upgrade on device or Emulator It spins up with debugger. If then go to the updated WP81, I get a popup with info Something is taking longer then normal and then it crashes with ..Ensure unlocked screen.. :/
Could it be an issue with the differen SDKS?
During a repair of all the SDKs, I found an issue with the event log, which I cleared based on The Event Log File is full
Still no success.
Extra
I cannot spin up the emulator from VS2013, when using the WP8.1 solution, but the wp8.0 solution in the same VS works :S
I found an error in a log file, from:
The errors are:
[0F08:14A8][2015-07-23T09:11:44]: Applying execute package: silverlight5_DRT, action: Repair, path: C:\ProgramData\Package Cache\DEB5078B60B74431E2830831EB48DF129CB32932\packages\Silverlight\5.0_DRT\Silverlight_Developer.exe, arguments: '"C:\ProgramData\Package Cache\DEB5078B60B74431E2830831EB48DF129CB32932\packages\Silverlight\5.0_DRT\Silverlight_Developer.exe" /q /ignorewarnings'
[0F08:14A8][2015-07-23T09:11:45]: Error 0x800705de: Process returned error: 0x5de
[0F08:14A8][2015-07-23T09:11:45]: Error 0x800705de: Failed to execute EXE package.
[0550:0E74][2015-07-23T09:11:45]: Error 0x800705de: Failed to configure per-machine EXE package.
[0550:0E74][2015-07-23T09:11:45]: MUX: Installation size in bytes for package: silverlight5_DRT MaxAppDrive: 0 MaxSysDrive: 0 AppDrive: 0 SysDrive: 0
AND
[0F08:14A8][2015-07-23T09:16:16]: Applying execute package:
{312d9252-c71c-4c84-b171-f4ad46e22098}, action: Repair, path:
C:\ProgramData\Package
Cache{312d9252-c71c-4c84-b171-f4ad46e22098}\VS2012.4.exe, arguments:
'"C:\ProgramData\Package
Cache{312d9252-c71c-4c84-b171-f4ad46e22098}\VS2012.4.exe" -repair
-quiet -burn.related.patch' [0F08:14A8][2015-07-23T09:16:23]: Error 0x80048bc7: Process returned error: 0x80048bc7
[0F08:14A8][2015-07-23T09:16:23]: Error 0x80048bc7: Failed to execute
EXE package. [0550:0E74][2015-07-23T09:16:23]: Error 0x80048bc7:
Failed to configure per-machine EXE package.
Anybody knows what to do with this? The error is coming when I repair Windows Phone SDK 8.0
There was a post-VS2013 update for the Windows Phone 8.1 SDK, some odds that you don't have it installed since you did not need it before. The download location is here.
Getting error messages like "port is in use" when there's no obvious reason why it should be in use and seeing excessive download times is also a very strong selector for your installed anti-malware product getting in the way. No specific advice on how to configure it when we don't know what it might be. You definitely first want to try to temporarily disable it so you can identify it as the source of the problem.
I have no Idea of what is the issue, but creating a new solution and importing the existing projects into a new solution has solved all the issues regarding emulator and debugger an AgHost.
Seems like the upgrade function integrated in the solution did not work properly.

How do I deploy a Mono Winforms Application to Suse Linux 11.0 Server Enterprise?

Is there a way to make a simple installer that includes the necessary runtimes and dependency packages, and creates an icon in the OpenSuse menu, so the application will "just work?"
The actual application is just an executable (.EXE) and a handful of support files (mostly XML and CSV).
I already have the application successfully building and executing in MonoDevelop 2.0.
I originally tried to install the Mono Runtime via zypper from the following repository http://ftp.novell.com/pub/mono/download-stable/openSUSE_11.0, but quickly got bogged down in missing package dependencies.
This is what happens when I try to use zypper to install the Mono runtime:
linux-lkfu:~ # zypper addrepo http://ftp.novell.com/pub/mono/download-stable/SLE_11 mono-stable
Adding repository 'mono-stable' [done]
Repository 'mono-stable' successfully added
Enabled: Yes
Autorefresh: No
URI: http://ftp.novell.com/pub/mono/download-stable/SLE_11
linux-lkfu:~ # zypper refresh --repo mono-stable
Retrieving repository 'mono-stable' metadata [done]
Building repository 'mono-stable' cache [done]
Specified repositories have been refreshed.
linux-lkfu:~ # zypper dist-upgrade --repo mono-stable
Loading repository data...
Reading installed packages...
Computing distribution upgrade...
Nothing to do.
linux-lkfu:~ #
Notice the last line before the prompt that says "Nothing to do." I don't think it's doing anything.
One option is to buy mono support for SLES 11 from Novell. That will grant you a tested, supported and working mono repository.
If not you have to use the SLES repositories. For mono it's http://ftp.novell.com/pub/mono/download-stable/SLE_11
This should do it:
zypper addrepo http://ftp.novell.com/pub/mono/download-stable/SLE_11 mono-stable
zypper refresh --repo mono-stable
zypper dist-upgrade --repo mono-stable
If you have Visual Studio, you can try Mono Tools for Visual Studio, which provides tooling to make this easy. It is fully functional for 30 days.
http://go-mono.com/monotools/
that depends on how you plan to package them up. Either you manually create (deb for Debian and Ubuntu, rpm for Fedora and openSUSE, or anything else).
Personally, I think at first it is acceptable to simply add a .sh to your ZIP package and ask the end users to execute it for dependency checking, installing, and so on.
Then you can learn about the packaging methods.

Categories