I am working on supporting TLS, and it looks like everything that I need is
built into FlightServerBase.

However, I am struggling to understand how it works, or how to test that it
is working. For example, I don't understand why I can pass garbage in for
the tls_certs, and still get results when called from a client. Here is a
minimal example I put together to show where I am confused.

Server that I think should not work:
```python
from pyarrow import flight, Table

class SampleServer(flight.FlightServerBase):
    def __init__(self, *args, **kwargs):
        tls_certificates = [("garbage", "garbage")]
        location = flight.Location.for_grpc_tcp("localhost", 8081)
        super(SampleServer, self).__init__(location,
                                           None,
                                           tls_certificates,
                                           False,
                                           None,
                                           *args, **kwargs)

    def do_get(self, context, ticket):
        data = {'col': [1]}
        table = Table.from_pydict(data)
        return flight.RecordBatchStream(table)

if __name__ == "__main__":
    server = SampleServer()
    server.serve()
```

Client code that I think should not work:
```python
import pyarrow.flight as fl
import json
def main():
    server_location = "grpc://localhost:8081"

    client = fl.FlightClient(server_location)
    ticket = fl.Ticket(json.dumps({}))
    reader = client.do_get(ticket)
    print(reader.read_all().to_pandas())

if __name__ == "__main__":
    main()
```

But when I run the server, and then the client, I get a result:

```
% python3 client.py
   col
0    1
```

I would expect some kind of TLS error.

I am sure that I am confused about something, but if someone could help me
with my reasoning, I would appreciate it.

For reference, my project is here: https://github.com/rickspencer3/shoots

Reply via email to