Skip to content

Improve behavior ssl_credentials #120

@ZeusFSX

Description

@ZeusFSX

Is your feature request related to a problem? Please describe.
When I use ssl=True but without pass credentials it rise the error:

from grpc_requests import Client
client = Client.get_by_endpoint("some-domain:443", ssl=True)

I get the error:

File /.venv/lib/python3.12/site-packages/grpc_requests/client.py:104, in BaseClient.__init__(self, endpoint, symbol_db, descriptor_pool, channel_options, ssl, compression, credentials, interceptors, **kwargs)
     96     if credentials:
     97         _credentials = {
     98             k: load_data(v) if isinstance(v, str) else v
     99             for k, v in credentials.items()
    100         }
    102     self._channel = grpc.secure_channel(
    103         endpoint,
--> 104         grpc.ssl_channel_credentials(**_credentials),  # type: ignore
    105         options=self.channel_options,
    106         compression=self.compression,
    107     )
    108 else:
    109     self._channel = grpc.insecure_channel(
    110         endpoint, options=self.channel_options, compression=self.compression
    111     )

TypeError: grpc.ssl_channel_credentials() argument after ** must be a mapping, not NoneType

But when I added CredentialsInfo everything works fine:

client = Client.get_by_endpoint("some-domain:443", ssl=True, credentials=CredentialsInfo(root_certificates=None, private_key=None, certificate_chain=None))

Describe the solution you'd like
When set ssl=True but credentials=None set the default value for credentials=CredentialsInfo(root_certificates=None, private_key=None, certificate_chain=None)

Describe alternatives you've considered
Or simple, improve docs how to works with ssl

Additional context
By the way thank you for your lib, it's better than work with stubs

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions