官术网_书友最值得收藏!

Encrypting communication using TLS/SSL

Communication between the mongod or mongos server and the client mongo shell or applications should be encrypted. This is supported in most MongoDB distributions from 3.0 and onwards but we need to take care that we download the proper version with SSL support.

After that, we need to get a signed certificate from a trusted certificate authority or sign our own. Using self-signed certificates is fine for pre-production systems but in production it will mean that mongo servers won't be able to verify our identity, leaving us susceptible to man-in-the-middle attacks; thus using a proper certificate is highly recommended.

To start our MongoDB server with SSL we need the following:

$ mongod --sslMode requireSSL --sslPEMKeyFile <pem> --sslCAFile <ca>

Where <pem> is our .pem signed certificate file and <ca> is the .pem root certificate from the certificate authority that contains the root certificate chain.

These options can also be defined in our configuration file mongod.conf or mongos.conf in a YAML file format:

net:
ssl:
mode: requireSSL
PEMKeyFile: /etc/ssl/mongodb.pem
CAFile: /etc/ssl/ca.pem
disabledProtocols: TLS1_0,TLS1_1,TLS1_2

Here, we specified a PEMKeyFile, a CAFile, and also that we won't allow the server to start with certificates that follow the TLS1_0, TLS1_1 or TLS1_2 versions. These are the available versions for disabledProtocols at this time.

主站蜘蛛池模板: 安福县| 博客| 庄河市| 昂仁县| 和林格尔县| 冕宁县| 石阡县| 宜宾县| 寻甸| 任丘市| 于田县| 衡阳县| 阳西县| 庆元县| 芜湖市| 揭东县| 保德县| 休宁县| 江达县| 广水市| 靖江市| 永宁县| 远安县| 灌云县| 五家渠市| 安新县| 芜湖县| 津市市| 个旧市| 合肥市| 许昌市| 且末县| 碌曲县| 南靖县| 南溪县| 大方县| 南丹县| 沙河市| 土默特左旗| 黎川县| 衡阳市|