如何在 VM 中针对 Cosmos DB 模拟器 运行 验证 Node.js MongoClient?
How to authenticate Node.js MongoClient against Cosmos DB emulator running in VM?
我在 OS X 上,我正在尝试使用基于 Node.js 的 MongoClient
连接到 Parallels VM 中的 CosmosDB 模拟器 运行 .我能够让它连接,但查询因身份验证错误而失败。
我先看了this document,但我不得不稍微修改一下让我的主机连接到虚拟机:
Microsoft.Azure.Cosmos.Emulator.exe /AllowNetworkAccess /EnableMongoDbEndpoint /Key=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==
我的连接字符串:
mongodb://vm1:C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==@vm1:10255/admin?ssl=true
在我能够让它连接后,我不知道如何使用 MongoClient
提供与 ServerCertificateCustomValidationCallback
等效的方法。
我收到的认证错误信息:
[8/31/19 12:40:54 AM] System.Private.CoreLib: Exception while executing function: Functions.datasets. System.Private.CoreLib: Result: Failure
[8/31/19 12:40:54 AM] Exception: MongoError: Authentication Failed. ConnectionId 1a87b001-e1e6-4918-9a1c-92db5719c670 ActivityId: 8c071a01-0000-0000-0000-000000000000
[8/31/19 12:40:54 AM] Stack: MongoError: Authentication Failed. ConnectionId 1a87b001-e1e6-4918-9a1c-92db5719c670 ActivityId: 8c071a01-0000-0000-0000-000000000000
[8/31/19 12:40:54 AM] at /Users/Documents/Projects/DataStore/node_modules/mongodb-core/lib/connection/pool.js:598:61
[8/31/19 12:40:54 AM] at authenticateStragglers (/Users/Documents/Projects/DataStore/node_modules/mongodb-core/lib/connection/pool.js:516:16)
[8/31/19 12:40:54 AM] at Connection.messageHandler (/Users/Documents/Projects/DataStore/node_modules/mongodb-core/lib/connection/pool.js:552:5)
[8/31/19 12:40:54 AM] at emitMessageHandler (/Users/Documents/Projects/DataStore/node_modules/mongodb-core/lib/connection/connection.js:309:10)
[8/31/19 12:40:54 AM] at TLSSocket.<anonymous> (/Users/Documents/Projects/DataStore/node_modules/mongodb-core/lib/connection/connection.js:452:17)
[8/31/19 12:40:54 AM] at TLSSocket.emit (events.js:182:13)
[8/31/19 12:40:54 AM] at addChunk (_stream_readable.js:283:12)
[8/31/19 12:40:54 AM] at readableAddChunk (_stream_readable.js:264:11)
[8/31/19 12:40:54 AM] at TLSSocket.Readable.push (_stream_readable.js:219:10)
[8/31/19 12:40:54 AM] at TLSWrap.onStreamRead (internal/stream_base_commons.js:94:17).
我用这个连接字符串得到了这个:
mongodb://localhost:C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==@vm1:10255/admin?ssl=true
请注意,localhost
仍用作用户名。 vm1
被指定为 @
之后的机器名。
我在 OS X 上,我正在尝试使用基于 Node.js 的 MongoClient
连接到 Parallels VM 中的 CosmosDB 模拟器 运行 .我能够让它连接,但查询因身份验证错误而失败。
我先看了this document,但我不得不稍微修改一下让我的主机连接到虚拟机:
Microsoft.Azure.Cosmos.Emulator.exe /AllowNetworkAccess /EnableMongoDbEndpoint /Key=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==
我的连接字符串:
mongodb://vm1:C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==@vm1:10255/admin?ssl=true
在我能够让它连接后,我不知道如何使用 MongoClient
提供与 ServerCertificateCustomValidationCallback
等效的方法。
我收到的认证错误信息:
[8/31/19 12:40:54 AM] System.Private.CoreLib: Exception while executing function: Functions.datasets. System.Private.CoreLib: Result: Failure
[8/31/19 12:40:54 AM] Exception: MongoError: Authentication Failed. ConnectionId 1a87b001-e1e6-4918-9a1c-92db5719c670 ActivityId: 8c071a01-0000-0000-0000-000000000000
[8/31/19 12:40:54 AM] Stack: MongoError: Authentication Failed. ConnectionId 1a87b001-e1e6-4918-9a1c-92db5719c670 ActivityId: 8c071a01-0000-0000-0000-000000000000
[8/31/19 12:40:54 AM] at /Users/Documents/Projects/DataStore/node_modules/mongodb-core/lib/connection/pool.js:598:61
[8/31/19 12:40:54 AM] at authenticateStragglers (/Users/Documents/Projects/DataStore/node_modules/mongodb-core/lib/connection/pool.js:516:16)
[8/31/19 12:40:54 AM] at Connection.messageHandler (/Users/Documents/Projects/DataStore/node_modules/mongodb-core/lib/connection/pool.js:552:5)
[8/31/19 12:40:54 AM] at emitMessageHandler (/Users/Documents/Projects/DataStore/node_modules/mongodb-core/lib/connection/connection.js:309:10)
[8/31/19 12:40:54 AM] at TLSSocket.<anonymous> (/Users/Documents/Projects/DataStore/node_modules/mongodb-core/lib/connection/connection.js:452:17)
[8/31/19 12:40:54 AM] at TLSSocket.emit (events.js:182:13)
[8/31/19 12:40:54 AM] at addChunk (_stream_readable.js:283:12)
[8/31/19 12:40:54 AM] at readableAddChunk (_stream_readable.js:264:11)
[8/31/19 12:40:54 AM] at TLSSocket.Readable.push (_stream_readable.js:219:10)
[8/31/19 12:40:54 AM] at TLSWrap.onStreamRead (internal/stream_base_commons.js:94:17).
我用这个连接字符串得到了这个:
mongodb://localhost:C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==@vm1:10255/admin?ssl=true
请注意,localhost
仍用作用户名。 vm1
被指定为 @
之后的机器名。