title: HTTPS request in c++ using Poco
body: <p>I am trying to write a client app in C++ using Poco Libraries (version poco-1.4.6p1-all) and compiling in Visual Studio 2010, that sends a HTTPS request to a server that has a self-written certificate. I have an error because the certificate is not recognized:</p>
  
  <p><code>First-chance exception at 0x76e8c41f in httprequest.exe: Microsoft C++ exception: Poco::Net::SSLException at memory location 0x0044ed38..</code></p>
  
  <p>I have tried changing the verify functions written in the library (in X509Certificate.h) so that they always return true and rebuilt the library. Same error. </p>
  
  <p>Here is the code:</p>
  
  <pre><code>try{
      const Poco::URI uri("https://www.theServer.com");
      Poco::Net::Context::Ptr context =
          new Poco::Net::Context(Poco::Net::Context::CLIENT_USE, "",
          "","",Poco::Net::Context::VERIFY_RELAXED,
          9, true, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
  
      Poco::SharedPtr&lt;Poco::Net::InvalidCertificateHandler&gt; pAcceptCertHandler = new Poco::Net::AcceptCertificateHandler(true);
      Poco::Net::SSLManager::instance().initializeClient(NULL, pAcceptCertHandler, context);
  
      Poco::Net::HTTPSClientSession session(uri.getHost(), uri.getPort(), context );
      Poco::Net::HTTPRequest req(Poco::Net::HTTPRequest::HTTP_GET, "" );
      req.setContentType("application/x-javascript; charset=utf-8\r\n");
      req.setKeepAlive(true);
  
      Poco::Net::HTTPBasicCredentials cred("lala@lala.lala", "lala");
      cred.authenticate(req);
      session.sendRequest(req);
      Poco::Net::HTTPResponse res;
      std::istream&amp; rs = session.receiveResponse(res);
      std::string resp;
  
      std::vector&lt;Poco::Net::HTTPCookie&gt; cookies;
      res.getCookies( cookies );
      res.write(std::cout);
  }
  catch( const Poco::Net::SSLException&amp; e )
  {
      std::cerr &lt;&lt; e.what() &lt;&lt; ": " &lt;&lt; e.message() &lt;&lt; std::endl;
  }
  catch( const std::exception&amp; e )
  {
      std::cerr &lt;&lt; e.what() &lt;&lt; std::endl;;
  }
  </code></pre>
  
  <p>Thank you!</p>