GithubHelp home page GithubHelp logo

Comments (11)

imzyxwvu avatar imzyxwvu commented on July 17, 2024

I argee. And when ssl:read() returns want_read, the loop should end.

from lua-openssl.

zhaozg avatar zhaozg commented on July 17, 2024

according to https://github.com/zhaozg/lua-openssl/blob/master/src/ssl.c#L1417-L1418,
ssl:read([number bytes=ssl:pending()]), will always try to read all pending data if not given bytes to read,
so I think your options are done already.

from lua-openssl.

imzyxwvu avatar imzyxwvu commented on July 17, 2024

I called ssl:read() in my program (without any argument), it didn't read all pending data in the memory bio. Then if I call ssl:read() again, more data will be readed, without any new data pushed to the memory bio.

from lua-openssl.

zhaozg avatar zhaozg commented on July 17, 2024

OK, I'll check it, maybe bugs.

from lua-openssl.

zhaozg avatar zhaozg commented on July 17, 2024

@imzyxwvu 可能是在读完之后新产生的数据吧,即使实在ssl:read()中加上读取的参数也会出现这种现象

from lua-openssl.

imzyxwvu avatar imzyxwvu commented on July 17, 2024

@zhaozg 不,我自己写的uv绑定,参考那个lib重新实现。我向input mem bio里面写了数据之后有的时候只从ssl对象上read一次只读出了一部分数据,不够,但是接收数据回调没被再次调用。但是如果我在没有往mem bio写入新数据的情况下再调用一次read就能读出剩下的数据。我再翻翻openssl文档。我晚上试试写个程序重现下。

translation: I wrote a libuv binding myself (not luv), so I referenced that lua lib to implement one for my own binding. When I wrote some data to the input mem bio, ssl:read() succeeded but didn't return all data expected, but the on-data callback wasn't trigged any more. So I tried to call ssl:read() again and it returned the left data. I will try to write a program to show you the problem tonight.

from lua-openssl.

zhaozg avatar zhaozg commented on July 17, 2024

我最近太忙了,可能没有办法及时解决这个问题,我尽快处理这个问题吧。

I'm busy now, can't solve this problem in a timely, please wait some days to deal with this issue. thanks.

from lua-openssl.

imzyxwvu avatar imzyxwvu commented on July 17, 2024

@zhaozg 我看了下 openssl document,你的C代码没错。ssl底层数据流是由许多records组成的,SSL_pending返回当前正在处理的那一个record中还未读取的字节数,如果一次性写入input bio多个ssl record,那么openssl会依次处理,SSL_pending每次只返回当前正处理的record中剩余的字节数,只有你用SSL_read把当前record读完了,openssl才处理下一个record(如果bio中下一个record还不完整,SSL_pending返回0),这也就是要循环read的原因。

translation: in a word, there is nothing wrong in the C code.

from lua-openssl.

imzyxwvu avatar imzyxwvu commented on July 17, 2024

remember openssl document said that SSL_read may also yields WANT_WRITE.

from lua-openssl.

zhaozg avatar zhaozg commented on July 17, 2024

@imzyxwvu thanks

from lua-openssl.

zhaozg avatar zhaozg commented on July 17, 2024

https://github.com/zhaozg/lua-openssl/blob/master/ldoc/ssl.lua#L218

from lua-openssl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.