I added the certificate and key to server and it starts now. I generated some certificates and keys using a script mentioned in one of the posts in this group. Now after using server.crt and server.key generated by that script the server is running. However, what certificate and key should be added to the client to communicate with the server? Here is my client program. I am using client.crt and client.key generated by that script.
std::ifstream tfile("client.crt");
std::stringstream cli_cert;
cli_cert << tfile.rdbuf();
tfile.close();
tfile.open("client.key");
std::stringstream cli_key;
cli_key << tfile.rdbuf();
tfile.close();
grpc::SslCredentialsOptions ssl_opts;
ssl_opts.pem_root_certs="";
ssl_opts.pem_private_key=cli_key.str();
ssl_opts.pem_cert_chain=cli_cert.str();
GreeterClient greeter(grpc::CreateChannel(
"localhost:50051", grpc::SslCredentials(ssl_opts)));
std::string user("world");
std::string reply = greeter.SayHello(user);
Here is the error that I get on client side when the client is executed.
E1116 09:26:59.622489462 17976 ssl_transport_security.c:199] ssl_info_callback: error occured.
E1116 09:26:59.622623322 17976 ssl_transport_security.c:945] Handshake failed with fatal error SSL_ERROR_SSL: error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED.
E1116 09:26:59.622641277 17976 handshake.c:128] Security handshake failed: {"created":"@1479317219.622630904","description":"Handshake failed","file":"src/core/lib/security/transport/handshake.c","file_line":264,"tsi_code":10,"tsi_error":"TSI_PROTOCOL_FAILURE"}
The error on server side is:
E1116 09:18:28.809683734 17911 server_secure_chttp2.c:123] Secure transport failed with error 1
E1116 09:26:59.606240723 17911 ssl_transport_security.c:1288] No match found for server name: 0.0.0.0.
E1116 09:26:59.622738415 17911 handshake.c:128] Security handshake failed: {"created":"@1479317219.622724267","description":"Handshake read failed","file":"src/core/lib/security/transport/handshake.c","file_line":237,"referenced_errors":[{"created":"@1479317219.622722928","description":"EOF","file":"src/core/lib/iomgr/tcp_posix.c","file_line":235}]}
E1116 09:26:59.622827154 17911 server_secure_chttp2.c:123] Secure transport failed with error 1
I am guessing something is wrong with the server name ?