RSA Encryption Failed with Error Code = -2146893819 - c#

I'm working on some code that dropped on me when another developer (and the only person who knew anything about this system) left. I'm trying to figure out why my client and server are not connecting. I'm getting the following error:
"Genuine channels operation exception: The connection has been forcibly closed.
Specified reason: RSA encryption failed with error code = -2146893819"
Initial google research seems to indicate that Genuine Channels is a communications library that was being used (but I'm not sure if that's accurate). Also, there doesn't seem to be any information on what that particular error code means.
At this point, I'm fine with suggestions on where to give my research if you don't have any concrete ideas on what could be wrong.

Error code -2146893819 is hex 80090005 which, in the MS crypto libraries, is NTE_BAD_DATA.
That's about as far as I got before I lost interest (that tends to happen to me a lot with crypto stuff) and it's only slightly more helpful than what you've got, so I've made it community wiki.
You haven't actually stated what you were doing when you got the error but the top hit for "rsa" and "nte_bad_data" on Google was this.
Still, it expands you Google search terms at least :-)
Best of luck.

For reference to future people who visit this question, I eventually solved this issue. It turned out to be a a DLL mismatch between the versions of GenuineChannels & our cryptology implementation that were on our client machines and our server machines.

Related

Fortify fix for Often Misused: Authentication - C#

I got "Often Misused: Authentication" issue while fortify done my code scan. I am getting issue from below line of code
IPHostEntry serverHost = Dns.GetHostEntry(HttpContext.Current.Server.MachineName);
When I Googled I found some solutions but I am unable to get it. Do I need to create a False positive for this issue or Can I rewrite the code and give a fix. This is used only for logging purpose. I am not satisfied with creating FP ticket. How can i get serverhost without using Dns.GetHostEntry.Can anybody suggest any fix for this issue.

Azure logging API sample

I have tried the C# sample at https://learn.microsoft.com/en-us/azure/azure-monitor/platform/data-collector-api butI always get an error response back. Has anyone been able to get this sample to work? I have double and triply checked the workstation id and the secret key but still cannot call the API sucessfully.
Yes, as Doris Lv mentioned, displaying the error would certainly help to understand the issue better.
In additional to it what I could observe in general is, the C# example provided for the Azure Monitor Data Collector API uses ASCII encoding while other parts of the page reference UTF8 so try to tweak your code with UTF8 and see if it resolves your error.

Getting the Signal Strength of a cellular dongle (GSM) on a desktop application written in C#

I'm trying to retrieve the SignalStrength (i.e. like the info behind the bars cellular phones), but on a desktop application developed in C# .NET 4.0, that has a GSM adapter connected to it. I've managed to connect and disconnect to the service provider using RasDialer, but I can't find anyway to get the SignalStrength.
I've tried MbnApi, but it runs great until I receive the connected interfaces, and after I use one of them for ANYthing, it crashes with a COM exception saying "the data necessary to complete this operation is not yet available". Here's a piece of code that crashes with this exception on the last line:
MbnInterfaceManager mbnInfMgr = new MbnInterfaceManager();
IMbnInterfaceManager infMgr = (IMbnInterfaceManager)mbnInfMgr;
MbnConnectionManager mbnConnectionMgr = new MbnConnectionManager();
IMbnConnectionManager ImbnConnectionMgr = (IMbnConnectionManager)mbnConnectionMgr;
var mobileInterface = infMgr.GetInterfaces() as IMbnInterface[];
IMbnSignal sig = (IMbnSignal)mobileInterface[0];
uint signalStrength = sig.GetSignalStrength();
Can anyone assist, either by explaining what I'm doing wrong with MbnApi or directing me to another alternative?
Thank you so much in advance,
Yaron.
I couldn't see any obvious errors, so I pasted your exact code into a .NET 4.0 test project, referenced MbnApi built on a Windows 8 system and ran it, and it ran fine. I got the signal strength of my integrated modem out.
I assume that in your code, you would normally have try/catch blocks, tests for null etc.
Have you investigated how many interfaces are present, and whether you really want interface[0] or another one? Also obvious things like re-booting Windows etc.
You asked about other possibilities for getting this information.
When using MBN API for signal strength, you should be aware of this factor. The AT command AT+CESQ gives a more accurate value. Section 8.69 of this document describes it. There is plenty of information on SO and the internet on how to use AT commands with C# - try the at-command tag, or do a search for [c#][at-command] on SO.

Exception from HRESULT: 0x80040013: when Integrating R with C#:

I am trying to interface R with C# web application.I tried many solutions being provided but couldn't get it through. Error I am getting is: Exception from HRESULT: 0x80040013
Steps I followed were:
Installing R 2.15.1 for windows xp (32 bit)
Installed R_Scilab_DCOM3.0-1B5
Loaded rscproxy_1.3-1 package in the R/R.15.1/library
Set the System Variable path to C:/Program Files/R/R.15.1/bin
Added 3 COM references-STATCONNECTORCLNTLib,StatConnectorCommonLib,STATCONNECTORSRVLib
Code:
private StatConnectorClass _statconnector = new STATCONNECTORSRVLib.StatConnectorClass();
_statconnector.Init("R");--> Line shows the Exception from HRESULT: 0x80040013
I have used the COM method to interface to c# some years ago, but I gave up because on each version change there were problems similar to that you mentioned. In addition, the licensing scheme of R(D)COM is a bit obscure to me, and the .NET/COM/R tour has too many corners.
My current choice is Rserve, which is well maintained and has never let me down. I had written my own test bed for c#, but I consider it obsolete because RserveCLI is more complete.
R.NET in theory is a better concept, but for strange reasons it is considered "stable" by the author, which is highly euphemistic because of the many bugs mainly in memory management. Too bad it never took off.
I believe R.NET is a much better way to access R functionality from C#. It all runs in-process and so doesn't require an external R process to be running.
If you install the NuGet package, you will get version 1.5. This incorporates some memory management fixes I made that address most of the crashes people have reported. As Dieter points out, we use R.NET extensively via the F# RProvider, and it is extremely stable with the latest version. The RProvider also comes with a wrapper generator that generates wrapper functions for R functions which can be used from C#. So for example you could call the plot function from C# as R.plot(...params...). And you get Intellisense.

OpenSSL.net: null Ciphers

all,
I'm looking into OpenSSL.NET and have hit a bit of a wall with it. As I said, I'm only looking into it, but a project at work needs to use it, so I can't really use anything else. The problem I'm getting is that I'm using the Cipher attribute to select an encyption type, yet each one throws the following error:
The type initializer for 'OpenSSL.Crypto.Cipher' threw an exception.
Also, when I look at the debugger, each Cipher has "null" as it's value. I've got the ManagedOpenSsl.dll referenced, and libeay32.dll and ssleay32.dll are both in the working directory, so I'm a tad stuck.
Any help on this would be much appreciated. Also, has anyone found any good stuff to read on the OpenSSL library? I've spent two hours looking, but nothing useful shows up.
Cheers

Categories