Freeswitch与带SSL的webRTC(本地)比较

1 人关注

我使用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环境下的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.
    
webrtc
freeswitch
Nikola Lukic
Nikola Lukic
发布于 2019-01-03
1 个回答
Sadeesh Radhakrishnan
Sadeesh Radhakrishnan
发布于 2020-06-20
已采纳
0 人赞同

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

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]"; echo distinguished_name=req; echo "[san]"; echo subjectAltName=DNS:192.168.0.100,IP:192.168.0.100)-subj /CN=192.168.0.100