rtmplite hangs if we wait for it to talk first 1.x@63
authorhyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
Wed, 16 Dec 2009 06:26:23 +0000 (06:26 +0000)
committerhyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
Wed, 16 Dec 2009 06:26:23 +0000 (06:26 +0000)
git-svn-id: svn://svn.mplayerhq.hu/rtmpdump@63 400ebc74-4327-4243-bc38-086b20814532

handshake.cpp

index 8d53eae..82052ff 100644 (file)
@@ -257,12 +257,10 @@ bool CRTMP::HandShake(bool FP9HandShake)
 {
        bool encrypted = Link.protocol == RTMP_PROTOCOL_RTMPE || Link.protocol == RTMP_PROTOCOL_RTMPTE;
 
-       FP9HandShake = true;//false;
-
-       if(encrypted && !FP9HandShake) {
-               Log(LOGERROR, "%s: RTMPE requires FP9 handshake!", __FUNCTION__);
-               return false;
-       }
+       if ( encrypted || Link.SWFHash )
+               FP9HandShake = true;
+       else
+               FP9HandShake = false;
 
        char clientsig[RTMP_SIG_SIZE+1];
        char serversig[RTMP_SIG_SIZE];
@@ -398,11 +396,16 @@ bool CRTMP::HandShake(bool FP9HandShake)
        LogHex(LOGDEBUG, serversig, RTMP_SIG_SIZE);
        #endif
 
+       if (!FP9HandShake) {
+               if(!WriteN(serversig, RTMP_SIG_SIZE))
+                       return false;
+       }
+
        // we have to use this signature now to find the correct algorithms for getting the digest and DH positions
        int digestPosServer = GetDigestOffset2(serversig, RTMP_SIG_SIZE);
        int dhposServer     = GetDHOffset2(serversig, RTMP_SIG_SIZE);
 
-       if(!VerifyDigest(digestPosServer, serversig, GenuineFMSKey, 36)) {
+       if(FP9HandShake && !VerifyDigest(digestPosServer, serversig, GenuineFMSKey, 36)) {
                Log(LOGWARNING, "Trying different position for server digest!\n");
                 digestPosServer = GetDigestOffset1(serversig, RTMP_SIG_SIZE);
                dhposServer     = GetDHOffset1(serversig, RTMP_SIG_SIZE);
@@ -493,8 +496,6 @@ bool CRTMP::HandShake(bool FP9HandShake)
                        Log(LOGWARNING, "%s: client signature does not match!", __FUNCTION__);
                }
 
-               if(!WriteN(serversig, RTMP_SIG_SIZE))
-                       return false;
        } else {
                // verify server response
                int digestPosClient = GetDigestOffset1(clientsig+1, RTMP_SIG_SIZE);