vmagamedov / grpclib

Pure-Python gRPC implementation for asyncio
http://grpclib.readthedocs.io
BSD 3-Clause "New" or "Revised" License
936 stars 92 forks source link

Adding my learning on Secure connections #167

Open tmsrikanth opened 1 year ago

tmsrikanth commented 1 year ago

Its a knowledge share for member who had difficulty in creating secure channel with Client certificate. I had difficulty in creating sslcontext and passing it part of the Channel creation class. The error were more towards sslcontext creation .

Since grpclib provides support for certifi package .Internally while creating secure connection, grpclib looksup for certifi certificates repo and create default context. I updated my client certificate in the cacert.pem and it helped me to resolve my issue on secure channel creation

Picked up a small code to update the certificate details programatically. You can add wrappers for conditional update based on any condition.

cafile = certifi.where() with open(certi_path, 'rb') as infile: customca = infile.read() with open(cafile, 'ab') as outfile: outfile.write(customca)