我試圖用WebSocket安全(wss)配置Kamailio在客戶端使用JSSIP。我對kamailio.cfg和tls.cfg進行了設置,除了允許的端口和重定向之外。在我的瀏覽器控制檯上,我看到:jssip-3.0.13.js:21334 WebSocket connection to 'wss://mydomain.com:4443/' failed: WebSocket opening handshake was canceled
Kamilio和JS SIP Websocket安全
但是,如果我使用ws('ws://mydomain.com:8080/'
)它的工作原理。
有人知道如何解決這個問題嗎?
我生成了證書,但問題仍然存在。我使用nodeJS作爲服務器。
kamailio.cfg文件:
/*添加本地域別名*/
別名爲 「mydomain.com」
聽= UDP:private_ip:5060做廣告public_ip:5060
listen = tcp:private_ip:5060 advertise public_ip:5060
listen = tcp:private_ip:5061 advert ISE public_ip:5061
聽= MY_WS_ADDR做廣告public_ip:8080
聽= TLS:private_ip:4443做廣告public_ip:5061
」的#ifdef WITH_TLS
聽= MY_WSS_ADDR做廣告public_ip:4443
「#!ENDIF
tcp_connection_lifetime = 3604
tcp_accept_no_cl =是
tcp_rd_buf_size = 16384
/*端口聽(默認5060 UDP,TCP,scrtp,或5061 TLS)*/
「#端口= 5060
[...]
「#!限定WITH_NAT」
「#!定義WITH_MYSQL」
「#!定義WITH_AUTH
」#!定義WITH_USRLOCDB「
」#!定義WITH_TLS「
」#!定義WITH_DEBUG「
」 #!substdef「!MY_IP_ADDR !my_private_ip!G 「
」 #!substdef 「!MY_DOMAIN!my_public_ip!G」
「#!substdef」!MY_WS_PORT!8080!! 「!!!MY_WSS_PORT4443克!」 「#substdef! 」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:請求]等於Kamailio 5.0文檔:https://kamailio.org/docs/modules/5.0.x/modules/websocket.html [...]
tls.cfg文件:
[...]
[服務器:默認]
方法=使用TLSv1
verify_certificate =沒有
require_certificate = YES
private_key = /etc/certs/mydomain.com/key.pem
證書= /etc/certs/mydomain.com/cert.pem
[...]
[...]
[客戶端:默認]
verify_certificate = YES
require_certificate =是
[...]
的Javascript:
var socket = new JsSIP.WebSocketInterface('wss://mydomain.com:4443');
var configuration = {
sockets : [ socket ],
uri : 'sip:[email protected]',
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 /'會發生什麼? –
證書是好的,我通過這個網站生成他們:https://certbot.eff.org/#ubuntuxenial-nginx 我解決了這個問題。我會發布我所做的。 感謝您的幫助。 –