Bind a client's local IP through SSL - c

I'm looking to add SSL support to a client application written in C/C++ that I'm developing (it is multi-platform, designed to work on Linux and Windows). OpenSSL documentation is pretty poor, but I found a good working tutorial here. To my knowledge, however, there is no way to bind the socket to a local IP address using the BIO handle. There is a rather old ticket on the OpenSSL bug tracker that addresses this, but I think that no solution has been found (one comment suggests using BIO_get_accept_socket, but that will obviously not work for my client application). Any suggestions, solutions, or alternative libraries that offer this kind of functionality?

You can just create, bind and connect the socket yourself, then use SSL_set_fd to pass the socket to OpenSSL, followed by SSL_connect to set up the session.

Related

Partially Porting PJLIB - Without IOQUEUE, select abstraction, and socket abstraction API

I would like to use the PJSIP library to implement a small SIP softphone on an embedded system. Since this embedded system does not offer Linux or support POSIX, I would like to port the PJLIB library only partially, as described here (https://www.pjsip.org/porting.htm#mozTocId30930). The threading function can be deactivated via a macro, but I'm not quite sure yet how I have to set up this new transport function or where exactly it has to be included so that I can also bypass the IOQUEUE implementation and the PJLIB socket abstraction.
On my embedded system (Keil RTX) I can allocate a UDP socket and register a callback which is called on a network event. I also have a send function which I can use to send data packets. Although I have already looked into the stack, I can't find a way to get started.
Has anyone already dared to the partial porting and can give me a brief assistance. Thank you !
See how Symbian port worked (I think it might be removed from recent versions, but it should be still downloadable) - it was also based on non-POSIX sockets. Create your own platform-specific socket file and ioqueue file.

Client/Server communication using TCP/IP under TLS 1.3

I want to write a client and server in C preferably, simple C++ if necessary.
The server will run on some flavor of Linux, the client is for testing the server.
I want to ensure messages are received and error free; therefore I will use TCP.
I want them to communicate securely; thus I will use the latest version of TLS (v1.3).
I intend to use the GnuTLS library for reasons:
Actively updated by reputable open source project
License permits selling product
Given the above, if implemented and tested, I could claim that the client/server communication is secure, reliable (a.k.a. assured), and error-checked. Yes?
Am I missing something? Is anything patently false?
Edit: certificates... i think i'm missing something about certificates to protect against man in the middle attacks...
TLS is a complex topic. Depending on your specific code the TLS connection might succeed even if you fail to properly validate the certificate. Thus, just based on what you state so far in your question it cannot be assured that the data are transferred with proper end-to-end protection and that no man in the middle can manipulate the data.

Implementing a 9p server

I am looking to develop a C implementation of a 9p file server on a Linux machine. There isn't enough documentation in the internet about 9p and I am not very experienced with implementing servers. My general design is as follows:
Use UNIX sockets to listen to incoming 9p messages.
Decode the 9p message and spawn a new thread to perform the required task.
Reply to the client with the appropriate 9p reply message.
The server would just live in the user space and it will translate the 9p messages into a UNIX call.
Do you see any problems or have any recommendations regarding the proposed design? Are there any documentations that you can refer me to that will help me? How do you think I should debug my server and make sure it is working correctly.
Consider libixp (MIT license).
I've played around with wmii and use it in everyday work. libixp was part of wmii (in the earliest releases) and now it is an independent project. Check wmii's early versions to get a good starting point or dive directly into libixp.
To debug your server just mount it with 9PFUSE(4) with parameter −D to print each FUSE and 9P message.

How to create a BACnet client in C

I am trying to create a client in C that will talk with a BACnet server. This BACnet server is stored on an industrial device (CAN2GO) and I am not sure how I could talk with this device.
I spent quite some time reading documentation for BACnet and I never found a clear example for a BACnet client. I already did some server and clients using TCP and UDP but I don't know how to start this BACnet client and I must say I am getting quite desperate.
I found a library which seems to correspond to what I want which is called BACnet protocol stack but when I tried the whois exemple no device was found (I expected to found the bacnet server but maybe I shouldn't ?).
So my question is : could you give me an exemple in C, or another language but C would be better, that would communicate with a BACnet server (nothing complicated just a question and analysing response). This example could be using the library I just wrote about or if you prefer another library I am of course open to everything.
Thank you very much for your time and answers.
I have used that stack and it is the best open source one you are going to find. If you cannot see anything using the demo\whois\bacwi example from that library, then there is something wrong with your setup. In particular, are you using IP? Are your BACnet client and BACnet server on different machines (they cannot be on the same without some serious tweaking)? Are the two machines on the same IP subnet? (They must be, once again, unless you do some serious tweaking (in this case, setting up BBMDs (BACnet Broadcast Management Devices))).
You will also want to try the "Read Property" example (demo\readprop\bacrp.exe) to actually read a value from the server.
If you are still stuck, then post your detailed problem at the link on Sourceforge, Steve, the author, is very responsive to questions.
I am currently using the stack - just started. I had a little trouble at first, not sure if my problem is the same but.. I basically am using some BAC components made from Schneider Electric (UNC-500) and an old un-supported platform (Niagara R2). On my laptop I created a host server and addressed it to a private LAN network between it and the UNC. My laptop was also using wifi, which was utilizing DHCP, so I had two separate interfaces going. This was my problem. I couldn't read or get 'I-AM' responses back from the UNC. As soon as I turned the WIFI off, I got the 'I-AM' broadcasts. Make sure that you are on the same network as your device, and that there are not other interfaces active. Maybe there is a way to assign the interface to use, IDK. I just started using it.

HTML5 Web socket Handshaking

I'm sort of new to web programming, but I wanted to write a HTML interface for a embedded device (coded in C) that I am developing. I've already implemented a stream server (a la beej's socket server example) and a java client, but I'm interested in implementing a HTML5 Socket interface instead.
I am having some trouble with the handshaking (in so much as the server accepts the connection but the web page does not), and was wondering if there was a specification available somewhere on line. The w3c spec seems to only describe the API (as far as I can tell) and not the details of the handshake. I'm not looking for a fully written example (I can do that!) just a reference for the handshaking that is better than the Wikipedia entry (or an explanation of why that entry should be enough to fully understand the spec).
If anyone could help me get it up and running I will happily package it all in a library and demo and put it up on google code.
Thanks... and please let me know if you need more info to help answer the quesiton!
It looks like this is the specifiction here. I'm not much of a web prgrammer myself either. However, based on my limited understanding, I'm curious about whether you really need to implement WebSockets. Could you just using a series of HTTP messages instead?
Did you check your code against existing servers :
http://www.codeproject.com/KB/webservices/c_sharp_web_socket_server.aspx?msg=3364691 ?
with updated to last websocket specification here :
http://nugget.codeplex.com/
Another one here :
or http://superwebsocket.codeplex.com/
Not much difference betwee c# eand C in this case...

Resources