当使用libnice创建GTlsClientConnection时,“TLS支持不可用”

问题描述:

我有工作代码,其中两个对等体通过中继服务器(coturn)进行连接,并且似乎一切都好于伪TCP。我已经用nice_agent_attach_recv()nice_agent_get_io_stream()成功测试了消息交换。当使用libnice创建GTlsClientConnection时,“TLS支持不可用”

但是当我尝试创建一个GTlsClientConnection我回去:0:TLS support is not available

下面是一些部分代码:

if(!nice_agent_set_relay_info(agent, stream_id, 
     NICE_COMPONENT_TYPE_RTP, 
     "my.coturn.server", 
     5349, //tls-listener-port (I also tried the non tls port: 3478) 
     username.c_str(), 
     password.c_str(), 
     NICE_RELAY_TYPE_TURN_TCP)) 
    { 
     printf("error setting up relay info\n"); 
    } 

    ... 

    //after state has changed to NICE_COMPONENT_STATE_READY 

    ... 

    io_stream = nice_agent_get_io_stream (agent, stream_id, component_id); 
    input = g_io_stream_get_input_stream (G_IO_STREAM (io_stream)); 
    output = g_io_stream_get_output_stream (G_IO_STREAM (io_stream)); 

    GIOStream* tlsConnection = g_tls_client_connection_new 
           (G_IO_STREAM (io_stream), NULL, &error); 

    ///////////////////////// 
    /// error == 0 (TLS support is not available) 

我是新来libnice和油腔滑调。所以,我可能会错过一些基本的东西。

可能需要安装glib-networking软件包。

+0

有趣。那么,它仍然会编译和链接,但是无法创建TLS支持?我会试一试。 – mateuscb

+0

Gio中的Tls类只依赖通用接口,但不包含任何实现。 glib-networking提供了一个依赖于外部TLS库的实现。 – TingPing

+0

做到了。现在我只需要获得所有的证书和流。但让我过去了我的初学者问题。谢谢! – mateuscb