<?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 — [SOLVED] load_buffer with NO_FILESYSTEM define needs filesystem?]]></title>
		<link>https://www.wolfssl.com/forums/topic437-solved-loadbuffer-with-nofilesystem-define-needs-filesystem.html</link>
		<atom:link href="https://www.wolfssl.com/forums/feed-rss-topic437.xml" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in [SOLVED] load_buffer with NO_FILESYSTEM define needs filesystem?.]]></description>
		<lastBuildDate>Mon, 21 Oct 2013 08:09:07 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: [SOLVED] load_buffer with NO_FILESYSTEM define needs filesystem?]]></title>
			<link>https://www.wolfssl.com/forums/post1406.html#p1406</link>
			<description><![CDATA[<p>Hi Chris,</p><p>thanks for the confirmation.</p><p>I already did what you were suggesting and so far it&#039;s working for my use-cases. Of course it&#039;s not a very nice solution as I hard-coded the hex-values of all the certificates in DER-format into some header-files.<br />I will provide the code with the remainder of the eCos-port once I&#039;m done <img src="https://www.wolfssl.com/forums/img/smilies/smile.png" width="15" height="15" alt="smile" />.</p><p>Regards<br />- Daniel</p>]]></description>
			<author><![CDATA[null@example.com (Zeddi)]]></author>
			<pubDate>Mon, 21 Oct 2013 08:09:07 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post1406.html#p1406</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] load_buffer with NO_FILESYSTEM define needs filesystem?]]></title>
			<link>https://www.wolfssl.com/forums/post1405.html#p1405</link>
			<description><![CDATA[<p>Hi Daniel,</p><p>You are correct in your findings.&nbsp; Our client/server examples currently assume that there will be a file system available.&nbsp; We&#039;ll need to work on making those easier to use in filesystem-less environments.</p><p>You&#039;d need to use the buffer loading functions to load your certificates and keys instead of the file loading functions, ie:</p><p>wolfSSL_CTX_load_verify_buffer<br />wolfSSL_CTX_use_certificate_buffer<br />wolfSSL_CTX_use_PrivateKey_buffer<br />etc.</p><p>Best Regards,<br />Chris</p>]]></description>
			<author><![CDATA[null@example.com (chrisc)]]></author>
			<pubDate>Fri, 18 Oct 2013 21:00:47 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post1405.html#p1405</guid>
		</item>
		<item>
			<title><![CDATA[[SOLVED] load_buffer with NO_FILESYSTEM define needs filesystem?]]></title>
			<link>https://www.wolfssl.com/forums/post1398.html#p1398</link>
			<description><![CDATA[<p>I&#039;m trying to run the unit-tests on a WIP eCos port (based on wolfSSL embedded SSL 2.7.0), but stumbled over certificate loading with the example server and <strong>NO_FILESYSTEM </strong>defined.</p><p>This define helped during API tests, as the client certificates are then loaded directly from the <strong>certs_test.h</strong> header file, e.g.:<br /></p><div class="codebox"><pre><code>/* ./certs/1024/client-key.der, 1024-bit */
const unsigned char client_key_der_1024[] =
{
    0x30, 0x82, 0x02, 0x5C, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81, 
[...]
};</code></pre></div><p>I hoped that this will work the same way when I start the server itself (in my case through the <strong>SuiteTests</strong>-function in <strong>suites.c</strong>). Unfortunately, the server only loads certificates if a filesystem is available (<strong>examples/server/server.c</strong>):<br /></p><div class="codebox"><pre><code>#if !defined(NO_FILESYSTEM) &amp;&amp; !defined(NO_CERTS)
    if (!usePsk) {
        if (SSL_CTX_use_certificate_file(ctx, ourCert, SSL_FILETYPE_PEM)
                                         != SSL_SUCCESS)
            err_sys(&quot;can&#039;t load server cert file, check file and run from&quot;
                    &quot; wolfSSL home dir&quot;);
    }
#endif</code></pre></div><p>Then I saw that the echoserver (<strong>examples/echoserver/echoserver.c</strong>) on the other hand has code for the <strong>NO_FILESYSTEM</strong> case:<br /></p><div class="codebox"><pre><code>#ifndef NO_FILESYSTEM
[...]
#elif !defined(NO_CERTS)
    if (!doPSK) {
        load_buffer(ctx, svrCert, WOLFSSL_CERT);
        load_buffer(ctx, svrKey,  WOLFSSL_KEY);
    }
#endif</code></pre></div><p>What made me sad in the end, was that the function <strong>load_buffer</strong> as defined in <strong>test.h</strong> again needs a filesystem to fill the buffer with contents of the file passed:<br /></p><div class="codebox"><pre><code>#if defined(NO_FILESYSTEM) &amp;&amp; !defined(NO_CERTS)
[...]
static INLINE void load_buffer(WOLFSSL_CTX* ctx, const char* fname, int type)
{
        /* test buffer load */
        long  sz = 0;
        byte  buff[10000];
        FILE* file = fopen(fname, &quot;rb&quot;);

        if (!file)
            err_sys(&quot;can&#039;t open file for buffer load &quot;
                    &quot;Please run from wolfSSL home directory if not&quot;);
[...]
#endif /* NO_FILESYSTEM */</code></pre></div><p>So, do I have to make my own <strong>load_buffer</strong>-function which fills ctx directly from a char array, or is there any other intended way to do this which I&#039;m missing?</p><p>Thanks!<br />- Daniel</p>]]></description>
			<author><![CDATA[null@example.com (Zeddi)]]></author>
			<pubDate>Fri, 11 Oct 2013 08:07:57 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post1398.html#p1398</guid>
		</item>
	</channel>
</rss>
