mongo atlas 与 ssl 的连接有选择地不起作用

问题描述

我在 Azure 中有一个 windows vm 和一个 mongo atlas 集群。 windows vm公网IP在mongo集群白名单

在 mongoDB Compass 中使用以下连接字符串并设置 ssl=true 我可以从 windows 机器连接到 mongo 集群

mongodb+srv://user:password@abc.mongodb.net/test?authSource=admin&readPreference=primary&appname=MongoDB%20Compass&ssl=true

在我的 Windows 机器上,

  • openjdk 11.0.11 2021-04-20 LTS
  • Maven 3.8.1

windows vm 运行一个用 maven 构建的 serenity 套件,但由于 ssl 握手失败

WARN: Establishing SSL connection without server's identity verification is not recommended. According to MysqL 5.5.45+,5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false,or set useSSL=true and provide truststore for server certificate verification.

在 mongo 方面,日志给出

Error receiving request from client: SSLHandshakeFailed: The server is configured to only allow SSL connections. Ending connection from IP:Port (connection id: 12345)

Mongo atlas 使用 ISRG Root X1 证书。 如果我在 C:\Program Files\RedHat\java-11-openjdk-11.0.11-1\lib\security\cacerts 的 windows 机器上列出 java 的密钥库,我会得到一个 ISRG 条目

*******************************************
*******************************************


Alias name: isrgrootx1
Creation date: Jun 26,2020
Entry type: trustedCertEntry

Owner: CN=ISRG Root X1,O=Internet Security Research Group,C=US
Issuer: CN=ISRG Root X1,C=US

所以这不是缺少证书的问题。为什么 maven 不从认信任存储中获取证书?

我尝试在 mvn 命令中设置路径没有任何效果

mvn clean verify -Dtags="Suite1" -Djavax.net.ssl.keyStore=path/to/cacerts

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)