<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[wolfSSL - Embedded SSL Library — Using wolfSSL embedded SSL with an asynchronous socket]]></title>
		<link>https://www.wolfssl.com/forums/topic393-using-wolfssl-embedded-ssl-with-an-asynchronous-socket.html</link>
		<atom:link href="https://www.wolfssl.com/forums/feed-rss-topic393.xml" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Using wolfSSL embedded SSL with an asynchronous socket.]]></description>
		<lastBuildDate>Tue, 21 Apr 2020 21:53:01 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Using wolfSSL embedded SSL with an asynchronous socket]]></title>
			<link>https://www.wolfssl.com/forums/post5217.html#p5217</link>
			<description><![CDATA[<div class="quotebox"><blockquote><p>Does that mean that I just need to protect against multiple calls to wolfSSL_read() and multiple calls to wolfSSL_write() and so can have a separate mutex for each or do I also need to prevent a call to wolfSSL_write() while another thread is in wolfSSL_read() and vice-versa?</p></blockquote></div><p>To better clarify wolfSSL, for embedded design reasons, uses a single I/O buffer since TLS packets can be up to 16k we thought it unreasonable for resource constrained devices to have to maintain 32k for thread safe reads and writes, the overhead was too much. Because there is only one buffer used for both sending and receiving send calls can corrupt data that is not yet read. Similarly read calls can corrupt data that is not yet sent. A single mutex should be used to protect against both wolfSSL_read and wolfSSL_write calls on the same SSL object.</p><p>For blocking setups we added a feature called &quot;write duplicate&quot;. This is where you use one SSL object to connect to a server. Once the connection is established and the handshake is complete you can make a duplicate of the SSL object for writing only. Then the first SSL object becomes a read only object. This gives a solution for the scenario SieRaybould noted but also adds that overhead of 32k for thread safe reading and writing. See wolfSSL_write_dup(ssl); for creating a write duplicate of an SSL object.</p><br /><br /><p>Warm Regards,</p><p>K</p>]]></description>
			<author><![CDATA[null@example.com (Kaleb J. Himes)]]></author>
			<pubDate>Tue, 21 Apr 2020 21:53:01 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post5217.html#p5217</guid>
		</item>
		<item>
			<title><![CDATA[Re: Using wolfSSL embedded SSL with an asynchronous socket]]></title>
			<link>https://www.wolfssl.com/forums/post5190.html#p5190</link>
			<description><![CDATA[<p>I know this is an old thread but could you please clarify this response:</p><p><strong>&quot;You&#039;ll need to protect calls to wolfSSL_read() and wolfSSL_write() on the same WOLFSSL object with a mutex or similar to avoid more than one thread trying to call it simultaneously.&quot;</strong></p><p>Does that mean that I just need to protect against multiple calls to wolfSSL_read() and multiple calls to wolfSSL_write() and so can have a separate mutex for each or do I also need to prevent a call to wolfSSL_write() while another thread is in wolfSSL_read() and vice-versa?</p><p>I hope not or this would mean it is impossible to use a blocking receive interface at the socket transport layer in a multi-threaded environment, as while the receive is waiting for data, no-one would be able to send anything.</p><p>Kind Regards,<br />Simon Raybould,<br />Firmware Developer, Landis+Gyr, Switzerland.</p>]]></description>
			<author><![CDATA[null@example.com (SieRaybould)]]></author>
			<pubDate>Wed, 01 Apr 2020 16:35:13 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post5190.html#p5190</guid>
		</item>
		<item>
			<title><![CDATA[Re: Using wolfSSL embedded SSL with an asynchronous socket]]></title>
			<link>https://www.wolfssl.com/forums/post1641.html#p1641</link>
			<description><![CDATA[<p>I&#039;m in a similar situation as the OP. Has this ever been resolved?</p><p>Thanks</p>]]></description>
			<author><![CDATA[null@example.com (lieron)]]></author>
			<pubDate>Sun, 18 May 2014 17:12:05 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post1641.html#p1641</guid>
		</item>
		<item>
			<title><![CDATA[Re: Using wolfSSL embedded SSL with an asynchronous socket]]></title>
			<link>https://www.wolfssl.com/forums/post1200.html#p1200</link>
			<description><![CDATA[<p>Hello,</p><p>The problem is - The callback is only being called if the SSL_Read function is called. The threads that are reading are receiving messages asynchronously, meaning I don&#039;t know when a message will be received...</p><p>One way I can think of is inserting the newly received message into a queue, and then calling to SSL_Read explicitly, overriding the read callback to get the message from the queue.<br />But that seems kind of crooked (And needs to be well designed thread-safety-wise)</p><p>The higher levels (i.e. the Business Logic that uses the TCP server) are built based on asynchronous messaging as well, so I&#039;d like to keep the reading method as it is</p><p>Thanks<br />Nitay</p>]]></description>
			<author><![CDATA[null@example.com (Nitay)]]></author>
			<pubDate>Fri, 14 Jun 2013 09:33:01 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post1200.html#p1200</guid>
		</item>
		<item>
			<title><![CDATA[Re: Using wolfSSL embedded SSL with an asynchronous socket]]></title>
			<link>https://www.wolfssl.com/forums/post1198.html#p1198</link>
			<description><![CDATA[<p>Nitay,</p><p>It sounds like you&#039;re on the right track with registering your own I/O callbacks.&nbsp; The callbacks were designed to allow applications to control how they read/write data to/from wolfSSL.&nbsp; For your Recv callback, you&#039;ll just need to pass the encrypted data buffer received over your transport medium to wolfSSL through the provided buffer, &quot;buf&quot;, in your callback.&nbsp; For an example, you can reference the EmbedReceive() function in &lt;wolfssl_root&gt;/src/io.c.</p><p>I&#039;m not familiar with IOCP myself, so if I&#039;m misunderstanding what you are trying to do, please correct me.</p><p>Best Regards,<br />Chris</p>]]></description>
			<author><![CDATA[null@example.com (chrisc)]]></author>
			<pubDate>Thu, 13 Jun 2013 17:11:30 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post1198.html#p1198</guid>
		</item>
		<item>
			<title><![CDATA[Re: Using wolfSSL embedded SSL with an asynchronous socket]]></title>
			<link>https://www.wolfssl.com/forums/post1196.html#p1196</link>
			<description><![CDATA[<p>Hi,</p><p>I&#039;m less concerned about thread safety since I can limit thread access per session. I&#039;m just not sure about how can I use wolfSSL if my reads are done outside the library, and not through the SSL_Read function</p><p>Thanks<br />Nitay</p>]]></description>
			<author><![CDATA[null@example.com (Nitay)]]></author>
			<pubDate>Thu, 13 Jun 2013 15:55:53 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post1196.html#p1196</guid>
		</item>
		<item>
			<title><![CDATA[Re: Using wolfSSL embedded SSL with an asynchronous socket]]></title>
			<link>https://www.wolfssl.com/forums/post1195.html#p1195</link>
			<description><![CDATA[<p>Hi Nitay,</p><p>Section 9.4 of the wolfSSL Manual (<a href="http://www.yassl.com/yaSSL/Docs-cyassl-manual-9-library-design.html">http://www.yassl.com/yaSSL/Docs-cyassl- … esign.html</a>) talks a little about wolfSSL&#039;s thread safety.&nbsp; Have you looked through that?</p><p>wolfSSL is generally thread safe, but reading from or writing to the same WOLFSSL object with multiple threads at one time is not supported.&nbsp; You&#039;ll need to protect calls to wolfSSL_read() and wolfSSL_write() on the same WOLFSSL object with a mutex or similar to avoid more than one thread trying to call it simultaneously.</p><p>Best Regards,<br />Chris</p>]]></description>
			<author><![CDATA[null@example.com (chrisc)]]></author>
			<pubDate>Thu, 13 Jun 2013 15:51:08 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post1195.html#p1195</guid>
		</item>
		<item>
			<title><![CDATA[Using wolfSSL embedded SSL with an asynchronous socket]]></title>
			<link>https://www.wolfssl.com/forums/post1193.html#p1193</link>
			<description><![CDATA[<p>Hello,</p><p>I have tcp server which uses multiple threads for reading through an IO Completion Port. I want to add SSL to this server.</p><p>What, in your opinion, is the best way to do so?<br />The writes are less of a problem, but how do I decrypt a SSL packet without calling read?</p><p>For now, I&#039;ve set the write and read callbacks using wolfSSL_SetIORecv / wolfSSL_SetIOSend.<br />I didn&#039;t implement the reads yet. <br />Also, the accept could be done to a new client before attaching it to the IOCP, so its not really a non-blocking IO...</p><p>What do you think?</p><p>EDIT: The reads are done through IOCP, so the threads are not blocked on recv() or select(), but on GetQueuedCompletionStatus()</p><p>Thanks<br />Nitay</p>]]></description>
			<author><![CDATA[null@example.com (Nitay)]]></author>
			<pubDate>Thu, 13 Jun 2013 13:25:05 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post1193.html#p1193</guid>
		</item>
	</channel>
</rss>
