通过AWS ELB的MongooseIM SSL连接

use*_*890 3 erlang ssl amazon-web-services mongoose-im aws-elb

我在AWS的EC2实例中配置了docker-compose的MongooseIM服务器。

我打算通过以下方式通过端口5222(mongooseim的ejabberd_c2s模块)上的ELB(AWS)通过SSL访问某些移动客户端:

     SSL (Secure TCP) -> 5222 -> TCP -> 5222  (EC2 Instance Port)
Run Code Online (Sandbox Code Playgroud)

在ejabberd_c2s模块配置中,我具有以下内容:

    { 5222, ejabberd_c2s, [

                %%
                %% If TLS is compiled in and you installed a SSL
                %% certificate, specify the full path to the
                %% file and uncomment this line:
                %%
                {certfile, "priv/ssl/fake_server.pem"}, starttls,

                %%{zlib, 10000},
                %% https://www.openssl.org/docs/apps/ciphers.html#CIPHER_STRINGS
                %% {ciphers, "DEFAULT:!EXPORT:!LOW:!SSLv2"},
                {access, c2s},
                {shaper, c2s_shaper},
                {max_stanza_size, 65536},
                {protocol_options, ["no_sslv3"]}

               ]},
Run Code Online (Sandbox Code Playgroud)

但是客户无法连接,我在服务器上收到的唯一消息是:

    mongooseim_server_dev | 10:58:25.885 [info] (#Port<0.27608>) Accepted connection {{10,0,17,246},42571} -> {{172,18,0,2},5222}
    mongooseim_server_dev | 10:58:25.885 [debug] Received XML on stream = "???yw?\??.ndEt?;?????fn?A>? n:?=5??</A
     "ngooseim_server_dev | ??kj98????g@32ED?(#
    mongooseim_server_dev | 10:58:25.885 [debug] Send XML on stream = <<"<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='2B421BCD2D077161' from='localhost' version='1.0'>">>
    mongooseim_server_dev | 10:58:25.886 [debug] Send XML on stream = <<"<stream:error><xml-not-well-formed xmlns='urn:ietf:params:xml:ns:xmpp-streams'/></stream:error>">>
    mongooseim_server_dev | 10:58:25.886 [debug] Send XML on stream = <<"</stream:stream>">>
Run Code Online (Sandbox Code Playgroud)

Mongoose文档没有为我提供任何解决方案,并且看不到有此错误的任何人。

任何帮助或线索?

ers*_*zcz 5

从您的描述和MongooseIM日志片段中,我认为客户端从一开始就开始加密连接-这就是为什么“接收的XML”似乎是垃圾。

在XMPP中,使用STARTTLS将最初的纯文本连接升级为安全连接。这对于带有TCP转发且没有TLS终止的ELB来说应该可以正常工作,您只需要确保客户端不会一开始就尝试使用SSL / TLS,而是使用STARTTLS。所有流行的XMPP库都应具有此选项,它是核心XMPP的一部分。


[...]一旦打开连接,是否更容易将ELB TCP放入TCP并通过TLS加密?

究竟。

我主要使用ELB来避免不得不自己处理SSL,如果无法获取SSL,将Mongoose服务器直接暴露于Internet会更好吗?

ELB不能用于纯XMPP的SSL终止。可用的选项有:

  1. ELB转发纯TCP,使用MongooseIM纯XMPP侦听器-客户端打开TCP连接,但通过STARTTLS升级它,所有EC2实例都需要证书配置。

  2. 为HTTPS终止设置了ELB,MongooseIM使用了BOSH侦听器-BOSH是HTTP上的XMPP,因此具有一些开销,但是SSL / TLS卸载的好处可能是值得的,对EC2实例上的证书不会感到头痛。