带有TLS支持的grpc中的错误 [英] Error in grpc with TLS support

查看:107
本文介绍了带有TLS支持的grpc中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行安全的helloworld程序,以检查GRPC代码中对TLS的支持.我收到此错误

I am trying to run the secure helloworld program to check the support of TLS in the GRPC code. I get this error

E1228 23:15:44.054232298   10843 ssl_transport_security.cc:621] Invalid cert chain file.
E1228 23:15:44.054286682   10843 security_connector.cc:1108] Handshaker factory creation failed with TSI_INVALID_ARGUMENT.
E1228 23:15:44.054304555   10843 server_secure_chttp2.cc:83] {"created":"@1514520944.054294700","description":"Unable to create secure server with credentials of type Ssl.","file":"src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc","file_line":62,"security_status":1}
Server listening on localhost:50051
Segmentation fault (core dumped)

以下是我的服务器代码.

Following is my server code.

std::string server_address ( "localhost:50051" );

std::string key;
std::string cert;
std::string root;

read ( "server.crt", cert );
read ( "server.key", key );
read ( "ca.crt", root );

ServerBuilder builder;

grpc::SslServerCredentialsOptions::PemKeyCertPair keycert =
{
    key,
    cert
};

grpc::SslServerCredentialsOptions sslOps;
sslOps.pem_root_certs = root;
sslOps.pem_key_cert_pairs.push_back ( keycert );

builder.AddListeningPort(server_address, grpc::SslServerCredentials( sslOps ));

GreeterServiceImpl service;
builder.RegisterService(&service);

std::unique_ptr < Server > server ( builder.BuildAndStart () );
std::cout << "Server listening on " << server_address << std::endl;

server->Wait ();

我只是试图运行服务器.即使在图片中也没有CLient.这是我用来生成密钥的脚本.

I am just trying to run the server. CLient isnt even in the picture yet. Here is the script i used to generate the keys.

# Generate valid CA
openssl genrsa -passout pass:1234 -des3 -out ca.key 4096
openssl req -passin pass:1234 -new -x509 -days 365 -key ca.key -out ca.crt -subj  "/C=CA/ST=Ontario/L=Ontario/O=Test/OU=Test/CN=Root CA"

# Generate valid Server Key/Cert
openssl genrsa -passout pass:1234 -des3 -out server.key 4096
openssl req -passin pass:1234 -new -key server.key -out server.csr -subj "/C=CA/ST=Ontario/L=Ontario/O=Test/OU=Server/CN=localhost"
openssl x509 -req -passin pass:1234 -days 365 -in server.csr -CA ca.crt -
CAkey ca.key -set_serial 01 -out server.crt

# Remove passphrase from the Server Key
openssl rsa -passin pass:1234 -in server.key -out server.key

# Generate valid Client Key/Cert
openssl genrsa -passout pass:1234 -des3 -out client.key 4096
openssl req -passin pass:1234 -new -key client.key -out client.csr -subj  "/C=CA/ST=Ontario/L=Ontario/O=Test/OU=Client/CN=localhost"
openssl x509 -passin pass:1234 -req -days 365 -in client.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out client.crt

# Remove passphrase from Client Key
openssl rsa -passin pass:1234 -in client.key -out client.key

任何帮助将不胜感激.谢谢

Any help would be deeply appreciated. Thanks

推荐答案

该错误似乎类似于加载服务器x509证书时出错.您是否将服务器密钥/证书和CA证书放在服务器二进制文件的同一目录中?

The error looks like there was something wrong with loading server x509 certificate. Did you put your server key/certificate and CA certificate in the same directory of your server binary?

我使用您的脚本来生成密钥和证书. 我使用来自> https://github.com/grpc/grpc/issues的欢迎客户端/服务器代码/9593 一切正常.我无法复制您的错误.

I use your script to generate keys and certificates. I use the greeter client/server code from https://github.com/grpc/grpc/issues/9593 Everything works fine. I could not duplicate your error.

这篇关于带有TLS支持的grpc中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆