Cryptography: Expose `SSL_write_ex`

Created on 2 Nov 2020  路  5Comments  路  Source: pyca/cryptography

Hello, I see that SSL_write is exposed but SSL_write_ex isn't.

I think it's useful to have it for the purposes of solving https://github.com/pyca/pyopenssl/issues/176.
(That is if I'm reading the docs right)

All 5 comments

We can expose this, but it's 1.1.1+ only. cryptography supports 1.1.0 so it'll need to be a conditional binding.

@reaperhulk thanks for the info! Any idea if sendall() can be implemented w/o it? I'm a little bit confused about whether there are any other ways to detect bytes that's actually been sent over the wire...

@tiran may know the answer to this -- I don't know OpenSSL's TLS APIs well enough.

I think I've found what I was looking for, it _should be_ possible with SSL_MODE_ENABLE_PARTIAL_WRITE set: https://github.com/pyca/pyopenssl/issues/176#issuecomment-723674922.

Python's ssl module uses SSL_write. The function uses negative values to report errors and positive values how many bytes were written successfully. Then it's a matter of slicind and dicing the send buffer and loop until all data was written. Python doesn't use SSL_MODE_ENABLE_PARTIAL_WRITE.

Was this page helpful?
0 / 5 - 0 ratings