var channelCredentials = new SslCredentials(File.ReadAllText("server.pem"));
var option = new List<ChannelOption>
{
new ChannelOption(ChannelOptions.SslTargetNameOverride, "your-common-name")
};
channel = new Channel(address, channelCredentials, option);
using Grpc.Core;
...
var channelCredentials = new SslCredentials(File.ReadAllText("server.pem"));
var option = new List<ChannelOption>
{
new ChannelOption(ChannelOptions.SslTargetNameOverride, "your-common-name")
};
channel = new Channel(address, channelCredentials, option);
2条答案
按热度按时间t1rydlwq1#
2lpgd9682#
SnowCrumble意味着如果您使用this Nuget包创建gRpc-channel,则可以按以下方式设置'common-name':
这段代码覆盖了grpc.ssl_target_name_override通道参数。但是正如Jan Tattermusch在他的注解中所说的:请注意强制更改“common-name”,因为它应该是证书的一部分。