1

我刚刚在我的 Suse-Linux EC2 实例中安装了 openfire 服务器,并且除了管理员之外,我还通过创建一个名为“balaji”的用户来配置 openfire 服务器。

然后,我为 iOS 平台安装了 ilibjingle 代码,并且能够构建它。我在模拟器中运行它,它非常适合我的 gmail-id。它登录,然后从花名册列表中获取用户。

然后我修改了代码以指向我的 openfire 服务器 IP 地址,并将用户名设为“balaji”(我在 openfire 中创建的那个)和适当的密码。我在 openfire 服务器中也有一个自签名 SSL 证书。当我运行此代码时,它能够连接,但无法登录(我相信)。ilibjingle 代码应该从连接到登录到登录到名册列表。当我使用我的 openfire 服务器运行时,它从 Connect 变为 Login,但除此之外什么都没有。

可能出了什么问题?我应该修改我的 openfire 服务器中的任何内容以使其正常工作吗?这是我的 iPhone 代码。

在 rootviewcontroller.mm 中,我有以下片段。

-(void) _mainGtalkThread:(id)sender
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    //you need to setup name and passwd manuelly here
    char *name = "balaji";
    char *password = "mypasswd";
    [self gtalk_main:(char*)name userpassword:(char*)password];
    [pool release];
}


-(int) gtalk_main:(char*)un userpassword:(char*)password 
{
// This app has three threads. The main thread will run the XMPP client,
// which will print to the screen in its own thread. A second thread
// will get input from the console, parse it, and pass the appropriate
// message back to the XMPP client's thread. A third thread is used
// by MediaSessionClient as its worker thread.

buzz::Jid jid;
talk_base::InsecureCryptStringImpl pass;

std::string username = un;
if (username.find('@') == std::string::npos) {
    username.append("@localhost");
}
jid = buzz::Jid(username);
if (!jid.IsValid() || jid.node() == "") {
    printf("Invalid JID. JIDs should be in the form user@domain\n");
    return 1;
}
pass.password() = password;

buzz::XmppClientSettings xcs;

xcs.set_user(jid.node());
//xcs.set_resource("call");
xcs.set_host(jid.domain());
xcs.set_pass(talk_base::CryptString(pass));
xcs.set_use_tls(false);
xcs.set_allow_plain(true);

xcs.set_server(talk_base::SocketAddress("50.37.185.206", DEFAULT_PORT));
printf("Logging in as %s with user as %s\n", jid.Str().c_str(), jid.node().c_str());

talk_base::InitializeSSL();

talk_base::Thread athread;
talk_base::ThreadManager::SetCurrent(&athread);

talk_base::Thread* main_thread = talk_base::Thread::Current();
assert(main_thread!=NULL);

XmppPump pump;
//CallClient *client = new CallClient(pump.client());
gtalkClient_ = new gtalkClient(pump.client(), self);

pump.DoLogin(xcs, new XmppSocket(true), NULL);
main_thread->Run();

return 0;
}

在另一个文件“gtalkclient.mm”中,我有以下内容:

gtalkClient::gtalkClient(buzz::XmppClient* xmpp_client, void * controller) :
xmpp_client_(xmpp_client), controller_(controller), media_engine_(NULL),
media_client_(NULL), call_(NULL), incoming_call_(false), auto_accept_(false),
pmuc_domain_("conference.localhost"), local_renderer_(NULL), remote_renderer_(NULL),
roster_(new RosterMap), portallocator_flags_(0)
{
    xmpp_client_->SignalStateChange.connect(this, &gtalkClient::OnStateChange);
}


void gtalkClient::OnStateChange(buzz::XmppEngine::State state) 
{         
    RootViewController * tvc = (RootViewController*)controller_;
    switch (state) {
      case buzz::XmppEngine::STATE_START:
        printf("connecting...");
      [tvc.roster_ removeAllObjects];
      [tvc.roster_ addObject:@"connecting..."];
      [tvc reloadTableViewData];
        break;

      case buzz::XmppEngine::STATE_OPENING:
        printf("logging in...");
      [tvc.roster_ removeAllObjects];
      [tvc.roster_ addObject:@"logging in..."];
      [tvc reloadTableViewData];
        break;

      case buzz::XmppEngine::STATE_OPEN:
        printf("logged in...");
      [tvc.roster_ removeAllObjects];
      [tvc.roster_ addObject:@"logged in..."];
      [tvc reloadTableViewData];
        InitPhone();
        InitPresence();
      // prepare to add roster
      [tvc.roster_ removeAllObjects];
        break;

      case buzz::XmppEngine::STATE_CLOSED:
        buzz::XmppEngine::Error error = xmpp_client_->GetError(NULL);
        printf("logged out...%s", strerror(error).c_str());
      [tvc.roster_ removeAllObjects];
      [tvc.roster_ addObject:@"logged out..."];
      [tvc reloadTableViewData];
    Quit();
      }
    }
4

1 回答 1

4

libjingle在我的服务器上运行示例程序时,我也遇到了同样的问题。这是openfire因为较新版本的libjingle不支持未知机构的证书。

因此,您需要撤消xmppsocket.cc对 rev65 所做的更改(何时libjingle更新到版本 0.5.6):
此链接将帮助您查看两个版本之间的差异 http://code.google.com/p/libjingle/source/diff ?spec=svn95&r=65&format=side&path=/trunk/talk/examples/login/xmppsocket.cc&old_path=/trunk/talk/examples/login/xmppsocket.cc&old=30

在此提交中,他们删除了允许未知证书颁发机构证书的两行。

我按照上面的说明解决了这个问题,或者您可以按照下面的链接获得完整的想法。 http://code.google.com/p/libjingle/issues/detail?id=250

于 2011-12-22T07:15:01.213 回答