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

How it works...

In step 1, we created a self-signed certificate to get us started with SSL enabled connections. One could very well use a certificate signed by a valid Certificate Authority (CA), but for test purposes we are good with a self-signed certificate. In all honesty, if connection security is all you need, a self-signed certificate can also be used in a production environment as long as you keep the keys secure. You might as well take it a step forward by creating your own CA certificate and use it to sign your certificates.

In step 2, we concatenate the key and the certificate file. Next, in step 3, we start the mongod daemon with --sslMode requireSSL followed by providing the path to the concatenated .pem file. At this point, we have a standalone MongoDB server listening to the default port 27017, ready to accept only SSL based clients.

Next, we attempt to connect to the mongod server using the default non-SSL mode, which is immediately rejected by the sever. Finally, in step 5 we explicitly make an SSL connection by providing the --ssl parameter followed by --sslAllowInvalidCertificates. The latter parameter is used because we are using a self-signed certificate on the server. If we were using an certificate signed by a authorized CA or even a self-signed CA, we could very well use the --sslCAFile to provide the CA certificate.

主站蜘蛛池模板: 宝坻区| 吉木萨尔县| 荔浦县| 正安县| 井冈山市| 晋江市| 平湖市| 红原县| 栖霞市| 陵水| 恩施市| 新竹县| 上饶市| 陇川县| 朝阳县| 大渡口区| 石楼县| 象州县| 东辽县| 米脂县| 宜城市| 盐池县| 房产| 杭锦旗| 衢州市| 抚州市| 花莲县| 东山县| 拉萨市| 蓝山县| 若羌县| 五台县| 海盐县| 上高县| 浮梁县| 延寿县| 常山县| 林口县| 射阳县| 濮阳市| 江永县|