title: Connection failed with SSL with ESP8266
body: <p>I want to create an SSL connection with my site to send data and every time I connect it fails!</p>
  
  <p>I am using <code>WiFiClientSecure.h</code> library but I don't know where is the problem is it from code or library or from my site?</p>
  
  <p>here is my code:</p>
  
  <pre><code> #include &lt;ArduinoJson.h&gt;
   #include &lt;ESP8266WiFi.h&gt;
   #include &lt;DHT.h&gt;
   #include &lt;WiFiClientSecure.h&gt;
  
  
    #define DHTPIN D6
   #define DHTTYPE DHT11 
  
  
   const char* ssid     = "SSID";
   const char* password = pass";
  
  
   char host[] = "mysite.com";
   DHT dht(DHTPIN, DHTTYPE);
  
   void setup() {
  
     Serial.begin(115200);
     delay(100);
     dht.begin();
     Serial.println();
     Serial.println();
     Serial.print("Connecting to ");
     Serial.println(ssid);
  
     WiFi.begin(ssid, password); 
     while (WiFi.status() != WL_CONNECTED) {
       delay(500);
       Serial.print(".");
     }
  
     Serial.println("");
     Serial.println("WiFi connected");  
    Serial.println("IP address: ");
     Serial.println(WiFi.localIP());
     Serial.print("Netmask: ");
     Serial.println(WiFi.subnetMask());
     Serial.print("Gateway: ");
     Serial.println(WiFi.gatewayIP());
  
  
   }
  
   void loop (){
     float h = dht.readHumidity();
     // Read temperature as Celsius (the default)
     float t = dht.readTemperature();
     if (isnan(h) || isnan(t)) {
       Serial.println("Failed to read from DHT sensor!");
       return;
     }
  
     Serial.print("connecting to ");
     Serial.println(host);
  
     int httpPort = 443;
     //Add a SSL client
      WiFiClientSecure client;
     if (!client.connect(host, httpPort)) {
        Serial.println("connection failed");
       return;
     }
  
     String url = "/insert.php?temp=" + String(t) + " ;
     Serial.print("Requesting URL: ");
     Serial.println(url);
  
     client.print(String("GET ") + url + " HTTP/1.1\r\n" +
             "Host: " + host + "\r\n" + 
             "Connection: close\r\n\r\n");
     delay(500);
  
     while(client.available()){
        String line = client.readStringUntil('\r');
       Serial.print(line);
     }
  
     Serial.println();
   Serial.println("closing connection");
  
   }
  </code></pre>
  
  <p>Is the issue in the code or from my site?</p>