HTTP and HTTPS Tunneling - Server
This sample demonstrates a server accepting client connections through HTTP and HTTPS tunnels.
#include <iostream>
#include <RCF/RCF.hpp>
#include <RCF/PemCertificate.hpp>
#ifndef RCF_FEATURE_OPENSSL
#error Please define RCF_FEATURE_OPENSSL=1 to build this sample with OpenSSL support.
#endif
RCF_BEGIN(I_PrintService, "I_PrintService")
RCF_METHOD_V1(void, Print, const std::string &)
RCF_END(I_PrintService)
class PrintService
{
public:
void Print(const std::string & msg)
{
std::cout << std::endl;
{
std::cout << "Client connecting through a HTTP tunnel." << std::endl;
}
{
std::cout << "Client connecting through a HTTPS tunnel." << std::endl;
}
std::cout << "I_PrintService service: " << msg << std::endl;
}
};
int main()
{
try
{
PrintService printService;
server.
bind<I_PrintService>(printService);
"serverCert.pem",
"password"));
std::cout << "Press Enter to exit..." << std::endl;
std::cin.get();
}
{
}
return 0;
}
HTTP and HTTPS tunneling - Client
This sample demonstrates a client connecting to a server through HTTP and HTTPS tunnels.
#include <iostream>
#include <RCF/RCF.hpp>
#include <RCF/PemCertificate.hpp>
#ifndef RCF_FEATURE_OPENSSL
#error Please define RCF_FEATURE_OPENSSL=1 to build this sample with OpenSSL support.
#endif
RCF_BEGIN(I_PrintService, "I_PrintService")
RCF_METHOD_V1(void, Print, const std::string &)
RCF_END(I_PrintService)
bool validateCert(
RCF::Certificate * pCert)
{
if ( pX509Cert )
{
X509 * pX509 = pX509Cert->getX509();
}
return true;
}
int main()
{
try
{
std::string serverName = "printsvr";
std::string proxyName = "web-proxy.acme.com";
int proxyPort = 8080;
{
std::cout << "Connecting through HTTP tunnel." << std::endl;
client.getClientStub().setHttpProxy(proxyName);
client.getClientStub().setHttpProxyPort(proxyPort);
client.Print("Hello World");
}
{
std::cout << "Connecting through HTTPS tunnel." << std::endl;
client.getClientStub().setHttpProxy(proxyName);
client.getClientStub().setHttpProxyPort(proxyPort);
client.getClientStub().setCertificateValidationCallback(&validateCert);
client.Print("Hello World");
}
}
{
}
return 0;
}