title: Trouble getting POCO HTTPSClientSession to send a request - certificate verify failed
body: <p>I'm trying to use the POCO libraries to write a program that makes an HTTPS request to a server. For testing purposes, I'm connecting to a server which has a self-signed certificate, and I want to allow the client to connect anyway.  To allow that to happen, I've attempted to install an <code>InvalidCertificateHandler</code> which is an instance of <code>AcceptCertificateHandler</code> - which I thought would accept the certificate even though it's not signed.  Here's the code I'm using:</p>
  
  <pre><code>try {
              Poco::SharedPtr&lt;Poco::Net::InvalidCertificateHandler&gt; pAcceptCertHandler =
                                               new Poco::Net::AcceptCertificateHandler(true);
              Poco::Net::Context::Ptr pContext =
                  new Poco::Net::Context(Poco::Net::Context::CLIENT_USE, "",
                                         "","",Poco::Net::Context::VERIFY_RELAXED,
                                         9, true, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
              SSLManager::instance().initializeClient(NULL, pAcceptCertHandler, pContext);
  
              Poco::Net::HTTPSClientSession theSess(myHostName,myHostPort);
  
              // Create the HTTP request object
              Poco::Net::HTTPRequest request("POST",
                                "https://myservername.com/MockServlet/activateEnc","1.1");
  
              // Send the request
              std::cout &lt;&lt; "Debug point A" &lt;&lt; std::endl;
              std::ostream&amp; aStream = theSess.sendRequest(request);
              std::cout &lt;&lt; "Debug point B" &lt;&lt; std::endl;
              if (aStream.fail()) {
                  std::cout &lt;&lt; "Fail to send HTTP request for activateEnc" &lt;&lt; std::endl;
                  return WSERR_CONNECTION_ERR;
              }   
          } catch (Poco::Exception&amp; exc) {
              std::cout &lt;&lt; "Exception caught while attempting to connect." &lt;&lt; std::endl;
              std::cerr &lt;&lt; exc.displayText() &lt;&lt; std::endl;
              return WSERR_CONNECTION_ERR;
          }   
  </code></pre>
  
  <p>When I run this code, I get the following output:</p>
  
  <pre><code>Debug point A
  Exception caught while attempting to connect.
  Certificate validation error: Unacceptable certificate from myservername.com: application verification failure
  </code></pre>
  
  <p>My expectation was that since I'm using the AcceptCertificateHandler, the certificate would be accepted even though it is not valid.  What might I be doing wrong?</p>
  
  <p>A couple notes:</p>
  
  <ol>
  <li>In the Context object constructor call, I'm passing empty strings for privateKeyFile, certificateFile, and caLocation arguments. The reason I did this is because I think that as a client I don't need a private key, client certificate, or certificate authority certificates. Maybe this is the problem?</li>
  <li>In the call to initializeClient, I'm passing NULL as the PrivateKeyPasshraseHandler - because I'm not using a private key for the client.</li>
  <li>I'm not calling Context::useCertificate() before using the Context object. The docs say you need to call either userCertificate() or usePrivateKey(), but I wasn't sure what to pass or if this was required for client, or only for a server. Maybe this is the problem?</li>
  </ol>