TLS Implementation Silverlight - c#

I am trying to implement TLS client in a Silverlight XMPP application.
I found a nice documentation about TLS at tools.ietf.org, there are a good explanation of structures, but I can't find an explanations of how to convert these strunctures into a raw message (bytes).
Here is for example a ClientHello message.
Can anyone share some tips or workarounds, or at least an example of how the ClientHello message should look in bytes?
I tried to sniff it out using WireShark, but it does not show the whole picture.

If something is in full .NET Framework, and does not present in Silverlight, the first option for you is to go to Mono code base and find a way to port it,
https://github.com/mono/mono
As most Mono class library code is licensed under MIT/X11, it is safe to reuse them.
Starting from scratch like you did is not recommended if you've never done similar things before.

TLS is not a trivial thing to implement. Unless you have specific reasons to do this, it's wiser to use existing implementation. You can use Mono as suggested above and port its code, or you can use SSL/TLS classes of our SecureBlackbox library, which is available for Silverlight as well, and doesn't require any extra coding from you.

Related

How to do ebMS3 AS4 messaging from C# client application

I am looking out for developing a C# application which posts message to a ebMS3 platform using AS4. I am new to this area. Could anyone please help? Is there any third party libraries to do this easily? If not, how we post messages using AS4 from a c# solution.
I have just implemented our own AS4 solution, and it is hard task to accomplish. Especially because .NET does not support SOAP with attachments out of the box. And there is a lot background knowledge you need to know about - all the different specifications AS4 is based on. I have not been able to find an AS4 API written in .NET without it being a standalone solution as well...
First thing is to understand AS4, and a good place to start is this blog:
https://www.codit.eu/blog/2016/02/03/as4-for-dummies-part-ii-messaging-overview/
And then you will have to understand most of the EBMS3 specification:
http://docs.oasis-open.org/ebxml-msg/ebms/v3.0/core/ebms_core-3.0-spec.html
That being said - it is not impossible.
I have been looking at the AS4.NET framework as Sander talks about, and it is well-written and a very good starting point for exchanging AS4 messages. I have used it as a test-endpoint.
So unless you need to incorporate AS4 directly into an existing product (which we needed to), I can only recommend using AS4.NET.
AS4.NET is also open source (and e-SENS profile conformant), so you can have a look at their code-base and let you inspire by the hard parts in AS4.
For the MIME parts I can recommend Mimekit: https://github.com/jstedfast/MimeKit
And for some of the encryption/signing stuff Bouncycastle is great: http://www.bouncycastle.org/csharp/
Not sure whether it can be used as a library, but for a project within the European Commission an open source .NET based AS4 implementation was developed. You can find it here in the EC's code repository. I don't know if there is any support on this, so if that is important you should probably consider another implementation. A list of solutions tested by the EC for conformance with their own profile of AS4 is available here (or if that link doesn't work by searching for "as4 conformance tested implementations")
Note that most are standalone applications which you connect to for executing the AS4 message exchange. Most offer different integration options, so you should be able to integrate it into your solution.

How to set ZMQ_ROUTER_MANDATORY using C# bindings?

I´m using Official .NET Bindings for ZeroMQ (x86) 2.2.5 and cannot figure out how to set this Socket Option. Can anyone please shed some light on me ?
CLRZMQ is obsolete, NetMQ(https://github.com/zeromq/netmq) is now the official stack for windows.
in NetMQ use socket.Options.Mandatory = true;
CLRZMQ is not obsolete (see zeromq.org). The key difference between the two is in the approach:
CLRZMQ is binding project which actually uses libzmq library in background (it's a .NET wrapper for libzmq library);
NetMQ is .NET-native port of ZeroMQ, meaning that it does not wrap existing libzmq but rewrites it in pure C#.
Which one to use? Well, there's no simple answer. Here are few important things to keep in mind while choosing:
When it comes to portability - NetMQ wins by far, especially due to the fact that there's .NET Core version of NetMQ. Deployment is also easier with NetMQ - there are no native libraries to worry about (x64 / x86, etc.).
On the other side the fact that NetMQ actually rewrites everything is bit scary for me - there's always risk that something is not precisely mirrored from the original code, and that it may cause incompatibility with other ZeroMQ nodes. There's also question how fast NetMQ will implement new features from the original library.
Performances. At the moment I don't know which library wins in performances, but this is definitely thing to consider while choosing. libzmq should be significantly faster than any managed code, but in communication between CLRZMQ and libzmq marshaling has to take place, so I really can't predict which library will win in speed.

monitor internet usage in .net

I want to write a method in C# to check which applications in my machine/server are using internet connection at a particular point in time and if possible, how much bandwidth they are using. Can anyone please help me get a head start on this?
I decided to write an answer because comments are too small.
Well, reading other Q&A on stackoverflow and looking around on the internet, I didn't find a simple solution for your problem.
Actually, for .NET processes is really simple, you just need to retrieve informations from ".NET CLR Networking - Bytes Received/Bytes Sent" performance counters, as shown in this Q&A
But in general, getting per-process used bandwidth isn't an easy work.
For example "Microsoft Network Monitor" sniffer can trace the process that generates internet packets only for TCP traffic, because probably it maps IP-port pairs with processes using them (or something similar, TCP is a connected protocol so it is simpler).
Anyway if you want to give it a try you can use the exposed API (look at this blog entry for some hint).
However, as suggested in these Q&A's (LINK 1, LINK 2), the right, and probably the only way, is to write a NDIS/TDI driver that can intercept network traffic and exposing a .NET callable API to it.
The problem is that such drivers can't be written in managed code, and so you need to implement it in C/C++.
Obviously, if you manage to find an already written driver/sniffer exposing a callable API, you can use it.
For example WinPCap has one (and some .NET wrappers like SharpPCap or PCap.Net), but I don't think (not sure) it's able to get packets's source-process information.
As digEmAll noted, in pre-Vista Windows you are reduced to writing your own driver or using a 3-rd party one. In Vista, 2008 and Windows 7 you can use the GetPerTcpConnectionEStats API (there is a large example of its usage on the MSDN page). Resource Monitor relies on this API, together with the older GetTcpTable/GetTcpRow APIs, for extended network statistics.
I found Process Monitor as a very useful tool and it served my purpose so I didnt had to write any code although i am yet to check out whether it gives any API which i can use in my application to get some information I need.
Thanks everyone for helping me out.

RDM Sockets

I've recently come across .NET's RDM Socket type (SocketType.Rdm) and its features sound very promising, sounding very much like a reliable connectionless protocol. However, I've found no examples of its usage, and little documentation on the protocol itself.
First of all, how do I instantiate a socket of this type? Specifying SocketType.Rdm in the socket constructor always seems to cause an exception. Secondly, is this protocol referred to by a different name outside of .NET? As I say, the protocol seems to undocumented despite it's promising feature set.
Thanks
RDM sockets do support PGM. However PGM support is not installed on Windows by default, but as part of the MSMQ installation. If you have Windows 7, this is the command line that will prompt Package Manager to install the right components.
pkgmgr /iu:MSMQ-Container;MSMQ-Server;MSMQ-Multicast
Try running your socket after installing this and see if you still have the same exception.
As far as I know this is PGM. Here are some random links to MS forum bits:
devshed,
ms.
I have no idea about the maturity of .NET implementation.
Reliable Multicast with PGM and WCF is an interesting article over at codeproject on how to use RDM (PGM) sockets. It features both raw PGM sender/receiver classes and also builds on it by implementing WCF connectors for PGM

TLS/SSL in .net

Is there any (hopefully free/open source) code available that does native TLS/SSL communication? I do not speak about the HTTPListener/Client and WebRequest classes. I'd like to do raw TLS communication in my C# code.
Thanks in advance,
Max
Here's an article on codeproject, it also includes code for using OpenSSL.
Do you mind if I ask what you're trying to achieve? Just curious really; there's lots of high-level wrapper classes for this kind of thing so you don't normally need to work at this level (not that there's anything wrong with that :-)
http://www.mentalis.org/soft/projects/ssocket/ - been using this in a commercial product for the last 5 years in .net 1.0, 2.0 and now 3.0. Very reliable, simple to use and stable.
Built-in (as at time of writing) SslStream object makes this easy - see https://www.medo64.com/2014/09/client-authenticated-tls-in-c/

Categories

Resources