firebase-arduino icon indicating copy to clipboard operation
firebase-arduino copied to clipboard

Has anyone had problems with your Nodemcu and Firebase connection?

Open filactito opened this issue 6 years ago • 131 comments

Hi. Has anyone had problems with your Nodemcu and Firebase connection? everything worked correctly until today.

Is someone having this problem?

filactito avatar Aug 02 '18 21:08 filactito

Yes, I cant connect..

Daniel-Moraes avatar Aug 02 '18 22:08 Daniel-Moraes

firebase has new fingerprint => 6F D0 9A 52 C0 E9 E4 CD A0 D3 02 A4 B7 A1 92 38 2D CA 2F 26

just edit this file, FirebaseHttpClient.h

adamrabbani avatar Aug 02 '18 22:08 adamrabbani

Works correctly !! Thank you @adamrabbani :)

filactito avatar Aug 02 '18 22:08 filactito

Thank you so much @adamrabbani !!!!!!!!!!!!!!!!!!!!

Daniel-Moraes avatar Aug 02 '18 22:08 Daniel-Moraes

@adamrabbani Thank you so much

ExploreLab avatar Aug 03 '18 01:08 ExploreLab

Damm!! Thank you a lot bro

HugoLimon avatar Aug 03 '18 03:08 HugoLimon

This is my own solutions to handle the fingerprint changes Solution 1

  1. Create php file on web server that will provide firebaseio.com fingerprint via get request which the host to get fingerprint is test.firebaseio.com

  2. Modify FirebaseHttpClient_Esp8266.cpp from line no. 22

 public:
  FirebaseHttpClientEsp8266() {}

to

public:
 String fingerprint;
  FirebaseHttpClientEsp8266() {
	http_.begin("http://{YOUR WEB SERVER}.com/fingerprint.php?host=test.firebaseio.com");
	int httpCode = http_.GET();
	if (httpCode == HTTP_CODE_OK)
		fingerprint = http_.getString();
	http_.end();
  }

and from line no. 46

void begin(const std::string& url) override {
    http_.begin(url.c_str(), kFirebaseFingerprint);
  }

  void begin(const std::string& host, const std::string& path) override {
    http_.begin(host.c_str(), kFirebasePort, path.c_str(), kFirebaseFingerprint);
  }

to

 void begin(const std::string& url) override {
    http_.begin(url.c_str(), fingerprint);
  }

  void begin(const std::string& host, const std::string& path) override {
    http_.begin(host.c_str(), kFirebasePort, path.c_str(), fingerprint);
  }

This is fingerprint.php file

<?php
	
# PHP SSL Fingerprint Checker written by W. Al Maawali  
# (c) 2013 Founder of Eagle Eye Digital Solutions
# http://www.digi77.com
# http://www.om77.net
# script starts here:
# Usage: http://www.yourdomain.com/sslf.php
# Example: http://www.digi77.com/software/fingerprint/fp-public.php?hosts=www.facebook.com

//avoid timeouts
set_time_limit(0);

//For String variable use prevent sql injections
function StringInputCleaner($data)
{
	$data = trim($data); 
	$data = stripslashes($data); 
	$data=(filter_var($data, FILTER_SANITIZE_STRING));
	return $data;
}	

function getSllCertificate($hostname, $port = 443)
{
	$context = stream_context_create(array("ssl" => array("capture_peer_cert" => true)));
	$socket = @stream_socket_client("ssl://$hostname:$port", $errno, $errstr, ini_get("default_socket_timeout"), STREAM_CLIENT_CONNECT, $context);
 
	if(!$socket)
		return array("md5" => "error", "sha1" => "error");
 
	$contextdata = stream_context_get_params($socket);
	$contextparams = $contextdata['options']['ssl']['peer_certificate'];
 
	fclose($socket);
 
	openssl_x509_export($contextparams, $cert, true);
	openssl_x509_free($contextparams);
 
	$repl = array("\r", "\n", "-----BEGIN CERTIFICATE-----", "-----END CERTIFICATE-----");
	$repw = array("", "", "", "");
 
	$cert = str_replace($repl, $repw, $cert);
 
	$decoded = base64_decode($cert);
	$fingerprints = array(
		"md5" => md5($decoded),
		"sha1" => sha1($decoded),
	);
	
	
	return $fingerprints ;
}

$host=$_GET['host'];
//clean string safer coding
$host=StringInputCleaner($host);
$port=443;
$hashes = getSllCertificate($host, $port);

echo($hashes['sha1']);

?>

Solution 2

Bypass the finger print verification in WiFiClientSecure.cpp in C:\Users{YOUR NAME}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.0\libraries\ESP8266WiFi\src

from line no. 630 to

bool WiFiClientSecure::verify(const char* fp, const char* domain_name)
{
return trure;

mobizt avatar Aug 03 '18 05:08 mobizt

@adamrabbani GOD BLESS!!!!!! We have a project due on monday (3 days from this post) and randomly our firebase started failing. God bless you, God bless your family, god bless your ancestors.

turbo105 avatar Aug 03 '18 18:08 turbo105

@adamrabbani jesus christ god bless indeed. That was really scary. Whats the scoop on this?

stlcool avatar Aug 03 '18 21:08 stlcool

@adamrabbani I have changed the fingerprint, but it's still not working. Did I miss anything?

image

arkochatterjee avatar Aug 04 '18 03:08 arkochatterjee

@arkochatterjee I've the same issue...but the fingerprint for me is already correct.

JaysArtworks avatar Aug 05 '18 09:08 JaysArtworks

I have the same issue. I changed the fingerprint, but its still not working, It begins connection and starts streaming. Then Unable to get/read Data from firebase and firebase Stream is failing. Tried updating ArduinoJson as well no use.

Does Anyone know the solution ?

santoshn547 avatar Aug 06 '18 09:08 santoshn547

hi @adamrabbani hope you doing well can you plz tell that where i found firebasehttp.client.h. your answer would be highly appreciated

hammad42 avatar Aug 07 '18 14:08 hammad42

@hammad42
You can find that file inside libraries folder of Arduino. Libraries-> firebase-arduino-master -> src-> firebasehttp.client.h

santoshn547 avatar Aug 07 '18 14:08 santoshn547

thankyou @santoshn547 but finger print is already same as above which is wrote by @adamrabbani

hammad42 avatar Aug 07 '18 14:08 hammad42

@santoshn547 if you found any success plz share it with me i have submit my fyp project and i stuck on this my code was works fine then this shit happens..

hammad42 avatar Aug 07 '18 14:08 hammad42

@JaysArtwork did you find any success..

hammad42 avatar Aug 07 '18 15:08 hammad42

@hammad42 Even I haven't found any solution !

santoshn547 avatar Aug 07 '18 15:08 santoshn547

@hammad42 I did not find any solution...damn

JaysArtworks avatar Aug 07 '18 16:08 JaysArtworks

Ok @JaysArtworks@Santoshn547 do one thing download old library and go to firebase http client.h and edit finger print as above adamrabbani shows

hammad42 avatar Aug 08 '18 15:08 hammad42

@adamrabbani @ Thank you very much my friend. You save my project. I have try many weeks ago. Now it work fine. Many many thank.

kimleng-ly avatar Aug 09 '18 04:08 kimleng-ly

@adamrabbani @ how can we know that firebase change that? If later firebase change again, where can we find it?

kimleng-ly avatar Aug 09 '18 11:08 kimleng-ly

@kimleng-ly you can check fingerprint through this site https://www.grc.com/fingerprints.htm?domain=yourdatabase.firebaseio.com

For test you can use https://www.grc.com/fingerprints.htm?domain=test.firebaseio.com.

If you read my post above, solution 1 (if you have PHP skill) is for automatically update fingerprint when your device start to connect to firebase.

In case of you want to bypass fingerprint checking please see solution 2 of my previous post.

mobizt avatar Aug 09 '18 11:08 mobizt

@mobizt Many thank my friend. You save a lot time for me to search it. Thank.

kimleng-ly avatar Aug 09 '18 14:08 kimleng-ly

Good day, replaced the code, the application runs 2-3 minutes, after writing: DB failed. What is the solution ?

part_progr

db failed


6F D0 9A 52 C0 E9 E4 CD A0 D3 02 A4 B7 A1 92 38 2D CA 2F 26

file FirebaseHttpClient.h edited

AlexPivo avatar Aug 10 '18 16:08 AlexPivo

@AlexPivo If you want to by pass fingerprint verification, write "return true;" first inside the function and no need to edit finger print in FirebaseHttpClient.h.

bool WiFiClientSecure::verify(const char* fp, const char* domain_name)
{
    return true; //<--- here

    if (!_ssl) {
        return false;
    }

mobizt avatar Aug 10 '18 19:08 mobizt

Thanks, it's working. Works 2-3 minutes, then error. Crash controller (freezes controller ) and start working again in 2-3 minutes.

p.s. Error not writes: DB failed

AlexPivo avatar Aug 11 '18 06:08 AlexPivo

the library should be inside the Document/Arduino/libraries, not the program files, it should be the same file of your project saved in. This works for me.

pcliu624 avatar Aug 14 '18 12:08 pcliu624

Can you confirm that was fixed with https://github.com/firebase/firebase-arduino/pull/368 ?

proppy avatar Aug 16 '18 11:08 proppy

@mobizt Good day, it's working. The problem was wi-Fi.

option 2: Bypass the finger print verification in WiFiClientSecure.cpp in C:\Users{YOUR NAME}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.0\libraries\ESP8266WiFi\src

bool WiFiClientSecure::verify(const char* fp, const char* domain_name) { return true; //<--- here

if (!_ssl) {
    return false;
}

Thanks!

AlexPivo avatar Aug 19 '18 20:08 AlexPivo