<p dir="ltr">To whom it may concern,</p>
<p dir="ltr">I have been experiencing issues with OpenSSL and DraginoYun. If you are not the person I should have contacted, please redirect me. Thank you!</p>
<p dir="ltr">Recently, I have tried using OpenSSL to establish a simple server application on Dragino Yun version 2.4. First, I tested the code on my Acer Aspire 5750ZG running Ubuntu 14.04 and it worked fine. Afterwards, I used OpenWrt SDK to cross-compile the application. However, the application is unable to bind the socket; the BIO_do_accept function fails. Here is the error stack the code provided:<br>
"2006783048:error:0200407C:lib(2):func(4):reason(124):NA:0:port='5354'<br>
2006783048:error:20069076:lib(32):func(105):reason(118):NA:0:"</p>
<p dir="ltr">errstr returned these as answers:<br>
"$ openssl errstr 0200407C<br>
error:0200407C:system library:socket:Wrong medium type<br>
$ openssl errstr 20069076<br>
error:20069076:BIO routines:BIO_get_accept_socket:unable to create socket<br>
"<br>
I suppose that the second one is a product of the first one.</p>
<p dir="ltr">I have checked iptables and I have checked ports that are currently in use, all seems to be in order.</p>
<p dir="ltr">However, the OpenSSL s_server (in combination with s_client on the other side) works fine.<br>
May this be an OpenSSL bug? If not, do you have any suggestions?</p>
<p dir="ltr">OpenSSL version on Acer is 1.0.1f 6 Jan 2014 and on Dragino 1.0.1h 5 Jun 2014.</p>
<p dir="ltr">In the attachment, I am providing the code(though I am not sure if it is available on the list), mostly taken from O'Reilly "Network Security with OpenSSL".</p>
<p dir="ltr">All the passkeys are "raspberry". (these certificates and keys were generated for testing purposes)</p>
<p dir="ltr">Of course, should you need any additional information, I'd be happy to provide it.</p>
<p dir="ltr">I originally addressed Matt Caswell regarding the issue and I am pasting his response to my question and my response to that.</p>
<p dir="ltr">His response:<br>
"Hello,</p>
<p dir="ltr">I'm not really the best person to ask about such low level stuff. The<br>
best place to raise these questions is on the openssl-users email list.<br>
It also means any questions/answers are publicly archived and available<br>
for other users. Details are here:</p>
<p dir="ltr"><a href="https://mta.openssl.org/">https://mta.openssl.org</a></p>
<p dir="ltr">However, I did have a quick look and discovered the following. The code<br>
that raises this error looks like this:</p>
<p dir="ltr">    s = socket(server.sa.sa_family, SOCK_STREAM, SOCKET_PROTOCOL);<br>
    if (s == INVALID_SOCKET) {<br>
        SYSerr(SYS_F_SOCKET, get_last_socket_error());<br>
        ERR_add_error_data(3, "port='", host, "'");<br>
        BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET, BIO_R_UNABLE_TO_CREATE_SOCKET);<br>
        goto err;<br>
    }</p>
<p dir="ltr">So this is a call to the non-OpenSSL networking function "socket". In<br>
this context "server.sa.sa_family" has been set to AF_INET a few lines<br>
above, and "SOCKET_PROTOCOL" is a macro defined at the beginning of the<br>
file as follows:</p>
<p dir="ltr"># define SOCKET_PROTOCOL IPPROTO_TCP</p>
<p dir="ltr">In other words the function that is failing is doing this:</p>
<p dir="ltr">socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)</p>
<p dir="ltr">This seems like a fairly fundamental failure, and might suggest that the<br>
platform in question has no TCP/IP support available for some reason?"</p>
<p dir="ltr">My response to his:<br>
"<br>
Hi Matt,</p>
<p dir="ltr">The platform supports TCP/IP, if I deduced correctly. I have programmed an application similar to the example in Unix Network Programming (a basic TCP/IP echo server) and it works without any issues. Also, openssl s_server works correctly; I tried using it with openssl s_client on the other machine.<br>
I will forward my question to the email list, including both of our responses.<br>
I am grateful for your quick response.</p>
<p dir="ltr">Best regards,<br>
Nikola Milev</p>
<p dir="ltr">"</p>
<p dir="ltr">My original mail to him is almost the same as the first part of this mail.</p>
<p dir="ltr">I am thankful for you support!</p>
<p dir="ltr">Best regards,<br>
Nikola Milev</p>