diff options
author | Santosh Ananthakrishnan <santosh@dropbox.com> | 2018-03-27 16:10:02 -0700 |
---|---|---|
committer | Santosh Ananthakrishnan <santosh@dropbox.com> | 2018-06-07 22:20:31 +0000 |
commit | fd4c5dd031e548af3672021d9e7e0d079e1f55d2 (patch) | |
tree | ddcf7fc6af8154b4a06d8ed194b95eef8d5843a4 /src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi | |
parent | b441dbbc2c534f88bb671b4ca1564e4ef65c3e36 (diff) |
TLS session resumption support for Python clients
This change adds an experimental ssl_session_cache_lru function to the
Python API that returns an encapsulated grpc_ssl_session_cache (#14483).
Python clients may use this object as an argument for the
grpc.ssl_session_cache channel option if they wish to cache and resume
TLS sessions with a server.
Diffstat (limited to 'src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi')
-rw-r--r-- | src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi index dff9097bf9..f4ccfbc016 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi @@ -17,6 +17,9 @@ cimport cpython import grpc import threading +from libc.stdint cimport uintptr_t + + def _spawn_callback_in_thread(cb_func, args): threading.Thread(target=cb_func, args=args).start() @@ -29,6 +32,7 @@ def set_async_callback_func(callback_func): def _spawn_callback_async(callback, args): async_callback_func(callback, args) + cdef class CallCredentials: cdef grpc_call_credentials *c(self): @@ -107,6 +111,21 @@ cdef class ChannelCredentials: raise NotImplementedError() +cdef class SSLSessionCacheLRU: + + def __cinit__(self, capacity): + grpc_init() + self._cache = grpc_ssl_session_cache_create_lru(capacity) + + def __int__(self): + return <uintptr_t>self._cache + + def __dealloc__(self): + if self._cache != NULL: + grpc_ssl_session_cache_destroy(self._cache) + grpc_shutdown() + + cdef class SSLChannelCredentials(ChannelCredentials): def __cinit__(self, pem_root_certificates, private_key, certificate_chain): |