Poco C++ - Net Ssl - How to Post Https Request

POCO C++ - NET SSL - how to POST HTTPS request

You are setting content type like this:

req.setContentType("Content-Type: application/x-www-form-urlencoded\r\n");

which should be:

req.setContentType("application/x-www-form-urlencoded\r\n");

HTTPS request in c++ using Poco

I found the answer. I wasn't really getting the certificate. It works like this:

 try{
Poco::Net::initializeSSL();
Poco::SharedPtr<Poco::Net::InvalidCertificateHandler> ptrHandler = new AcceptCertificateHandler(false);
Context::Ptr ptrContext = new Context(Context::CLIENT_USE, "", "", "", Context::VERIFY_RELAXED, 9, true, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
SSLManager::instance().initializeClient(0, ptrHandler, ptrContext);

Poco::Net::SocketAddress address("www.server.com:443");
Poco::Net::SecureStreamSocket socket(address);
if (socket.havePeerCertificate())
{
X509Certificate cert = socket.peerCertificate();
std::cout<<cert.issuerName()<<"\n";
}
else
{
std::cout<<"No certificate";
}

}catch (Poco::Exception& e) {
std::cout << "Error: " << e.displayText() << "\n";
return -1;
}

Upload a file using POCO - SSL Connection Unexpectedly Closed Exception

I am able to handle the exception by reading the response body character by character. Here is the complete code to upload a file using POCO.

http://developersarea.wordpress.com/2014/10/08/upload-files-using-poco-c-libraries/



Related Topics



Leave a reply



Submit