Wowza Community

AS3 OSMF & Secury Token

Hi

is it possible to use Flex OSMF and authenticate a stream with secury token ?

Im trying to use NetConnectionFactory to create a netConnection and handle its status to get a secury token, but i didnt find a way to do it…

in the old version of the app, with AS2, I used this code:

thisNc.call(“secureTokenResponse”, new Responder(onResult), TEA.decrypt(e.info.secureToken, myKey));

thisNc is a NetConnection.

but, how can I do it with AS3 osmf ?

I mean…

I is there a way to manipulate the NetConnection, or any other way to do this authentication ?

any help ?

tks a lot

[]'s

Harley

You will need the OSMF source code instead of the swc file. Then you can modify the onNetStatus function in NetLoader.as file, which is in the org.osmf.net package.

You can check out the source with svn here:

http://opensource.adobe.com/svn/opensource/osmf

Then copy the org folder from here:

OSMF source framework\OSMF\org

To the Flash Builder project src folder

Then Delete the SWC file, modify the file and rebuild.

Richard

Below is source from a version of Wowza OSMF player that handles SecureToken and the Wowza Load Balancer NetConnection 302 redirect method, which are both things we decided not to include with the Wowza OSMF examples because the OSMF Wowza examples are more directed to Sanjose (Flash HTTP) streaming, but can of course do RTMP as well.

Removed

Richard

You can get com.wowza.encryptionAS3.TEA from any of the Wowza Flash examples.

Richard

I will do some tests today.

Richard

I’ve been working on it. The source I posted was a bit mangled. I have it clearing the NetConnection NetStatusEvent handler, and handling the SecureToken, but haven’t quite got the RTMP playback re-constituted.

Richard

Turns out I was looking on the wrong machine. I updated the earlier post above with a player that uses OSMF framework, plays RTMP and handles SecureToken and 302 redirect.

However, Sanjose streams don’t work. Frankly, I’m not sure this qualifies as a OSMF player. It uses the OSMF framework then works around it really, and evidently breaks a key feature: Sanjose HTTP streaming. But take a look for what it’s worth. I might not leave it up.

Richard

In my tests, it does plays RTMP and runs NetConnection NetStatusEvent, but it’s not a good example. Thanks for reminding me, I removed it again. I really just don’t know how to bring SecureToken functionality as it exists now into OSMF framework.

Richard

tks a lot for your reply

now that you mentioned it, Im quitting using osmf, lol

tks bro!

[]'s

Harley

In my tests, it does plays RTMP and runs NetConnection NetStatusEvent, but it’s not a good example. Thanks for reminding me, I removed it again. I really just don’t know how to bring SecureToken functionality as it exists now into OSMF framework.

Richard

If anybody is interested in using OSMF 1.6 with Wowza SecureToken write me a message. I got it working a couple of weeks ago.

If anybody is interested in using OSMF 1.6 with Wowza SecureToken write me a message. I got it working a couple of weeks ago.

Give me a day or two to get the things together.

Here are the changes I’ve made to get it working with OSMF 1.6.1 (should be easy to get this working on OSMF 2.0 too):

  • add the TEA encryption library from wowza to the sourcecode

  • at the top of org/osmf/net/NetNegotiator.as include the TEA.as ->

import com.wowza.encryptionAS3.TEA;

  • change the following at NetNegotiator.as in the function “onNetStatus”:
				case NetConnectionCodes.CONNECT_SUCCESS:
				
					// #### ADD THIS #####
					if(event.info.secureToken != null)
						NetConnection(event.target).call("secureTokenResponse", null, TEA.decrypt(event.info.secureToken, "SECURE_TOKEN"));					
					// #### END #####
					
					if (	event.info.hasOwnProperty("data")
						&& 	event.info.data.hasOwnProperty("version")
					   )
					{
						// Decorate the resource with the FMS version, as it may be useful downstream.
						resource.addMetadataValue(MetadataNamespaces.FMS_SERVER_VERSION_METADATA, event.info.data.version);
							
						CONFIG::LOGGING
						{
							logger.info("FMS Version: " + event.info.data.version);
						}
					}
					else
					{
						CONFIG::LOGGING
						{
							logger.info("FMS Version unknown");
						}
					}

that’s it.

Here are my changes packaged in a zip files:

http://funkdoobiest.de/wowza_osmf_securetoken.zip

changes are marked with “HERE” in the source code.

Hi

I tried to modify the NetLoader.as file in OSMF v1.5 stable but I’m still not having any luck.

I used the following code block in the onNetStatus function in the case NetConnectionCodes.CONNECT_SUCCESS:

if (event.info.secureToken != null) {netConnection.call(“secureTokenResponse”, null, TEA.decrypt(event.info.secureToken, “#ed%h0#w@1”));}

However, I’m still getting the same result as if it wasn’t there at all. I also checked the OSMF example that ships with Wowza but it doesn’t look like that uses secureToken. I’m by no means a master developer. Are there any other suggestions on how to get this to work?

Thanks

Hi Richard, thanks for the code snippet. I am using secureToken and enforcing RTMPe only to protect our stream.

It looks like the secureToken is working, but I still receive the same error with your code. The trace on the client side looks like this:

testVersion: MAC 10,3,181,26>=10,1,0,0: true

secureTokenResponse: true

event.traitType: audio

event.traitType: buffer

event.traitType: time

event.traitType: displayObject

event.playState: playing

event.traitType: play

infoObj.info.code: NetConnection.Connect.Closed

event.time: NaN

player.duration: NaN

event.time: NaN

player.duration: NaN

event.time: NaN

player.duration: NaN

Error: Error #2154: The NetStream Object is invalid. This may be due to a failed NetConnection.

at flash.net::NetStream/play2()

at org.osmf.net::NetLoader/reconnectStream()[/Users/rashad/Documents/Adobe Flash Builder 4/WowzaSample/src/org/osmf/net/NetLoader.as:409]

at Function/org.osmf.net:NetLoader/private:setupStreamReconnect/org.osmf.net:onNetStatus()[/Users/rashad/Documents/Adobe Flash Builder 4/WowzaSample/src/org/osmf/net/NetLoader.as:616]

On the server side, the trace is:

INFO session connect-pending 127.0.0.1 -

INFO session connect 127.0.0.1 -

ERROR session comment 1302063160 ModuleSecureToken.onConnect: Action before response received: kill connection: clientId:1302063160

It seems like something that was happening in this thread:

http://www.wowza.com/forums/showthread.php?575-secure-token-failure

Obviously the code you’ve given me works so I’m messing something up here. I followed the instructions to setup the server-side security module and made no special changes. The only change I made to the code snippet was to set the rtmpURL to connectURL directly instead of doing the replace functions to preserve the rtmp. Have you ever tried using this code with RTMP?

For reference, I’m using:

Flex SDK 4.1

OSMF 1.5

Wowza 2.2.4

Thanks.

Yes, I did use the OSMF v1.5 source and not the swc. Does anyone have any examples of OSMF and Wowza secureToken?

Unfortunately, the code still produces the exact same result. Actually, the code looks fairly similar to the snippet that was posted before. Are you sure it was successfully switched out?

Again, I always assume I’m doing something wrong but I did try to clear my browser cache in case. Maybe the version of OSMF that I’m using is newer (1.5)? What .swc version did you use to get that code to work? Or did you use the latest source?

I would love to get this last issue resolved and switch my secure content to Wowza as well.

Thanks

I think You will need the OSMF source code instead of the swc file.

Hi,

How to do the securetoken in OSMF player?please guide me.if u have a sample please send me it’s very helpful to me

Thanks,

AravindakumarThangaraju

If anybody is interested in using OSMF 1.6 with Wowza SecureToken write me a message. I got it working a couple of weeks ago.