从本地Windows计算机通过Gremlin.net连接到AWS Neptune

问题描述 投票:0回答:2

我正在access-graph-gremlin-dotnet关注Amazon的文档并尝试在通过EC2实例通过SSH隧道连接到Neptune的本地Windows计算机上运行它。我已经使用gremlin控制台测试了SSH隧道,并且工作正常。在EC2实例上运行程序也可以正常运行,但是在本地Windows计算机上运行程序时,由于出现Neptune的证书需要添加到受信任的证书中,因此出现以下异常:

System.Net.WebSockets.WebSocketException (0x80004005): Unable to connect to the remote server ---> 
System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner 
 exception. ---> System.Security.Authentication.AuthenticationException: The remote certificate is 
invalid according to the validation procedure.

我正在Gremlin.Net 3.4.6(最好是C#)中搜索操作方法。

gremlin amazon-neptune gremlinnet
2个回答
0
投票

您将需要执行此操作:

  1. 以管理员身份打开cmd.exe
  2. notepad c:\windows\system32\drivers\hosts
  3. 添加一行127.0.0.1 <your neptune cluster endpoint just the name without port>
  4. 保存文件
  5. 现在尝试再次运行.Net代码

这是因为您最有可能连接到localhost,并且该证书已为群集的主机名签名,所以不匹配。


0
投票

[另一个选择是对GremlinClient构造函数使用webSocketConfiguration参数,并使用RemoteCertificateValidationCallback进行手动检查。由于存在明显的安全风险,因此在进行证书验证时应格外小心。

var webSocketConfiguration = new Action<ClientWebSocketOptions>(options => {options.RemoteCertificateValidationCallback=(o, c, ch, er) => Test and return true if certificate is valid;});
var gremlinServer = new GremlinServer(endpoint, 8182, enableSsl: true );
var gremlinClient = new GremlinClient(gremlinServer, webSocketConfiguration: webSocketConfiguration);
© www.soinside.com 2019 - 2024. All rights reserved.