A number of extra features/changes for ASIO - #2
Conversation
|
Hi Nick, Thanks for taking the time to work on these patches. I have a few comments.
These look good. However I do wonder whether std::string equivalents should be added for all of the existing *_file() functions. What do you think?
I think these functions should be templated to take a ConstBufferSequence rather than a single const_buffer. This data can then be buffer_copy()-ed in to the stream's core's input buffer space, and the input_ set to point to that.
The intention is that asio::error::eof be used to indicate closure of the SSL session, and a new error code shouldn't be needed. However I did fix a bug recently in that area. Can you please check whether that covers your use case? Please see: 93bf0f4 Cheers, |
|
On Wed, Dec 14, 2011 at 4:56 PM, chriskohlhoff <
I recall the reason why there is no interface for CA loading from an asn1
Instead of keeping the asio::ssl::detail::stream_core::input_ member, we
I felt that the caller would need a distinct indication that only the SSL I guess that upon receiving asio::error::eof in an SSL session, the author Given that the only place where asio::error::eof is set as the error code On a kind of related note: Thanks |
Thanks. I guess if there's no easy equivalent for some of them there's no point trying too hard.
Can you expand on what problems you had with linearisation? In any case support for multiple buffers is essential IMHO, as in my experience things like circular buffers are commonplace.
The current mapping should provide this. The asio::error::eof is only for clean termination of the SSL session. Eof from the underlying socket is remapped to another error, hence map_error_code().
It may also be set by the underlying stream. E.g. the read_some() operation. It is then mapped to another error.
Thanks of the tip. I will change this. |
|
On Wed, Dec 14, 2011 at 8:32 PM, chriskohlhoff <
There are still a number of functions that can be converted, I'm sure, but I'll keep these specific functions in my tree until I can map as many more
But I fully agree, supporting a buffer sequence is the way to go.
I'll work further on the non _file function conversions and send another |
Hunterize v1.12.2-8d6df7b
Reduce Asio API surface for better platform support
I want to contribute a number of changes to ASIO that I have made for use in our products at Network Box.
The changes come under three categories. Each of the categories does require some work,
so they couldn't be included in ASIO straight away without further discussion and refinement.
The changes are:
e08db1f05d5e19b5e10d87235247e46b593300c4
Interfaces to load CAs, Certificates and Private Keys stored in the form of std::string.
Useful for cases where these objects have been loaded from a database.
Additional interfaces therefore no ABI breakage.
90% complete, as the interface for loading CAs in ASN1 format hasn't been defined.
Loading Certs and PKs supports both PEM and ASN1 which is consistent with other
ASIO interfaces available.
56ec4891d4e9ee530d990adeca3c263b7a58778b
09db9f10f606b86e39869547f48cd9c157ed944a
Our planned use for this is cases where data is read from a socket, then subsequently identified as being
a SSL handshake header. Caller may then re-use the already read data in a handshake.
New function overload for async_handshake, so should be no ABI breakage.
This change is theory only at this stage, so is more of a request for comments. It works by using the
user provided buffer object as the initial value of the SSL layer input_ buffer, so the read routines find
this data before they try reading from the wire. As stated, not tested fully, and as I am writing this pull
request, I realise there is no corresponding non-async interface. I will submit that soon.
d966bf238727f10fa9853b3959913becb8b1696c
Provide a distinct error value for ssl shutdown in the form of a new error_code: ssl_eof. On receipt of
this, the user can then initiate a shutdown in their own chosen method: async or non-async.
I seem to recall that in the current logic, the code path leads to an implicit call to SSL_shutdown,
which is out of control of the user.
This change is not backwards compatible and a brand new error_code value is being returned, so
using this interface will require proper support in code, as only exists in my company software.
But seeing as there is a problem with the logic in regard to ssl shutdown, any fix to this area may
require a new version release of ASIO with sufficient documentation to explain the new behaviour.
But with this fix, I am able to produce a pleasing, although probably redundant test example:
A client and server connect with TCP and can exchange data in plaintext.
Either side may initiate a secure connection by writing 'starttls\n' on a new line.
Either side may stop a secure connection by writing 'stoptls\n' on a new line, and continue talking
on the same connection in plaintext.
This may be repeated on the same connection at will.
Thanks for taking the time to consider these submissions.