title: ssl peer certificate or ssh remote key was not ok - C
body: <p>I have the following code to connect to a site:</p>
  
  <pre><code>int main()
  {
      CURL *curl;
      CURLcode res;
  
      curl = curl_easy_init();
  
      if(curl)
      {
          curl_easy_setopt(curl, CURLOPT_URL, "https://192.168.200.115:8080/appliances");
          curl_easy_setopt(curl, CURLOPT_USERNAME, "myusername");
          curl_easy_setopt(curl, CURLOPT_PASSWORD, "mypassword");
          curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); 
  
          // Perform the request, res will get the return code
          res = curl_easy_perform(curl);
  
          // Check for errors
          if(res != CURLE_OK)
          {
              fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
          }
  
          //always cleanup
          curl_easy_cleanup(curl);
      }
  
      return 0;
  }
  </code></pre>
  
  <p>WHen ran I got the error: <strong>peer certificate cannot be authenticated with given ca certificates</strong></p>
  
  <p>After googling I found that I had to add the line:</p>
  
  <pre><code>curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
  </code></pre>
  
  <p>BUt now I get the error: <strong>ssl peer certificate or ssh remote key was not ok</strong></p>
  
  <p>I have tried adding in:</p>
  
  <pre><code>curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2);
  </code></pre>
  
  <p>But still the same error.</p>
  
  <p>How can I solve this??</p>
  
  <p><strong>EDIT</strong>
  I added verbose logging:</p>
  
  <pre><code>curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
  </code></pre>
  
  <p>And now I see the following in the output:
  <strong>ssl certificate subject name 'name or server' does not match target host</strong></p>