eidheim / Simple-WebSocket-Server

A very simple, fast, multithreaded, platform independent WebSocket (WS) and WebSocket Secure (WSS) server and client library implemented using C++11, Boost.Asio and OpenSSL. Created to be an easy way to make WebSocket endpoints in C++.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use The Program I have a ssl stream problem,Need some Help

Wangweilai1 opened this issue · comments

excuse me,using you program, I had the same problem in the stackoverflow : https://stackoverflow.com/questions/25263381/how-to-clean-boostasiosslstream-after-closed-by-server

How do I can solve the problem. Using WSS protocol in the void accept() function

connection->socket->async_handshake(asio::ssl::stream_base::server, [this, connection, timer](const error_code &ec) {
            if(timer)
              timer->cancel();
			if (ec)
			{
				using namespace std;
				std::cout << ec << std::endl;
				std::cout << ec.value() << std::endl;
				std::cout << ec.message() << std::endl;
			}
            if(!ec)
              read_handshake(connection);
          });

there have a error, and error code is 335544539, message is "short read".
Thanks for your help.

edit (eidheim): more readable code

I fail to reproduce this error, what OS are you on? And please provide which compiler (and version) you are using, and the library versions.

OS:windows10, IDE: VS2015, boost:boost_1_64_0, openssl: openssl1.0.2
Client: Google Chrome 59.0.3071.115,
I use the service parts in this program, Client use Chrome ,use self certificate, in my opinion in the service need add cipher suite, So My cipher suite list is : #define CIPHER_SUITE_LIST "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:\ ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:\ EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4"
and my self certificate is AES128-GCM-SHA256 algorithm;
and error display ec.category().name() is asio.ssl
I don't know Why chrome display connect error.
Thanks for you help.

can you help me write a JSP Client Demo use WSS protocol? I just changed you javascript_client_example.html file at ws=new WebSocket("ws://localhost:8080/echo"); changed into
ws=new WebSocket("wss://localhost:8080/echo"); but it doesn't work to connect service.

The problem is that web browsers are silent when it comes to websocket certificate errors. One solution, unless you start using a valid certificate, is to start a https server running on the same port with the same certificate, and then in the browser accept the certificate as an exception (browsers show https certificate errors). After that, the browser will accept the websocket secure connection with the exception certificate on the same port.

But In my plans , I use this service and browser all at Once computer, That is to say, windows service to connect with browser use Https protocol , so I must use self sign certificate in my computer, in practice,
I already manual operation add CA certificate into browsers, so that I thank it may be not websocket certificate errors.