【问题标题】:Kamilio and JS SIP Websocket SecureKamailio 和 JSSIP Websocket 安全
【发布时间】:2018-02-05 18:02:36
【问题描述】:

我正在尝试在客户端使用 JSSIP 为 Kamailio 配置 WebSocket Secure (wss)。除了允许的端口和重定向之外,我还对 kamailio.cfg 和 tls.cfg 进行了设置。在我的浏览器控制台上,我看到:jssip-3.0.13.js:21334 WebSocket connection to 'wss://mydomain.com:4443/' failed: WebSocket opening handshake was canceled

但是,如果我使用 ws ('ws://mydomain.com:8080/') 就可以了。

有人知道如何解决这个问题吗?

我生成了证书,但问题仍然存在。我正在使用 nodeJS 作为服务器。

kamailio.cfg 文件:

/* 添加本地域别名 */

alias="mydomain.com"

listen=udp:private_ip:5060 广告 public_ip:5060

listen=tcp:private_ip:5060 广告 public_ip:5060

listen=tcp:private_ip:5061 广告 public_ip:5061

listen=MY_WS_ADDR 广告 public_ip:8080

listen=tls:private_ip:4443 广告 public_ip:5061

"#!ifdef WITH_TLS

listen=MY_WSS_ADDR 广告 public_ip:4443

"#!endif

tcp_connection_lifetime=3604

tcp_accept_no_cl=yes

tcp_rd_buf_size=16384

/* 监听端口(默认为 5060 用于 udp、tcp、scrtp,或 5061 用于 tls)*/

"#端口=5060

[...]

"#!define WITH_NAT"

"#!define WITH_MYSQL"

"#!define WITH_AUTH

"#!define WITH_USRLOCDB"

"#!define WITH_TLS"

"#!define WITH_DEBUG"

"#!substdef "!MY_IP_ADDR!my_private_ip!g"

"#!substdef "!MY_DOMAIN!my_public_ip!g"

"#!substdef "!MY_WS_PORT!8080!g"

"#!substdef "!MY_WSS_PORT!4443!g"

"#!substdef "!MY_WS_ADDR!tcp:MY_IP_ADDR:MY_WS_PORT!g"

"#!substdef "!MY_WSS_ADDR!tls:MY_IP_ADDR:MY_WSS_PORT!g"

额外信息 event_route[xhttp:request] 等于 Kamailio 5.0 文档:https://kamailio.org/docs/modules/5.0.x/modules/websocket.html [...]

tls.cfg 文件:

[...]

[服务器:默认]

方法 = TLSv1

verify_certificate = 否

require_certificate = 是

private_key = /etc/certs/mydomain.com/key.pem

证书 = /etc/certs/mydomain.com/cert.pem

[...]

[...]

[客户端:默认]

verify_certificate = 是

require_certificate = 是

[...]

Javascript:

var socket = new JsSIP.WebSocketInterface('wss://mydomain.com:4443');
    var configuration = {
      sockets  : [ socket ],
      uri      : 'sip:client@mydomain.com',
      password : '******',
    };

NodeJS:


    'use strict';

    var os = require('os');
    var path = require('path');
    const https = require('https');
    var url = require('url');
    const fs = require('fs');

    const options = {
        key:    fs.readFileSync('demoCA/key.pem'),
        passphrase: '*********',
        cert: fs.readFileSync('demoCA/cert.pem')
    };

    var app = https.createServer(options, function(req, resp) {
    var url_parts = url.parse(req.url);
    var path = url_parts.pathname;
    console.log(path)
    fs.readFile(__dirname + path, function(err, data) {
    if(err) {
        resp.writeHead(404, {'Content-Type': 'text/html'});
        resp.write('Not found');
    } else {
       resp.writeHead(200, {'Content-Type': 'text/html'});
       resp.write(data);
    }
    resp.end();
    });
});

   app.listen(443);

AWS

在听

udp: private_ip:5060 advertise public_ip:5060

tcp: private_ip:5060 advertise public_ip:5060

tcp: private_ip:5061 advertise public_ip:5061

tcp: private_ip:8080 advertise public_ip:8080

tls: private_ip:4443 advertise public_ip:4443

别名:

tls: ip-private_ip.us-west-2.compute.internal:4443

tcp: ip-private_ip.us-west-2.compute.internal:8080

tcp: ip-private_ip.us-west-2.compute.internal:5061

tcp: ip-private_ip.us-west-2.compute.internal:5060

udp: ip-private_ip.us-west-2.compute.internal:5060

如果您需要更多详细信息,请询问我,我将编辑我的问题。

【问题讨论】:

  • 通过 wss 使用的自签名证书现在不能直接在浏览器中使用。直接在浏览器中打开https://yourdomain.com:4443/ 会发生什么?
  • 证书没问题,我通过这个网站生成了它们:certbot.eff.org/#ubuntuxenial-nginx我解决了这个问题。我会发布我所做的。感谢您的帮助。

标签: javascript node.js amazon-web-services websocket kamailio


【解决方案1】:

我解决了我的问题。我缺少加载一些模块和路由器。

我以这个文件为例: https://gist.github.com/jesusprubio/4066845 但重要的是要知道 Kamailio 5.0 不支持每个模块都以“mi”开头。 您需要替换相对于 5.0 版的模块。

我使用此站点生成证书:certbot.eff.org/#ubuntuxenial-nginx

我希望它对某人有所帮助。

【讨论】:

    猜你喜欢
    • 2015-03-04
    • 1970-01-01
    • 2015-10-12
    • 2012-09-04
    • 2018-11-08
    • 1970-01-01
    • 1970-01-01
    • 2014-04-24
    • 2012-07-30
    相关资源
    最近更新 更多