我正在使用DocumentDB迁移工具将一些json从本地开发机器移动到本地网络上另一台机器上运行的远程DocumentDB模拟器。当我运行DT.exe迁移时,它会抛出以下错误:
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure. at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult)
从这个错误中,我知道这是一个证书问题,但我不知道如何解决它。我正在端口=443上使用/AllowNetworkAccess运行模拟器,并使用默认的emulator密钥(https://myservername)。然后,我在DT.exe中使用以下ConnectionString:
AccountEndpoint=https://myservername/;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==;Database=MyDBName
以前有人试过这样做吗?
我也遇到过这个错误,我已经能够通过以下方式修复它。我只想写下我所做的一切。我不确定创建证书是否是解决此问题的一部分。
生成证书
首先,我转到Azure Cosmos DB EmulatorC:Program FilesAzure Cosmos DB Emulator
的根文件夹,并在此处打开CMD。然后我运行命令Microsoft.Azure.Cosmos.Emulator.exe /GenCert=127.0.0.1,localhost
。
删除Cosmos DB Emulator
创建证书后,我删除了Emulator。首先,在系统托盘中停止Emulator。之后,转到Control Panel -> Uninstall a program
。单击Azure Cosmos DB Emulator
,然后单击Uninstall
。按照提示操作,应卸载Cosmos DB。
手动删除剩余文件
一些文件可能仍然保留。最好手动删除这些。转到文件资源管理器中的C:Program Files
并删除Azure Cosmos DB Emulator
文件夹。如果它说它正在使用中,可能是因为您仍然打开了命令提示符。关上这个,你就可以走了。
其他一些文件可能仍在%LOCALAPPDATA%
中。在该文件夹中删除CosmosDBEmulator
文件夹。
安装Cosmos DB
删除所有文件后,我再次安装了Cosmos DB,它神奇地工作了。
我仍然不知道这是否真的是一个好的解决方案,但它为我解决了这个问题。所以我希望它能在未来帮助其他人。