Archived

This forum has been archived. Please start a new discussion on GitHub.

How to connect to a remote server using IceSSL with C++ (Windows)

HI Bernard,

Thank you much for replying back and activating my account here.

Yes, I have installed Ice-3.4.2.msi on windows. I have gone through the documentation such as “C++ Configuration for IceSSL” and “The IceSSL Plugin Interface in C++” and have looked in the demos you are referring too, but I was not able to find the one using IceSSL.

I am trying to write a C++ program to communicate with a remote server listening on a random port. The sever requires me to use a certificate provided by them for authentication of connection. For this secure communication I need to create a secure socket layer (SSL) connection. I found IceSSL very interesting because theoretically it will allow me to specify the location of my certificates and will help me creating a connection with server.

As, I was not able to find any example showing this kind of work, therefore I am having problems in what header files to include and how to make sure that what I am doing is correct. So far, after reading the documentation, I have tried following C++ code;

#include <Ice/Ice.h>
#include <IceSSL/IceSSL.h>

void IceSSLTest(int argc, char** argv)
{
using namespace std;
Ice::CommunicatorPtr communicator;
try
{
Ice::InitializationData initData;
initData.properties = Ice::createProperties(argc, argv);

initData.properties->setProperty("Ice.Plugin.IceSSL", "IceSSL:createIceSSL");
initData.properties->setProperty("IceSSL.DefaultDir", "cert/");
initData.properties->setProperty("IceSSL.CertFile", "pubkey.pem");
initData.properties->setProperty("IceSSL.KeyFile", "privkey.pem");
initData.properties->setProperty("CertAuthFile", "ca.pem");
initData.properties->setProperty("IceSSL.Password", "sungard");

Ice::CommunicatorPtr communicator = Ice::initialize(initData);
Ice::PluginManagerPtr pluginMgr = communicator->getPluginManager();
Ice::PluginPtr plugin = pluginMgr->getPlugin("IceSSL");
IceSSL::PluginPtr sslPlugin = IceSSL::PluginPtr::dynamicCast(plugin);
pluginMgr->initializePlugins();
sslPlugin->initialize();

pluginMgr->destroy();
sslPlugin->destroy();
communicator->destroy();
}
catch(const Ice::Exception& ex)
{
cerr << ex << endl;
try
{
if(communicator)
{
communicator->destroy();
}
}
catch(const Ice::Exception& ex)
{
cerr << ex << endl;
}
}
}



Now the problems are, that I do not know, where I can specify the IP and Port of the server which I am trying to connect with and also I do not know if there is any connection object or if I have any control over the connection object yet. For example, if I want to check if I got connected successfully with the server or if I want to disconnect from the server. Also, how can I send and receive data to the server using IceSSL.

Please let me know, you suggestions and if there is any such example or tutorial please refer that.


Thanks again.

Kind Regards,