0

I have a system where client sends a gzip file to a server over regular socket connection. The server consumes the file without writing to disk. The server uses gzdopen and gzread to read from socket. I have a requirement to add TLS/SSL layer for secured communication. How to read gzip files at server end without writing SSL_read to temporary file or very huge chunk of memory ?

damleak
  • 549
  • 1
  • 5
  • 20
  • 1
    According to the [`zlib` manual](https://www.zlib.net/manual.html): *"...gzread can be used to read a gzip file that is being concurrently written. Upon reaching the end of the input, gzread will return with the available data. If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then gzclearerr can be used to clear the end of file indicator in order to permit gzread to be tried again. Z_OK indicates that a gzip stream was completed on the last gzread. Z_BUF_ERROR indicates that the input file ended in the middle of a gzip stream..."* – jww Jun 20 '17 at 21:20
  • Also, if your problem is having a memory buffer but needing a file number or file descriptor, then see [Difference between fmemopen and open_memstream](https://stackoverflow.com/q/29849749/608639). – jww Jun 20 '17 at 21:36
  • 1
    Yes, it's possible. – President James K. Polk Jun 20 '17 at 22:08
  • The easiest solution is to run the current server [behind an SSL/TLS proxy.](https://en.wikipedia.org/wiki/TLS_termination_proxy) Why do developers seem to think way too often that the best solution is to write more code, or even worse, to rewrite working code? [Every problem is not a nail...](https://en.wikipedia.org/wiki/Law_of_the_instrument) – Andrew Henle Jun 21 '17 at 10:59
  • @jww Thanks. I will try that out. – damleak Jun 21 '17 at 17:42

0 Answers0