<#3715 [BUG] Providing admin.caCertFilePath result...
# flytekit
a
#3715 [BUG] Providing admin.caCertFilePath results in 'expected certificate to be bytes, got OpenSSL.crypto.X509' Issue created by LukasBommes Describe the bug When providing a CA root certificate in the flyte config via admin.caCertFilePath, I get the error
Copy code
Traceback (most recent call last):
  File "debug_remote.py", line 45, in <module>
    flyte_workflow_execution = remote.fetch_execution(project=project, domain=domain, name=execution)
  File "/opt/micromamba/envs/OHLI/lib/python3.8/site-packages/flytekit/remote/remote.py", line 362, in fetch_execution
    self.client.get_execution(
  File "/opt/micromamba/envs/OHLI/lib/python3.8/site-packages/flytekit/remote/remote.py", line 192, in client
    self._client = SynchronousFlyteClient(self.config.platform, **self._kwargs)
  File "/opt/micromamba/envs/OHLI/lib/python3.8/site-packages/flytekit/clients/raw.py", line 44, in __init__
    self._channel = wrap_exceptions_channel(cfg, upgrade_channel_to_authenticated(cfg, get_channel(cfg)))
  File "/opt/micromamba/envs/OHLI/lib/python3.8/site-packages/flytekit/clients/auth_helper.py", line 165, in get_channel
    credentials = grpc.ssl_channel_credentials(load_cert(cfg.ca_cert_file_path))
  File "/opt/micromamba/envs/OHLI/lib/python3.8/site-packages/grpc/__init__.py", line 1611, in ssl_channel_credentials
    _cygrpc.SSLChannelCredentials(root_certificates, private_key,
  File "src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi", line 143, in grpc._cython.cygrpc.SSLChannelCredentials.__cinit__
TypeError: expected certificate to be bytes, got <class 'OpenSSL.crypto.X509'>
The issue is in flytekit.clients.auth_helper where we have
Copy code
credentials = grpc.ssl_channel_credentials(load_cert(cfg.ca_cert_file_path))
The problem ist that
load_cert
returns an OpenSSL.crypto.X509 object, but
grpc.ssl_channel_credentials
expects a bytes string. So, we need to modify the call as follows (to encode the X509 object as bytes):
Copy code
credentials = grpc.ssl_channel_credentials(crypto.dump_certificate(crypto.FILETYPE_PEM, load_cert(cfg.ca_cert_file_path)))
Alternatively, we could modify
load_cert
to return bytes. Expected behavior Providing a CA root certificate in the flyte config via admin.caCertFilePath should not result in any errors. Additional context to reproduce No response Screenshots No response Are you sure this issue hasn't been raised already? ☑︎ Yes Have you read the Code of Conduct? ☑︎ Yes flyteorg/flyte