Looking for poco ssl websocket client example in C++ for Windows 7 - c++

I've been looking through the poco samples and documentation, but I couldn't find out how to use poco's websockets and SSL combined. I successfully connected a non-SSL websocket (based on the WebSocket class) to a server (the echoserver sample from Qt5.4, running on Ubuntu), but how to add SSL to the client eludes me. Poco's NetSSL_OpenSSL samples aren't all that helpful, because I don't need to know how to download, tweet, mail or write a time server. Also the latter is the only one that uses "SecureStreamSocket" objects at all (which is probably the class I need). But that sample just accesses the socket from the request object, it doesn't show how to create and configure one properly.
I just want an SSL websocket client to send and receive some simple messages, like "Hello World". Can anyone help me please?
I use Windows 7 64 Bit for the client's OS and Ubuntu 64 Bit on VirtualBox for the server's OS, but the server side is no problem. My poco version is 1.6.0 and I compiled it with Visual Studio 2013 Express. Also I use OpenSSL 1.0.1j.
Cheers
Alex

Look at WebSocket testcase. Use HTTPSClientSession (instead of HTTPClientSession).

Related

Is there an encoding difference between Windows and Ubuntu

This is related to: Sending packets over UDP from Windows
I making simple UDP client using Boost ASIO. When I run the client on Ubuntu, it can send to the server (listener) the data correctly. However, when I am running it on Windows, the server can not parse the data correctly.
Since I do not have access to the server code. I can not be sure what is happening there.
I am sure that it is not Networking (such as firewall) problem because I tried the code on Ubuntu VM inside a Windows Host and it worked.
My question is: Should I encode the message I sent from Windows in different manner? (I am not sure but something like UTF-8, UTF-16 differences.. maybe..)
The sending code:
socket_.send_to(boost::asio::buffer(message, sizeof(*message)), endpoint_);
Where message is pointer to some struct that the server expecting. end_point_ is correct. I printed it and the address and port are correct.

zeromq: using a linux [REP] and windows [REQ] connection, no message arrives

I am trying to send messages from a windows client to a linux server using the REQ/REP pattern with ZeroMQ. The server side code is the hwserver.cpp code from the examples of the 0MQ guide. And for the client side I also use the example code hwclient.cpp.
Now the problem at hand is the following. If I use a Linux server and client I am able to send messages, receive them and send a reply back which is also received. When the server and client are both run in Windows I also can receive and send messages. If the server is running in Windows and the client is running in Linux it also works. These tests make me think I have at least the correct IP adresses.
When I try to use a Linux server and a Windows clien, the messages that are send do not arrive at the server. And I don't know what could cause this, since the reverse with a Windows server + Linux client works perfectly. I found a similar question but the solution posted there did not work.
I use Fedora 20 with g++ 4.8.3 and Windows 8 with Microsoft Visual Studio 2013.
Is there an option that has to be flagged when doing this kind of 0MQ connection ?
Once ZeroMQ version numbers match, there need not be any further "magic-switch" for Window$
n.b.:
socket.connect ("tcp://<_aUbuntuHOST_IpADRESS_>:5555"); // Do W8 allow outbound tcp:5555 connection in the security policy in effect?
May you proof that the Win integrated firewall policies ( explicit security settings permit exceptions ) do allow a process to request + use an outgoing tcp connection on the specified port number?
May reverse .bind() / .connect() on REQ/REP sides to remain on the same situation as that was working once you had Ubuntu.REQ ( with .connect() ) and the W8.REP ( with .bind() ) so the W8.REQ would again .bind() ( which you reported that worked fine ) & Ubuntu.REP would .connect()

Using telnet to communicate with QNX Neutrino via TCP/IP in C++

I'm able to access a telnet server via PuTTY which opens a terminal and allows me to send commands to retrieve data/logs and start/stop processes. I'd like to begin some research into how to access this server via C++ in order to automate the connection and the commands for testing. Basically I need a telnet client that can connect and authenticate itself, and write and read to/from the server as if I'm typing in a terminal. Where should I start my research? I've tried a couple examples including:
http://lists.boost.org/boost-users/att-40895/telnet.cpp
When I compile and run
./telnet 192.168.1.26 23
Nothing happens, but when I connect to the server with PuTTY I get:
QNX Neutrino (localhost) (ttyp0)
login: root
password:
#
Any help would be greatly appreciated.
Notes:
- I am using a Mac running OS X Version 10.7.3 with i686-apple-darwin11-llvm-gcc-4.2
- I am allowed to be doing this.
- I use PuTTY on my Windows 7 machine, the connection is ethernet to USB ethernet adapter, and the settings for the Local Area Connection Properties > TCP/IPv4 Properties: are a specific IP address, Subnet Mask, and Default gateway, which might be useful information.
Thanks
Learn how to program TCP/IP sockets. You can use the boost libraries, or straight C style BSD sockets. Some info here, here and here. If paper is your thing, you could get Volume 1 of Unix Network Programming. That book has such a good reputation that you get votes just for mentioning it on StackOverflow.
What you want to do closely matches the functionality of telnet and expect. You can have a look at there sources here and here for ideas.
Consider just using expect to solve your problem :)
You should start by learning the network API for the system you're trying to connect from. Telnet is just sending straight up text through a tcp/ip socket.

Boost's ASIO + SSL don't work in some conditions

There is a client/server application written using Boost's ASIO (Boost v.1.48) + OpenSSL (v.1.0.0d). Complete OpenSSL (dynamic/static libraries and binaries) is custom built, the after-build tests are passed correctly and it links to the client and the server statically. ASIO code works in asynchronous mode. All ASIO's SSL contexts use the boost::asio::ssl::context::sslv23
method. The problem description is the following.
Configuration 0
The server: works under Win7 Prof SP1 (Comp0). It uses a self-signed private key (PK0) and a public certificate (PC0) generated by the custom built OpenSSL binaries mentioned above. The server has a infinite timeout.
The client: works under WinXP Prof SP3 (Comp1). It uses the servers public certificate (PC0). The client has 20 secs timeout.
The clients connects successfully to the server but closes the connection by the 20 secs timeout in the SSL's handshake method (boost::asio::ssl::stream::async_handshake). FAIL.
Configuration 1
Both the server and the client run on the same Win7 Prof SP1 (Comp0), use the same ethernet interface and the same PK0/PC0 as in the configuration 0.
The clients successfully connects handshakes, sends/receives data and closes the connection. SUCCESS.
Configuration 2
The server: works under Win7 Prof SP1 (Comp0). It uses a self-signed private key (PK1) and a public certificate (PC1) generated by the custom built OpenSSL binaries BUT the PK1 and PC1 are generated a half of a year ago. PK0/PC0 are generated today. All the keys are generated by the same OpenSSL binaries (v.1.0.0d).
The client: works under WinXP Prof SP3 (Comp1). It uses the servers public certificate (PC1).
The clients successfully connects handshakes, sends/receives data and closes the connection. SUCCESS.
Configuration 3
Both the server and the client run on the same Win7 Prof SP1 (Comp0), use the same ethernet interface and the same PK1/PC1 as in the configuration 2.
The clients successfully connects handshakes, sends/receives data and closes the connection. Obviousely SUCCESS.
Changing the OpenSSL version to the latest stable release (v.1.0.0g) gives the same results.
The problem is not working configuration 0. Has anyone ever had such problem? Are there any ideas where can be the problem cause? In which direction is necessary to move to fix the problem?
Update #1. The code compiled using the tlsv1 method instead of the sslv23 one does not work in the Configuration 0 also.
Final Update. The problem is fixed. The cause is that the Comp1's system date was in the past, i.e. the PK0/PC0 are issued in future for this computer and OpenSSL fails in the handshake procedure. PC1 is issued in the past for the Comp1 and it works with it without problems. To diagnose the problem cause I used the following command executed on the client computer:openssl s_client -connect server_ip:server_port, where server_ip is the server address and server_port is the the server listening port. Now a task is to find a reason why handshake times out rather than returns an error. But it is another story. I hope my post will help someone in future.
The problem is fixed. The cause is that the Comp1's system date was in the past, i.e. the PK0/PC0 are issued in future for this computer and OpenSSL fails in the handshake procedure. PC1 is issued in the past for the Comp1 and it works with it without problems. To diagnose the problem cause I used the following command executed on the client computer:openssl s_client -connect server_ip:server_port
, where server_ip is the server address and server_port is the the server listening port. Now a task is to find a reason why handshake times out rather than returns an error. But it is another story. I hope my post will help someone in future.

dhcp client on linux, port or use?

On linux platform, I want to have dhcp client.
port any open source client to my app (which seems to be a bit time consuming)?
or communicate with the standalone client app via Signals?
or anyone knows any dhcp client library?
thanks for any advice.
You mean you want your app to tell the computer to DHCP? I would talk to dhcpcd using command line arguments and not do tons of extra work.