sockets - Using TLS on Google Talk XMPP TCP connection using PHP -


i trying connect google talk xmpp server using php. successful establishing connection , logging in using x-oauth2. google requires establish tls connection. when trying upgrade connection tls exception: stream_socket_enable_crypto(): peer certificate cn='gmail.com' did not match expected cn='talk.google.com'.

here steps:

$stream = stream_socket_client('tcp://talk.google.com:5222', $error_num, $error_str); // ... login, //server tells me use tls, //i tell going to, //it tells me proceed ... stream_socket_enable_crypto($stream, true, stream_crypto_method_tls_client); 

and error:

stream_socket_enable_crypto(): peer certificate cn='gmail.com' did not match expected cn='talk.google.com' 

of course, if try connect xmpp server via tcp://gmail.com or tcp://www.gmail.com, won't work.

i have tried establishing tls before logging in (which, assume more secure way of doing it), same problem. here whole handshake error:

me:     <stream:stream to="gmail.com" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" version="1.0">  google: <stream:stream from="gmail.com" id="7373af2152849b51" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client">             <stream:features>                 <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls">                     <required/>                 </starttls>                 <mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">                     <mechanism>x-oauth2</mechanism>                     <mechanism>x-google-token</mechanism>                 </mechanisms>             </stream:features>  me:     <auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="x-oauth2" auth:service="oauth2" xmlns:auth="http://www.google.com/talk/protocol/auth">encrypted user , pass</auth>  google: <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>  me:     <stream:stream to="gmail.com" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" version="1.0">  google: <stream:stream from="gmail.com" id="b3a6ad05178a5bf2" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client">             <stream:features>                 <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls">                     <required/>                 </starttls>                 <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/>                 <session xmlns="urn:ietf:params:xml:ns:xmpp-session"/>             </stream:features>  me:     <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>  google: <proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"/> 

i haven't figured out how fix problem, avoid altogether connection via tls get-go , using port 5223 instead:

stream_socket_client('tls://talk.google.com:5223', $error_num, $error_str); 

Popular posts from this blog