ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am writing a SSL Client program which is working fine if the request is lessthan or equal to 500 bytes to server.But whenever the request becomes more than 500 bytes my client receiving only 1 byte of response which is [H] and after that I/O error is occuring(SSL_ERROR_SYSCALL)
Post your code being as this client is your own.
Also read the definition of the functions & libraries you're calling, be sure you're not missing a documented behaviour/a check you should make in your read loop before assuming a variable's contents, or that you're not looping too much and only capturing the last read/buffer's worth of data.
SSL_read() tries to read num bytes from the specified ssl into the buffer buf.
...
SSL_read() works based on the SSL/TLS records. The data are received in records (with a maximum record size of 16kB for SSLv3/TLSv1). Only when a record has been completely received, it can be processed (decryption and check of integrity). Therefore data that was not retrieved at the last call of SSL_read() can still be buffered inside the SSL layer and will be retrieved on the next call to SSL_read(). If num is higher than the number of bytes buffered, SSL_read() will return with the bytes buffered. If no more bytes are in the buffer, SSL_read() will trigger the processing of the next record. Only when the record has been received and processed completely, SSL_read() will return reporting success. At most the contents of the record will be returned. As the size of an SSL/TLS record may exceed the maximum packet size of the underlying transport (e.g. TCP), it may be necessary to read several packets from the transport layer before the record is complete and SSL_read() can succeed.
SSL_ERROR_SYSCALL means that an underlying call to the system failed.
Check errno in that case.
If you're getting the error on larger pieces of data, instead of
smaller pieces of data, it sounds like you're not properly handling
the case where your read buffer isn't large enough, needs to be
extended, and the read continued. Without knowing the value of errno,
it's impossible to guess, though.
Quote:
SSL_ERROR_SYSCALL
Some I/O error occurred. The OpenSSL error queue may contain more information on the error. If the error queue is empty (i.e. ERR_get_error() returns 0), ret can be used to find out more about the error: If ret == 0, an EOF was observed that violates the protocol. If ret == -1, the underlying BIO reported an I/O error (for socket I/O on Unix systems, consult errno for details).
Is it just that the request is >500bytes, or that the source is different and possibly introducing an invalid EOF?
I'm not a C man, but BUFSIZZ is being defined where? Looks like it should be 65536 but there's a lot of occurances of this magic number instead.
Re-reading that documentation I originally linked, it looks like you could do more error value investigation in your code rather than your current print and goto.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.