良好的C#XMPP库支持群聊和TLS或SSL加密 [英] Good C# XMPP Library supporting Group Chat and TLS or SSL Encryption

查看:463
本文介绍了良好的C#XMPP库支持群聊和TLS或SSL加密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我一直在寻找有一个像样的C#库,不仅能支持客户端和服务器之间的SSL或TSL加密XMPP使用挣扎。我希望有人可以推荐符合我的一些需求,是相当良好的支持/记录我库。另外也许有人可以证实我一些我已经试过库的怀疑。

So I have been struggling with finding a decent C# library to use with XMPP that supports either SSL or TSL encryption between the clients and the server. I am hoping that someone can recommend I library that meets some of my needs and is fairly well supported/documented. Also perhaps someone can confirm my suspicions about some of the libraries I've already tried.

我用肥皂箱工作室SDK的第一次尝试。 发现这里从的Conversant ,但是从我可以告诉他们只支持SASL认证。我试图联系他们,但没有得到回应,并有论坛,似乎是不工作,因为我无法张贴在他们的论坛我的问题。也许我错了我的SSL假设与肥皂盒的图书馆,这将是巨大的,如果有人可以纠正我,因为这是我宁愿使用图书馆。

My first attempt used Soapbox Studio SDK. Found here from Conversant, however from what I can tell they only support SASL authentication. I attempted to contact them but received no response and there forum appeared to be not working as I could not post my question on their forum. Perhaps I am wrong about my SSL assumption with Soapbox's library, which would be great if someone could correct me because that is the library that I would prefer to use.

我旁边转移到矩阵这是后继agXmpp。几天曳其留言板,并通过他们的示例应用程序会之后,我不能奶源,甚至我的Openfire服务器上创建一个群聊。几乎所有的formum 的直接人们使用他们的示例应用程序来回答贴在 AG软件相关的问题的问题。但是,除非我误解的东西,他们的许多示例应用程序似乎是过时或不适合我的需要。下面的代码是我尝试使用他们的库来创建一个群聊的一个例子。如果有人已经用他们的图书馆也许他们能指出我在做什么错。

I next moved on to Matrix which is the successor to agXmpp. After several days trolling their message boards and going through their sample applications I cannot mange to even create a Group Chat on my openfire server. Almost all of the related questions posted on the ag Software formum direct people to use their sample applications to answer their questions. However, unless I am misunderstanding something, many of their sample applications appear to be out of date or not suitable for my needs. The following code is an example of my attempting to use their libraries to create a Group chat. If anyone has used their library perhaps they can point out what I am doing wrong.

这是我使用指令使用系统

These are my using directives

using System;
using Matrix.Xmpp.Disco;
using Matrix.Xmpp.Client;
using Matrix.Xmpp.Session;
using Matrix.Xmpp;
using Matrix;

下面是连接到XMPP客户

Here is the code that connect to the Xmpp Client

readonly XmppClient _xmppClient = new XmppClient();

public string Connect() {
   try
   {
       _xmppClient.SetUsername(OPENFIRE_USER_NAME);
       _xmppClient.Password = OPENFIRE_PASSWORD;
       _xmppClient.SetXmppDomain(OPENFIRE_SERVER);

       _xmppClient.Show = Matrix.Xmpp.Show.chat;
       _xmppClient.AutoRoster = true;
       _xmppClient.Open();

                return "Connection Succesful";
    }
    catch (Exception ex)
    {
       _logger.LogError("SessionManager", "Connect", "Could not connect to Openfire                     Server", ex.ToString());
                        return "Could not Connect to Openfire Server";
    }
}



这是假设创建代码新的聊天室

and this is the code that is suppose to create a new chatroom

public string CreateRoom(string roomName, string serverName, string userName)
{
    Jid groupJid = new Jid(userName, serverName, "gec2o");

    using (MucManager mucManager = new MucManager(_xmppClient))
    {
        mucManager.EnterRoom(groupJid, roomName, true);
        mucManager.RequestInstantRoom(groupJid);
    }

    return "";
}



但没有聊天室是在服务器上创建并没有异常。此外,我知道我能够使用他们的库连接到我的服务器,因为我可以看到我的登录名出现在用户的Openfire的名单。虽然他们在一个文件中记录所有的课,图书馆提供关于每个类/方法实际上做很少或没有意见,应该如何使用。再次,有论坛,主要是告诉人们来看看示例代码这在很大程度上是无益的,像肥皂盒这个库似乎并没有是很好的支持(看起来像一个开发人员曾经回答一个问题)。

However no chatroom is created on the server and no exception is thrown. Also I know that I am able to use their library to connect to my server because I can see the my login name appear in openfire's list of users. While they have all their class documented in a file, the library offers little or no comments on what each class/method actually does and how it should be used. Again, there forum mostly tells people to look at sample code which is largely unhelpful and like soapbox this library does not appear to be that well supported (looks like one developer answering ever single question).

我简要地看着其他库如的闲聊网但是这似乎是相同的故事,肥皂盒和Matrix在支持和文档方面。

I briefly looked into other libraries such as jabber-net but that appeared to be the same story as Soapbox and Matrix in terms of support and documentation.

我也碰到 IP *工程Internet工具包但该库似乎有些成本过高。

I also came across IP*Works Internet Toolkit but that library appears to be somewhat cost prohibitive.

我意识到我做了整个问题的假设一个很好的协议,但我一直在研究好几天了,这是我一直在最好的结论能来到。我希望有人可以纠正我的假设或建议,不会出现这些问题,我一直面临着库。

I realize that I've made a good deal of assumptions throughout this question but I've been researching for several days now and this is the best conclusions I've been able to come to. I'm hoping someone can either correct my assumptions or recommend a library that does not exhibit these issue I've been facing.

推荐答案

因此,它看起来好像一直认为这个问题的答案是,我原来的首选库(肥皂盒工作室SDK)是否确实支持TLS加密,因此用最佳的选择始终。它看起来好像TLS只是没有很好的记载和/或我错过了这个功能。

So it looks as though all along that the answer to this question was that my original preferred library, (Soapbox Studio SDK) does in fact support TLS encryption and therefore was by best choice all along. It looks as though TLS is just not well documented and/or I missed this feature.

根据服务器配置(我使用的是Openfire的服务器),你应该能够将您的服务器配置为只接受加密连接。而不是使用SSL(其中的Openfire是从其服务器弃用的过程),并试图通过SSL端口5223连接,只需连接于默认端口(5222),并要求加密连接将迫使客户端使用向发送数据TLS和自动协商握手。另外,服务器可以被配置以防止客户端创建其他用户。通过控制客户机能够在服务器上创建XMPP用户,而不是颁发的SSL证书,因此你基本上是确保在整个安全通信。

Depending upon your server configuration ( I am using an Openfire Server ), you should be able to configure your server to only accept encrypted connections. Rather than using the SSL (which Openfire is the process of deprecated from its server ) and attempting to connect over the SSL port 5223, Simply connected over the default port (5222) and requiring an encrypted connection will force the client to send the data using TLS and automatically negotiate the handshake. Also the server can be configured to prevent clients from creating additional users. By controlling which clients are able to create XMPP users on your server rather than issuing SSL certificates you therefore essentially ensure secure communication throughout.

这篇关于良好的C#XMPP库支持群聊和TLS或SSL加密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆