Skip to content

Commit

Permalink
add notes about ssl configuration in demo program
Browse files Browse the repository at this point in the history
  • Loading branch information
bsergean committed May 9, 2021
1 parent 0e0a748 commit 54db6ec
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ A bad security bug affecting users compiling with SSL enabled and OpenSSL as the

#include <ixwebsocket/IXNetSystem.h>
#include <ixwebsocket/IXWebSocket.h>
#include <ixwebsocket/IXUserAgent.h>
#include <iostream>

int main()
Expand All @@ -34,6 +35,8 @@ int main()
// Our websocket object
ix::WebSocket webSocket;

// Connect to a server with encryption
// See https://machinezone.github.io/IXWebSocket/usage/#tls-support-and-configuration
std::string url("wss://echo.websocket.org");
webSocket.setUrl(url);

Expand All @@ -53,6 +56,12 @@ int main()
std::cout << "Connection established" << std::endl;
std::cout << "> " << std::flush;
}
else if (msg->type == ix::WebSocketMessageType::Error)
{
// Maybe SSL is not configured properly
std::cout << "Connection error: " << msg->errorInfo.reason << std::endl;
std::cout << "> " << std::flush;
}
}
);

Expand Down
10 changes: 10 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include <ixwebsocket/IXNetSystem.h>
#include <ixwebsocket/IXWebSocket.h>
#include <ixwebsocket/IXUserAgent.h>
#include <iostream>

int main()
Expand All @@ -25,9 +26,12 @@ int main()
// Our websocket object
ix::WebSocket webSocket;

// Connect to a server with encryption
// See https://machinezone.github.io/IXWebSocket/usage/#tls-support-and-configuration
std::string url("wss://echo.websocket.org");
webSocket.setUrl(url);

std::cout << ix::userAgent() << std::endl;
std::cout << "Connecting to " << url << "..." << std::endl;

// Setup a callback to be fired (in a background thread, watch out for race conditions !)
Expand All @@ -44,6 +48,12 @@ int main()
std::cout << "Connection established" << std::endl;
std::cout << "> " << std::flush;
}
else if (msg->type == ix::WebSocketMessageType::Error)
{
// Maybe SSL is not configured properly
std::cout << "Connection error: " << msg->errorInfo.reason << std::endl;
std::cout << "> " << std::flush;
}
}
);

Expand Down

0 comments on commit 54db6ec

Please sign in to comment.