MongoDB 配置SSL

https://docs.mongodb.com/manual/core/security-transport-encryption/

关于MongoDB 的SSL 配置, 官方文档挺齐全的

win10 64位 安装 OpenSSL-Win64 的安装版, 添加环境变量path

由于文档提供的基本是Linux 的, 网上搜索到的也是Linux 这样的, 自己改成了 windows 的

G:
cd G:\ca

openssl req -newkey rsa:2048 -new -x509 -days 365 -nodes -out mongodb-cert.crt -keyout mongodb-cert.key

copy /b /y mongodb-cert.key+mongodb-cert.crt  mongodb.pem

这个是直接使用了CA根证书, 和由key+证书组成的CA服务器证书(mongodb 要求key+cert 合成的pem)

配置文件

net:
  port: 27000
  bindIp: 127.0.0.1
  ssl:
    mode: requireSSL
    PEMKeyFile: G:\ca\mongodb.pem
    CAFile: G:\ca\mongodb-cert.crt
    allowInvalidHostnames: true

如果有集群, 加上

security:
  authorization: enabled 
  clusterAuthMode: x509

启动MongoDB 后, 用mongo 客户端连接, 因为是自己建的证书, 所以--sslA

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值