CoTURN: How to use TURN REST API?

前端 未结 6 779
不知归路
不知归路 2020-12-02 18:57

I have build coturn and run it successfully. ip:192.168.1.111. Now the question I faced is to get the Turn credential through REST API. http://tools.ietf.org/html/draft-ube

6条回答
  •  囚心锁ツ
    2020-12-02 19:17

    After (many) hours of frustration, @Mido's excellent answer here was the only thing that actually got CoTurn's REST API working for me.

    My credential server is PHP and I use CoTurn's config file 'turnserver.conf' so here's a tested and working translation of Mido's work for that situation:

    Assuming a 'shared secret' of '3575819665154b268af59efedee8826e', here are the relevant turnserver.conf entries:

    lt-cred-mech
    use-auth-secret
    static-auth-secret=3575819665154b268af59efedee8826e
    

    ...and the PHP (which misled me for ages):

    $ttl = 24 * 3600;  // Time to live
    $time = time() + $ttl;
    $username = $time . ':' . $user;
    $password = base64_encode(hash_hmac('sha1', $username, '3575819665154b268af59efedee8826e', true));
    

提交回复
热议问题