gpt4 book ai didi

autobahn - 无法使用 TLS 连接到 Crossbar 路由器

转载 作者:行者123 更新时间:2023-12-02 21:54:49 25 4
gpt4 key购买 nike

我在这里运行了这个例子:https://github.com/crossbario/crossbarexamples/tree/master/wss/python ,一切正常。

但是,以下情况对我不起作用:

config.json 文件:

{
"controller": {},
"workers": [
{
"type": "router",
"realms": [
{
"name": "realm1",
"roles": [
{
"name": "anonymous",
"permissions": [
{
"uri": "*",
"publish": true,
"subscribe": true,
"call": true,
"register": true
}
]
}
]
}
],
"transports": [
{
"type": "web",
"endpoint": {
"type": "tcp",
"port": 9000,
"tls": {
"key": "server_key.pem",
"certificate": "server_cert.pem",
"dhparam": "dhparam.pem",
"ciphers": "ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AES:RSA+3DES:!ADH:!AECDH:!MD5:!DSS"
}
},
"paths": {
"/": {
"type": "static",
"directory": "../web"
},
"ws": {
"type": "websocket"
}
}
}
]
}
]
}

web/index.html 文件只是为了查看 TLS 是否有效:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Router</title>
</head>
<body>
This is a router.
</body>
</html>

我生成了证书,如果我连接到 https://127.0.0.1:9000 网站,一切正常。页面加载正确。

但是,我在 node.js 中设置了另一个项目来尝试注册某些内容..(代码取自页面加载计数示例)

server.js中的代码:

var connection = new autobahn.Connection({
url: 'wss://127.0.0.1:9000/ws',
realm: 'realm1'}
);

connection.onopen = function (session) {
console.log("connected to WAMP router");
app.session = session;

// REGISTER a procedure for remote calling
//
function get_visits () {
return app.visits;
}
session.register('com.example.get_visits', get_visits).then(
function (reg) {
console.log("procedure get_visits() registered");
},
function (err) {
console.log("failed to register procedure: " + err);
}
);
};

connection.onclose = function (reason, details) {
console.log("WAMP connection closed", reason, details);
app.session = null;
}

connection.open();

现在,wss://127.0.0.1:9000/ws 是路由器的正确 URL,但我总是收到以下内容:

WAMP connection closed unreachable { reason: null,
message: null,
retry_delay: 1.8090544409276008,
retry_count: 1,
will_retry: true }

无法连接到服务器。

我确信我没有掌握一些基本概念,也许你可以引导我走向正确的方向。

最佳答案

如果您使用自签名证书,则需要告诉浏览器信任它,否则连接将在 TLS 层失败。

我最近在“crossbarexamples”存储库中添加了客户端证书支持和完整的示例:https://github.com/crossbario/crossbarexamples/tree/master/authenticate/client_tls

在上面链接的示例中,您可以将中间 CA 证书导入到您的浏览器(或自签名根 CA 证书)。

关于autobahn - 无法使用 TLS 连接到 Crossbar 路由器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33938251/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com