Freeswitch与带SSL的webRTC(本地)

时间:2019-01-03 10:15:18

标签: webrtc freeswitch

我将freeswitch用作sip服务器,也使用freeswitch文件夹(/ usr / local / freeswitch / certs)中的pem。

在客户端部分,我使用SIP.js客户端看起来像:

<script src="https://rawgit.com/onsip/SIP.js/0.8.0/dist/sip-0.8.0.js"></script>
<!--script src="sip-0.12.0.js"></script-->
<video id="remoteVideo"></video>
<video id="localVideo" muted="muted"></video>
<script>
    var userAgent = new SIP.UA({
      uri: '1002@192.168.0.100',
      wsServers: ['wss://192.168.0.100:7443'],
      authorizationUser: '1002',
      password: '1234',
    });

    userAgent.on("connected", function() {
        console.log("Connected $$$$$$$$$$$$$$$$$$$$$$$$");
    });

    userAgent.on('invite', function (session) {
        session.accept({
            media: {
                render: {
                    remote: {
                        video: document.getElementById('remoteVideo')
                    },
                    local: {
                        video: document.getElementById('localVideo')
                    }
                }
            }
        });
    });
</script>

浏览器错误登录(Chrome):

sip-0.8.0.js:11540 WebSocket connection to 'wss://192.168.0.100:7443/' failed: Error in connection establishment: net::ERR_CERT_AUTHORITY_INVALID
connect @ sip-0.8.0.js:11540
Transport @ sip-0.8.0.js:11428
(anonymous) @ sip-0.8.0.js:7798
sip-0.8.0.js:746 Thu Jan 03 2019 11:10:42 GMT+0100 (Central European Standard Time) | sip.transport | WebSocket connection error: 
LoggerFactory.print @ sip-0.8.0.js:746
LoggerFactory.(anonymous function) @ sip-0.8.0.js:763
Logger.(anonymous function) @ sip-0.8.0.js:757
onError @ sip-0.8.0.js:11725
ws.onerror @ sip-0.8.0.js:11565
error (async)
connect @ sip-0.8.0.js:11564
Transport @ sip-0.8.0.js:11428
(anonymous) @ sip-0.8.0.js:7798
setTimeout (async)
Timers.(anonymous function) @ sip-0.8.0.js:1446
UA.recoverTransport @ sip-0.8.0.js:7795
UA.onTransportError @ sip-0.8.0.js:7452
onClose @ sip-0.8.0.js:11633
ws.onclose @ sip-0.8.0.js:11552
sip-0.8.0.js:746 Event {isTrusted: true, type: "error", target: WebSocket, currentTarget: WebSocket, eventPhase: 2, …}
LoggerFactory.print @ sip-0.8.0.js:746
LoggerFactory.(anonymous function) @ sip-0.8.0.js:763
Logger.(anonymous function) @ sip-0.8.0.js:757
onError @ sip-0.8.0.js:11726
ws.onerror @ sip-0.8.0.js:11565
error (async)
connect @ sip-0.8.0.js:11564
Transport @ sip-0.8.0.js:11428
(anonymous) @ sip-0.8.0.js:7798
setTimeout (async)
Timers.(anonymous function) @ sip-0.8.0.js:1446
UA.recoverTransport @ sip-0.8.0.js:7795
UA.onTransportError @ sip-0.8.0.js:7452
onClose @ sip-0.8.0.js:11633
ws.onclose @ sip-0.8.0.js:11552
sip-0.8.0.js:746 Thu Jan 03 2019 11:10:42 GMT+0100 (Central European Standard Time) | sip.transport | WebSocket disconnected (code: 1006)
sip-0.8.0.js:746 Thu Jan 03 2019 11:10:42 GMT+0100 (Central European Standard Time) | sip.transport | WebSocket abrupt disconnection
LoggerFactory.print @ sip-0.8.0.js:746
LoggerFactory.(anonymous function) @ sip-0.8.0.js:763
Logger.(anonymous function) @ sip-0.8.0.js:757
onClose @ sip-0.8.0.js:11614
ws.onclose @ sip-0.8.0.js:11552
sip-0.8.0.js:746 Thu Jan 03 2019 11:10:42 GMT+0100 (Central European Standard Time) | sip.ua | transport wss://192.168.0.100:7443 failed | connection state set to 2
sip-0.8.0.js:746 Thu Jan 03 2019 11:10:42 GMT+0100 (Central European Standard Time) | sip.ua | time for next connection attempt exceeds connectionRecoveryMaxInterval, resetting counter
sip-0.8.0.js:746 Thu Jan 03 2019 11:10:42 GMT+0100 (Central European Standard Time) | sip.ua | next connection attempt in 2 seconds
sip-0.8.0.js:746 Thu Jan 03 2019 11:10:44 GMT+0100 (Central European Standard Time) | sip.transport | connecting to WebSocket wss://192.168.0.100:7443

登录在localhost env中运行的freeswitch服务器:

tport.c:2753 tport_wakeup_pri() tport_wakeup_pri(0x7f8780e28b20): events IN
tport.c:862 tport_alloc_secondary() tport_alloc_secondary(0x7f8780e28b20): new secondary tport 0x7f878193c200
tport.c:2294 tport_set_secondary_timer() tport(0x7f878193c200): set timer at 4998 ms because keepalive
tport.c:2644 tport_accept() tport_accept(0x7f878193c200): new connection from wss/192.168.0.100:56317/sips
tport.c:2777 tport_wakeup() tport_wakeup(0x7f878193c200): events IN
tport.c:2868 tport_recv_event() tport_recv_event(0x7f878193c200)
tport_type_ws.c:232 tport_recv_stream_ws() tport_recv_stream_ws(0x7f878193c200): su_getmsgsize(): Host is down (64) N=-1
tport.c:2159 tport_shutdown0() tport_shutdown0(0x7f878193c200, 2)
tport.c:2092 tport_close() tport_close(0x7f878193c200): wss/192.168.0.100:56317/sips
tport.c:2265 tport_set_secondary_timer() tport(0x7f878193c200): set timer at 0 ms because zap
tport_type_ws.c:531 tport_ws_deinit_secondary() 0x7f878193c200 destroy wss transport 0x7f878193c3f0.

1 个答案:

答案 0 :(得分:1)

错误清楚地表明这是证书问题

  

sip-0.8.0.js:11540 WebSocket连接到'wss://192.168.0.100:7443 /'失败:>连接建立错误: net :: ERR_CERT_AUTHORITY_INVALID

     

我将freeswitch用作sip服务器,也使用freeswitch文件夹中的pem   (/ usr / local / freeswitch / certs)

Freeswitch提供的证书是自签名证书,不会为您的服务器地址192.168.0.100生成。 您可以尝试使用openssl生成一个,

  

openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout 192.168.0.100.key -out 192.168.0.100.crt -extensions san -config <(echo“ [req]”;回显distinguished_name = req; echo“ [san]”; echo subjectAltName = DNS:192.168.0.100,IP:192.168.0.100)-subj /CN=192.168.0.100

使您的wss.pem使用 https://freeswitch.org/confluence/display/FREESWITCH/WebRTC#WebRTC-InstallCertificates

如果您收到证书颁发机构错误,请在Chrome之类的浏览器上使用针对webrtc的自签名证书,最好使用域名生成有效的SSL证书并使用它。

致谢!