Skip to content
This repository was archived by the owner on Apr 9, 2021. It is now read-only.

Commit 7e4f4e5

Browse files
Merge pull request #757 from ysangkok/patch-1
pass channel credentials as byte string
2 parents 4970499 + 74d1cfe commit 7e4f4e5

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

docs/guides/auth.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,8 @@ Client:
358358
import grpc
359359
import 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())
362363
channel = grpc.secure_channel('myservice.example.com:443', creds)
363364
stub = helloworld_pb2.GreeterStub(channel)
364365
```
@@ -368,10 +369,13 @@ Server:
368369
```python
369370
import grpc
370371
import 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()
375379
server_credentials = grpc.ssl_server_credentials( ( (private_key, certificate_chain), ) )
376380
# Adding GreeterServicer to server omitted
377381
server.add_secure_port('myservice.example.com:443', server_credentials)

0 commit comments

Comments
 (0)