serve
serve copied to clipboard
Add support for secure communication over gRPC
Is your feature request related to a problem? Please describe.
The current implementation of gRPC doesn't support communication over a secure channel.
Describe the solution
Add support for starting gRPC secure mode.
Can you elaborate on how you implemented the secure communication support? I can't get a torchserver to work using secure grpc communication with self signed certificates for localhost @harshbafna
Yes, @msaroufim @harshbafna could you please provide steps for performing grpc secure communication for both client and server?
I have created a private key (.key) and certificate file (mycert.pem) on the server side. Copied the certificate on the client side and using the following code on the client side
with open("mycert.pem", 'rb') as f:
creds= grpc.ssl_channel_credentials(f.read())
options = [
('grpc.max_send_message_length', MAX_GRPC_MESSAGE_LENGTH),
('grpc.max_receive_message_length', MAX_GRPC_MESSAGE_LENGTH)
]
infer_channel = grpc.secure_channel(f"{host}:{port}", credentials=creds, options=options)
However, this doesn't seem to work. I get the error:
E0607 10:27:01.030167311 10127 ssl_transport_security.cc:1495] Handshake failed with fatal error SSL_ERROR_SSL: error:100000f7:SSL routines:OPENSSL_internal:WRONG_VERSION_NUMBER.
E0607 10:27:05.954440654 10228 ssl_transport_security.cc:1495] Handshake failed with fatal error SSL_ERROR_SSL: error:100000f7:SSL routines:OPENSSL_internal:WRONG_VERSION_NUMBER.
or
<_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "failed to connect to all addresses"
debug_error_string = "{"created":"@1654597621.030306810","description":"Failed to pick subchannel","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":3217,"referenced_errors":[{"created":"@1654597621.030306017","description":"failed to connect to all addresses","file":"src/core/lib/transport/error_utils.cc","file_line":165,"grpc_status":14}]}"
I also set the enable_grpc_ssl=true in config.properties. The WRONG_VERSION_NUMBER error is not generated anymore. However, the status is still Unavailable.
Any updates on this? i ran into the same problem
Any updates on this? i ran into the same problem
Yes, I wrote about how I got this working. Let me know if this works you or if you run into any issues.
https://iammohitm.github.io/Torch-Serve-with-Secure-gRPC/
Thank you very much. This made it work! :)