如何使用安全通道实现Tensorflow服务

时间:2018-04-02 17:53:24

标签: python-2.7 tensorflow grpc tensorflow-serving

我目前创建了一个张量流服务模型,用于预测给定图像是猫还是狗。在我的tensorflow服务客户端脚本中,我使用了不安全的通道进行通信,

host, port = hostport.split(':')
channel = implementations.insecure_channel(host, int(port))

我想使用安全通道(SSL / TLS)进行通信。我查看了他们使用的网站https://github.com/tensorflow/serving/issues/193

host, port = FLAGS.server.split(':')
creds = grpc.ssl_channel_credentials(open('roots.pem').read())

在这里,我无法理解什么是roots.pem以及如何为我的tensorflow服务模型创建一个。请告诉我如何使用SSL / TSL(安全通道)实现tensorflow服务

没有将参数传递给ssl_channel_credentials()函数时出错,creds = grpc.ssl_channel_credentials()

E0403 13:59:04.799573344   23914 ssl_transport_security.cc:989] Handshake 
failed with fatal error SSL_ERROR_SSL: error:100000f7:SSL 
routines:OPENSSL_internal:WRONG_VERSION_NUMBER.
E0403 13:59:04.800359343   23922 ssl_transport_security.cc:989] Handshake 
failed with fatal error SSL_ERROR_SSL: error:100000f7:SSL 
routines:OPENSSL_internal:WRONG_VERSION_NUMBER.
Traceback (most recent call last):
File "Client.py", line 85, in <module>
tf.app.run()
File "/opt/anaconda2/lib/python2.7/site- 
packages/tensorflow/python/platform/app.py", line 124, in run
_sys.exit(main(argv))
File "Client.py", line 76, in main
result = stub.Predict(request, 60.0)
File "/opt/anaconda2/lib/python2.7/site- 
packages/grpc/beta/_client_adaptations.py", line 309, in __call__
self._request_serializer, self._response_deserializer)
File "/opt/anaconda2/lib/python2.7/site- 
packages/grpc/beta/_client_adaptations.py", line 195, in 
_blocking_unary_unary
raise _abortion_error(rpc_error_call)
grpc.framework.interfaces.face.face.AbortionError: 
AbortionError(code=StatusCode.UNAVAILABLE, details="Connect Failed")

0 个答案:

没有答案