- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试使用 SSL/TLS 实现 gRPC,我阅读了有关如何实现 SSL/TLS 的文档,但这不起作用,我找到了一个 stackoverflow 页面 TLS support for GRPC in C#关于如何实现 TLS 支持,但这同样不起作用。
我正在使用 C#,但我有一个 Java 实现,我尝试将 C# 服务与 Java 客户端连接并且可以工作,但是当我尝试将 C# 客户端与 C# 服务器连接时,它不起作用,即使我尝试将 C# 客户端与 Java 服务器连接,但没有成功。
我使用的是 greet protos 和 Visual studio 2015
根据文档,此代码必须有效
首先我尝试将其用于客户端:
SslCredentials secureChanel = new SslCredentials(File.ReadAllText("ssl/ca.crt"));
Channel channel = new Channel("localhost", 50051, secureChanel);
然后我为此更改了代码:
var rootCert = File.ReadAllText("ssl/ca.crt");
var keyCertPair = new KeyCertificatePair(
File.ReadAllText("ssl/server.crt"),
File.ReadAllText("ssl/server.pem"));
var clientCredentials = new SslCredentials(rootCert, keyCertPair);
var options = new List<ChannelOption>
{
new ChannelOption(ChannelOptions.SslTargetNameOverride, "DESKTOP-3HLH093")
};
Channel channel = new Channel("localhost", 50051, clientCredentials, options);
有人有想法或可以帮助我知道哪里出了问题吗?或者我需要做什么才能知道如何解决?
可能是一个例子
这是我的客户端代码:
using System;
using Grpc.Core;
using System.IO;
using Greet;
using System.Collections.Generic;
namespace Nuxiba.Sever.Test.pruebaGrpcClient
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Test Server with gRPC");
var rootCert = File.ReadAllText("ssl/ca.crt");
var keyCertPair = new KeyCertificatePair(
File.ReadAllText("ssl/server.crt"),
File.ReadAllText("ssl/server.pem"));
var clientCredentials = new SslCredentials(rootCert, keyCertPair);
var options = new List<ChannelOption>
{
new ChannelOption(ChannelOptions.SslTargetNameOverride, "DESKTOP-3HLH093")
};
Channel channel = new Channel("localhost", 50051, clientCredentials, options);
greet_test(channel);
channel.ShutdownAsync().Wait();
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
public static void greet_test(Channel channel)
{
var greetCliente = new GreetService.GreetServiceClient(channel);
Greeting greeting = new Greeting();
greeting.FirstName = "John";
greeting.LastName = "XXXX";
Console.WriteLine(greeting);
GreetRequest callIR = new GreetRequest();
callIR.Greeting= greeting;
GreetResponse callResponse = greetCliente.Greet(callIR); //, new CallOptions().WithWaitForReady(true));
Console.WriteLine("respuesta: " + callResponse.Result);
}
}
}
这是我的服务器代码:
using System;
using Grpc.Core;
using System.IO;
using System.Collections.Generic;
using Greet;
namespace Nuxiba.Sever.Test.pruebaGrpcServer
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Test Server with gRPC");
//ssl
List<KeyCertificatePair> certificados = new List<KeyCertificatePair>();
certificados.Add(new KeyCertificatePair(File.ReadAllText("ssl/server.crt"), File.ReadAllText("ssl/server.pem")));
ServerCredentials servCred = new SslServerCredentials(certificados);
Server server = new Server
{
//Services = { TarificadorService.BindService(new TarificadorServiceImpl()) },
Services = { GreetService.BindService(new GreetServicesImpl()) },
Ports = { new ServerPort("localhost", 50051, servCred) }
};
server.Start();
Console.WriteLine("Greeter server listening on port: 50051 ");
Console.WriteLine("Press any key to stop the server...");
Console.ReadKey();
server.ShutdownAsync().Wait();
}
}
}
这是我的实现代码:
using System.Threading.Tasks;
using Grpc.Core;
namespace Nuxiba.Sever.Test.pruebaGrpcServer
{
class TarificadorServiceImpl : TarificadorService.TarificadorServiceBase
{
public override Task<CallInfoResponse> CallInfo(CallInfoRequest request, ServerCallContext context)
{
CallingInfo ci = request.CallingInfo;
uint Cal_id = ci.Callid;
CallInfoResponse response = new CallInfoResponse();
response.RegsAmount = Cal_id;
return Task.FromResult(response);
//return Task.FromResult(new CallInfoResponse { RegsAmount = Cal_id });
}
}
}
应用程序的错误是“连接拒绝”
这是完整的日志:
D0924 14:26:24.375269 Grpc.Core.Internal.UnmanagedLibrary Attempting to load native library "X:\desarrollos\pruebaGrpc\pruebaGrpcClient\bin\Debug\grpc_csharp_ext.x86.dll"
D0924 14:26:24.554956 Grpc.Core.Internal.NativeExtension gRPC native library loaded successfully.
D0924 14:26:24.634740 0 T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\ext\filters\client_channel\resolver\dns\native\dns_resolver.cc:348: Using native dns resolver
{ "firstName": "Armando", "lastName": "Rodriguez" }
I0924 14:26:25.100637 0 T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\lib\surface\call.cc:642: OP[client-channel:05DBD400]: SEND_INITIAL_METADATA{key=3a 70 61 74 68 ':path' value=2f 67 72 65 65 74 2e 47 72 65 65 74 53 65 72 76 69 63 65 2f 47 72 65 65 74 '/greet.GreetService/Greet'} SEND_MESSAGE:flags=0x00000000:len=22 SEND_TRAILING_METADATA{} RECV_INITIAL_METADATA RECV_MESSAGE RECV_TRAILING_METADATA
D0924 14:26:25.101644 0 T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\ext\filters\client_channel\resolver\dns\native\dns_resolver.cc:289: Start resolving.
E0924 14:26:25.340996 0 T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\tsi\ssl_transport_security.cc:1229: Handshake failed with fatal error SSL_ERROR_SSL: error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED.
D0924 14:26:25.340996 0 T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\lib\security\transport\security_handshaker.cc:129: Security handshake failed: {"created":"@1537817185.341000000","description":"Handshake failed","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\lib\security\transport\security_handshaker.cc","file_line":248,"tsi_code":10,"tsi_error":"TSI_PROTOCOL_FAILURE"}
I0924 14:26:25.342000 0 T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\ext\filters\client_channel\subchannel.cc:668: Connect failed: {"created":"@1537817185.341000000","description":"Handshake failed","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\lib\security\transport\security_handshaker.cc","file_line":248,"tsi_code":10,"tsi_error":"TSI_PROTOCOL_FAILURE"}
E0924 14:26:25.407816 0 T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\tsi\ssl_transport_security.cc:1229: Handshake failed with fatal error SSL_ERROR_SSL: error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED.
D0924 14:26:25.407816 0 T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\lib\security\transport\security_handshaker.cc:129: Security handshake failed: {"created":"@1537817185.408000000","description":"Handshake failed","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\lib\security\transport\security_handshaker.cc","file_line":248,"tsi_code":10,"tsi_error":"TSI_PROTOCOL_FAILURE"}
I0924 14:26:25.408815 0 T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\ext\filters\client_channel\subchannel.cc:668: Connect failed: {"created":"@1537817185.408000000","description":"Handshake failed","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\lib\security\transport\security_handshaker.cc","file_line":248,"tsi_code":10,"tsi_error":"TSI_PROTOCOL_FAILURE"}
I0924 14:26:25.408815 0 T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\ext\filters\client_channel\subchannel.cc:492: Subchannel 013E3B50: Retry in 767 milliseconds
D0924 14:26:25.409810 0 T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\ext\filters\client_channel\resolver\dns\native\dns_resolver.cc:265: In cooldown from last resolution (from 307 ms ago). Will resolve again in 693 ms
D0924 14:26:25.409810 0 T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\ext\filters\client_channel\resolver\dns\native\dns_resolver.cc:289: Start resolving.
I0924 14:26:25.423798 0 T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\lib\surface\call.cc:642: OP[client-channel:05DBD400]: CANCEL:{"created":"@1537817185.424000000","description":"Failed to create subchannel","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\ext\filters\client_channel\client_channel.cc","file_line":2636,"referenced_errors":[{"created":"@1537817185.410000000","description":"Pick Cancelled","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\ext\filters\client_channel\lb_policy\pick_first\pick_first.cc","file_line":241,"referenced_errors":[{"created":"@1537817185.408000000","description":"Connect Failed","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\ext\filters\client_channel\subchannel.cc","file_line":663,"grpc_status":14,"referenced_errors":[{"created":"@1537817185.408000000","description":"Handshake failed","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\lib\security\transport\security_handshaker.cc","file_line":248,"tsi_code":10,"tsi_error":"TSI_PROTOCOL_FAILURE"}]}]}]}
I0924 14:26:25.426771 0 T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\lib\surface\call.cc:642: OP[client-channel:05DBD400]: CANCEL:{"created":"@1537817185.424000000","description":"Failed to create subchannel","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\ext\filters\client_channel\client_channel.cc","file_line":2636,"referenced_errors":[{"created":"@1537817185.410000000","description":"Pick Cancelled","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\ext\filters\client_channel\lb_policy\pick_first\pick_first.cc","file_line":241,"referenced_errors":[{"created":"@1537817185.408000000","description":"Connect Failed","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\ext\filters\client_channel\subchannel.cc","file_line":663,"grpc_status":14,"referenced_errors":[{"created":"@1537817185.408000000","description":"Handshake failed","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\lib\security\transport\security_handshaker.cc","file_line":248,"tsi_code":10,"tsi_error":"TSI_PROTOCOL_FAILURE"}]}]}]}
I0924 14:26:28.737748 98788968 T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\ext\filters\client_channel\subchannel.cc:452: Failed to connect to channel, retrying
E0924 14:26:29.479174 0 T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\tsi\ssl_transport_security.cc:1229: Handshake failed with fatal error SSL_ERROR_SSL: error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED.
D0924 14:26:29.480172 0 T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\lib\security\transport\security_handshaker.cc:129: Security handshake failed: {"created":"@1537817189.480000000","description":"Handshake failed","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\lib\security\transport\security_handshaker.cc","file_line":248,"tsi_code":10,"tsi_error":"TSI_PROTOCOL_FAILURE"}
I0924 14:26:29.481170 0 T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\ext\filters\client_channel\subchannel.cc:668: Connect failed: {"created":"@1537817189.480000000","description":"Handshake failed","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\lib\security\transport\security_handshaker.cc","file_line":248,"tsi_code":10,"tsi_error":"TSI_PROTOCOL_FAILURE"}
I0924 14:26:29.482166 0 T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\ext\filters\client_channel\subchannel.cc:490: Subchannel 05DC3678: Retry immediately
I0924 14:26:29.482166 0 T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\ext\filters\client_channel\subchannel.cc:452: Failed to connect to channel, retrying
最佳答案
我找到了一个解决方案,根据注册表,问题是当客户端尝试验证证书时,我发现了这个关于类似问题的链接,它让我知道了如何解决我的问题https://groups.google.com/forum/#!topic/grpc-io/pJnoc_MHkfc
最后是客户端代码:
SslCredentials secureChanel = new SslCredentials(File.ReadAllText("ssl/server.crt"));
Channel channel = new Channel("localhost", 50051, secureChanel);
这是服务器代码:
List<KeyCertificatePair> certificados = new List<KeyCertificatePair>();
certificados.Add(new KeyCertificatePair(File.ReadAllText("ssl/server.crt"), File.ReadAllText("ssl/server.pem")));
ServerCredentials servCred = new SslServerCredentials(certificados);
//ServerCredentials servCred = new SslServerCredentials(certificados, File.ReadAllText("ssl/ca.crt"),true);
Server server = new Server
{
//Services = { TarificadorService.BindService(new TarificadorServiceImpl()) },
Services = { GreetService.BindService(new GreetServicesImpl()) },
Ports = { new ServerPort("localhost", 50051, servCred) }
};
关于c# - c# 中 grpc 的 SSL/TSL 支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52433029/
我想在汇编中使用“TSL”指令,但它没有引用理解。在某些文章中,此指令是针对互斥问题引入的,但没有引用或完整示例可以完全理解。 最佳答案 TSL(Test and Set Lock)是一般在处理互斥问
我按照 W3C 的规范实现了 HTTP 协议(protocol)在 java 。但是我无法处理 https 连接。 最佳答案 就 HTTP 协议(protocol)而言,HTTPs 没有什么特别之处。
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a software
我正在尝试使用一个公共(public) REST 端点,它在 http 中作为 SSL https://jsonplaceholder.typicode.com/posts/1 可用,它返回一个非常简
下面发布的代码非常适合我使用 SSL 通过 STMP 发送电子邮件。现在 SMTP 更改为 TSL,我无法用它发送电子邮件。我尝试了几件事,比如添加 props.put("mail.smtp.star
我正在处理一个 T-SQL 查询(我正在运行一个 SQL Server 数据库),该查询应该根据值列表计算中位数。查询如下所示: SELECT PERCENTILE_CONT(0.5) OVER
我工作的公司有一个旧的 VB6 应用程序,他们想强制使用 TSL,而不是 SSL。我查看了代码,并告诉他们应该没问题。该代码使用 HTTPS 向客户端网站发布消息。它没有指定要使用的加密方式。 这是相
我正在尝试使用 ServiceStack.Redis 使用 SSL 证书连接到基于云的 Redis 实例。 ServiceStack 文档提供了有关如何使用 SSL 连接到基于 Azure 的 Red
我尝试使用 SSL/TLS 实现 gRPC,我阅读了有关如何实现 SSL/TLS 的文档,但这不起作用,我找到了一个 stackoverflow 页面 TLS support for GRPC in
我在 AWS EC2 上安装了一个服务器,它监听多个端口,包括 ssh=22、http=80 和其他一些非 Web 端口。对于 http=80,我通过使用 route53 domain->Applic
等待 OS X El Capitan(以便我可以获得 TSL 1.2)我启用了我的 MAMP 服务器以使用 SSL/TSL。我的 iOS 应用程序使用如下所示的 URL,如果在浏览器中键入这些 URL
我想在 Delphi XE5 中使用 Indy 的 TIdHTTP 通过 HTTPS 读取 HTML 页面。 ssleay32.dll 和 libeay32.dll 在主程序文件夹中。 我收到一个错误
我有连接到 SSL SOAP 服务的应用程序。对于 iOS 9.3.5,应用程序运行良好。在 iOS 10 中,我有错误代码 -9801。我想这是连接到 Apple ATS 的。站点证书配置为 TLS
https://en.wikipedia.org/wiki/Transport_Layer_Security#Protocol_details 我正在研究 SSL/TSL 握手的工作原理,虽然我了解了
我在开发服务器 (IIS) 上有一个 WCF 服务。该服务启用了自签名 SSL 和用户名身份验证。 我已经设置了一个测试 ASP MVC 项目,它可以像这样从服务中成功调用数据: Ca
我正在运行: Amazon Linux AMI 2018.03.0 Linux ip-xxx-yy-z-ww 4.14.77-70.59.amzn1.x86_64 #1 SMP Mon Nov 12
我们的一个支付团队提到我们在制定安全措施时将 TLs 1.0 版本升级到 TLS 1.2。如果我们没有更新,我们将在我们的网站上面临付款问题。请让我们知道这是如何从 Cpanel/WHM 服务器完成的
当我尝试将 Java 8 应用程序连接到 Web 服务时,出现 SSLHandshakeException。 www.ssllabs.com说我 Web 服务不支持 TLSv1.1 和 TSLv1.2
这是抓取和上传图像的代码块。上载发生了,我得到了状态200,但是这确实会导致失败,并且CATCH块被运行。错误输出:。正如您所看到的,状态代码是200,我认为这意味着我可以打印结果(这只是为了测试,通
我是一名优秀的程序员,十分优秀!