title: ktor client https request with self-signed certificate
body: <p>I have a Ktor server application (rest api) running with a self signed certificate. </p>
  
  <p>It works fine from a browser (after a warning and a confirmation) port 80 is redirected to 8443. </p>
  
  <p>But if I try this from a Ktor Apache Client:</p>
  
  <pre><code>fun main(args: Array&lt;String&gt;) = runBlocking {
  
      val client = HttpClient(Apache) {
          install(JsonFeature) {
              serializer = GsonSerializer()
          }
      }
  
      val job = GlobalScope.launch {
          try {
              //self-signed certificate
              val resultWillFail = client.get&lt;String&gt;("https://10.0.0.11:8443/get-my-services")
              println("${resultWillFail}")
              val resultOk = client.get&lt;String&gt;("https://en.wikipedia.org/wiki/Main_Page") //ok
              println("${resultOk}")
          } catch (e: Exception) {
              println("Error: ${e.message}")
          }
      }
  
      job.join()
  }
  </code></pre>
  
  <p>My request to <a href="https://10.0.0.11:8443/get-my-services" rel="nofollow noreferrer">https://10.0.0.11:8443/get-my-services</a> will fail:</p>
  
  <blockquote>
    <p><strong>Error: General SSLEngine problem</strong></p>
  </blockquote>
  
  <p>I also tried the same using curl:</p>
  
  <blockquote>
    <p><strong>curl: (77) schannel: next InitializeSecurityContext failed: SEC_E_UNTRUSTED_ROOT (0x80090325) - The certificate chain was issued
    by an authority that is not trusted.</strong></p>
  </blockquote>
  
  <p>So my question would be: How to use a self signed certificate with ktor client (Apache) ?</p>
  
  <p>Thanks,
  J</p>