开发者

ilibjingle with the Openfire server - Not able to login

开发者 https://www.devze.com 2023-03-23 13:03 出处:网络
I just installed openfire server in my Suse-Linux EC2 instance and I\'ve configured the openfire server by creating one user named \'balaji\' in addition to the admin.

I just installed openfire server in my Suse-Linux EC2 instance and I've configured the openfire server by creating one user named 'balaji' in addition to the admin.

I then installed the ilibjingle code for the iOS platform and I was able to build it. I ran it in the simulator and it worked perfectly for my gmail-id. It logged in, then brought the users from the roster list.

I then modified the code to point to my openfire server IP address and gave the username as 'balaji' (the one I created in openfire) and the appropriate password. I also have a self signed SSL certificate in the openfire server. When I ran this code, it was able to connect, but not able to login (I believe). The ilibjingle code is supposed to go from Connect to Login to LoggedIn to the Roster list. When I ran with my openfire server, it went from Connect to Login, but nothing beyond that.

What could have possibly gone wrong? Should I modify anything in my openfire server to make this wor开发者_如何学Pythonk? Here's my iPhone code.

In the rootviewcontroller.mm, I have the following snippet.

-(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;
}

and in another file 'gtalkclient.mm', I have the following:

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();
      }
    }


I also had the same issue while am running libjingle sample program with my openfire server.Its because newer version of libjingle didn't support the certificates of unknown authorities.

So you need to undo the changes made on xmppsocket.cc on rev65 (when libjingle was updated to version 0.5.6):
This link will help you to see difference between two version 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

In this commit, they removed two lines that were allowing certificates of unknown Certificate Authorities.

I got solved the problem by following the above instructions Or you can follow the below link to get the complete idea. http://code.google.com/p/libjingle/issues/detail?id=250.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号