Can you stream from a HTTPS server using HLS?

2019-05-30 22:36发布

I'm wondering wether or not it's possible to stream from a HTTPS server using HLS, using the following code -

let url = NSURL(string:"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8")
        let player = AVPlayer(URL: url!)
        let playerController = AVPlayerViewController()

        playerController.player = player
        self.addChildViewController(playerController)
        self.view.addSubview(playerController.view)
        playerController.view.frame = self.view.frame

        player.play()

I can stream from an HTTP server, but when I changed the URL to the URL of my company's server it doesn't work, the only difference is that the video of my company has HTTPS in it's URL and apple's sample video doesn't, I'm testing on the Emulator in XCode

1条回答
甜甜的少女心
2楼-- · 2019-05-30 23:23

Yes, you can stream HLS from an HTTPS server. HLS streams are transfered over HTTP and HTTPS is just HTTP over TLS and most of the time it is transparent to the client. The only thing you need is support for HTTPS in the player which all major ones already have.

https://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8 is not working because the devimages.apple.com certificate is invalid. Just browse the url using your browser. It will warn you and give you additional information about what exactly is wrong.

I guess the problem with your company server is the same - wrong or self-signed certificate.

Another quick way to validate an https server is to user curl. For example:

curl "https://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"

complains with:

curl: (51) SSL: no alternative certificate subject name matches target host name 'devimages.apple.com'
查看更多
登录 后发表回答