Mongo shell无法连接到Azure CosmosDB

时间:2017-11-23 08:16:31

标签: mongodb macos azure openssl azure-cosmosdb

我无法从Mac下的MongoDB Shell连接到Azure CosmosDB(mongodb api):

mongo --host XXX.documents.azure.com --port 10255 --username XXX --password YYY --ssl

返回以下错误

MongoDB shell version v3.4.10
connecting to: mongodb://XXX.documents.azure.com:10255/
2017-11-23T20:56:57.762+1300 E QUERY    [thread1] Error: socket exception [CLOSED] for 104.210.89.99:10255 :
connect@src/mongo/shell/mongo.js:237:13
@(connect):1:6
exception: connect failed

sw_vers:

ProductName:    Mac OS X
ProductVersion: 10.12.4
BuildVersion:   16E195

mongo --version

MongoDB shell version v3.4.10
git version: 078f28920cb24de0dd479b5ea6c66c644f6326e9
OpenSSL version: OpenSSL 0.9.8zh 14 Jan 2016
allocator: system
modules: none
build environment:
    distarch: x86_64
    target_arch: x86_64

哪个mongo

/usr/local/var/mongodb/bin/mongo

otool -L / usr / local / var / mongodb / bin / mongo

/usr/local/var/mongodb/bin/mongo:
    /usr/lib/libssl.0.9.8.dylib (compatibility version 0.9.8, current version 0.9.8)
    /usr/lib/libcrypto.0.9.8.dylib (compatibility version 0.9.8, current version 0.9.8)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.60.2)
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1349.8.0)
    /System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 57740.60.18)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.5.0)

我的理论是Azure CosmosDB强制执行OpenSSL 0.9.8不支持的SSL / TLS 1.2 但是,最新版本的MongoDB仍然附带OpenSSL 0.9.8所以有一个问题:如何让MondoDB Shell与Azure CosmosDB一起工作,因为我并不急于在本地构建MongoDB?有没有办法使用更新的OpenSSL库强制MongoDB Shell?

1 个答案:

答案 0 :(得分:0)

卸载/安装brew并通过brew重新安装mongodb后,我得到了以下MongoDB版本:

mongo --version

MongoDB shell version v3.4.10
git version: 078f28920cb24de0dd479b5ea6c66c644f6326e9
OpenSSL version: OpenSSL 1.0.2m  2 Nov 2017
allocator: system
modules: none
build environment:
    distarch: x86_64
    target_arch: x86_64

连接到CosmosDB就好了。