This repository was archived by the owner on Apr 9, 2021. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -358,7 +358,8 @@ Client:
358358import grpc
359359import helloworld_pb2
360360
361- creds = grpc.ssl_channel_credentials(open (' roots.pem' ).read())
361+ with open (' roots.pem' , ' rb' ) as f:
362+ creds = grpc.ssl_channel_credentials(f.read())
362363channel = grpc.secure_channel(' myservice.example.com:443' , creds)
363364stub = helloworld_pb2.GreeterStub(channel)
364365```
@@ -368,10 +369,13 @@ Server:
368369``` python
369370import grpc
370371import helloworld_pb2
372+ from concurrent import futures
371373
372- server = grpc.server(futures.ThreadPoolExecutor(max_workers = 10 )
373- private_key = open (' key.pem' ).read()
374- certificate_chain = open (' chain.pem' ).read()
374+ server = grpc.server(futures.ThreadPoolExecutor(max_workers = 10 ))
375+ with open (' key.pem' , ' rb' ) as f:
376+ private_key = f.read()
377+ with open (' chain.pem' , ' rb' ) as f:
378+ certificate_chain = f.read()
375379server_credentials = grpc.ssl_server_credentials( ( (private_key, certificate_chain), ) )
376380# Adding GreeterServicer to server omitted
377381server.add_secure_port(' myservice.example.com:443' , server_credentials)
You can’t perform that action at this time.
0 commit comments