wowza流服务器截获hls密钥请求响应

5lhxktic  于 2021-07-13  发布在  Java
关注(0)|答案(1)|浏览(367)

我遇到了一个场景,在aes加密内部方法的情况下,需要截获hls密钥请求的响应。
以下是wowza给出的句柄

onHTTPCupertinoEncryptionKeyCreateLive(IApplicationInstance
appInstance, String streamName, byte[] encKey)

请求实时流密钥时调用(每个已发布流)

void onHTTPCupertinoEncryptionKeyCreateVOD(HTTPStreamerSessionCupertino
httpSession, byte[] encKey)

请求视频点播密钥时调用(每个会话)

void onHTTPCupertinoEncryptionKeyData(HTTPStreamerSessionCupertino
httpSession, IHTTPRequest req, IHTTPResponse resp, byte[] encKeyData)

在请求密钥数据时调用。

void onHTTPCupertinoEncryptionKeyLiveChunk(ILiveStreamPacketizer
liveStreamPacketizer, String streamName, CupertinoEncInfo encInfo, long
chunkId, int mode)

请求实时流密钥时调用(每个已发布流、每个区块-用于旋转密钥)

void onHTTPCupertinoEncryptionKeyRequest(HTTPStreamerSessionCupertino
httpSession, IHTTPRequest req, IHTTPResponse resp)

在请求密钥时调用。
上述所有方法都会截获密钥请求调用。在密钥响应发送到客户端之前,是否有任何方法可以截获它?

af7jpaap

af7jpaap1#

虽然有一个解决方法可以使用 onHTTPCupertinoEncryptionKeyData(HTTPStreamerSessionCupertino httpCupertinoStreamingSession, IHTTPRequest req, IHTTPResponse resp, byte[] encKeyData) 方法,最好的方法是使用外部方法进行aes-128加密。您将使用与流名称同名的.key文件,并包含代码的url,该url将提供用于解密的密钥数据。
.key文件的内容类似于:

cupertinostreaming-aes128-key: DE51A7254739C0EDF1DCE13BBB308FF0
cupertinostreaming-aes128-url: http:/mycompany.com/security.aspx

.key文件需要位于wowza安装的keys/目录中,如果vod文件位于子目录中,.key文件还需要与vod文件具有相同的子目录树。
例如,如果您的vod文件sample.mp4位于content/subdir/中,那么您的密钥文件将是keys/subdir/sample.mp4.key,您的播放url将是 http://wowzaIP:1935/vod/_definst_/mp4:subdir/sample.mp4/playlist.m3u8 . 然后,您可以通过查看位于logs/wowzastreamingengine\u access.log文件中的访问日志来验证这是否有效。您应该看到类似于以下内容的行:

HTTPStreamerCupertinoIndexFile.init[vod/_definst_/sample.mp4]: Encrypt Cupertino stream: key: *763a url: http://192.168.1.120:1935/vod/_definst_/mp4:sample.mp4/key{bitrate}{sessionid}.m3u8key

相关问题