title: ESP8266 and https connection to firebase
body: <p>i am trying to send a push notification to android device from esp8266. i have wemos d1 mini board. my code is follows</p>
  
  <pre><code>#include &lt;ESP8266WiFi.h&gt;
  #include &lt;WiFiClientSecure.h&gt;
  
  #ifndef STASSID
  //#define STASSID "XXXXXX"
  //#define STAPSK  "XXXXXX"
  #endif
  
  const char* ssid = STASSID;
  const char* password = STAPSK;
  const char* host = "fcm.googleapis.com";
  const int httpsPort = 80;
  // Use web browser to view and copy // SHA1 fingerprint of the certificate
  const char fingerprint[] PROGMEM = "0fd9151c4d4a317b647e87713bd7226b8b4fcbda";
  WiFiClient client;
  
  void setup() 
  {
    Serial.begin(115200);
    Serial.println();
    Serial.print("connecting to ");
    Serial.println(ssid);
    WiFi.mode(WIFI_STA);
    WiFi.begin(ssid, password);
    while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
  
  //Use WiFiClientSecure class to create TLS connection
  WiFiClientSecure client;
  Serial.print("connecting to ");
  Serial.println(host);
  Serial.printf("Using fingerprint '%s'\n", fingerprint);
  client.setFingerprint(fingerprint);
  if (!client.connect(host, httpsPort)) {
  Serial.println("connection failed");
  return;
  }
  sendDataToFirebase();
  }
  
  void loop() {
  }
  
  void sendDataToFirebase() {
  String data = "{" ;
  data = data + "\"to\": \"XXXXXXXXXXXXXXX\"," ;
  data = data + "\"notification\": {";
  data = data + "\"body\": \"Motion detected\",";
  data = data + "\"title\" : \"Alarm\" ";
  data = data + "} }";
  client.println("POST /fcm/send HTTP/1.1");
  client.println("Authorization: key=XXXXXXXXXXXXXXXXXX,");
  client.println("Content-Type: application/json");
  client.println("Host: fcm.googleapis.com");
  client.print("Content-Length: ");
  client.println(data.length());
  client.print("\n");
  client.print(data);
  Serial.println("Data sent...Reading response..");
  //while (client.available()) {
  //char c = client.read();
  //Serial.print(c);
      String line = client.readStringUntil('\n');
      Serial.println(line);
  //}
  Serial.println("Finished!");
  client.flush();
  client.stop();
  }
  </code></pre>
  
  <p>now my problem is, the connection to fcm server is failing. my best guess is, its for the fingerprint. 
  I copied the thumbprint from <a href="https://firebase.google.com/" rel="nofollow noreferrer">https://firebase.google.com/</a>. but the connection is still failing. Could you please help?</p>