gmag11 / WifiLocation

Google GeoLocation API wrapper for Arduino MKR1000, ESP8266 and ESP32
MIT License
212 stars 48 forks source link

HTTPS error - Result: API connection error #18

Closed richie241 closed 3 years ago

richie241 commented 3 years ago

Until 2 months ago I was able to use the query successfully in my application. Now I get an HTTPS error. An update to version 1.2.8 did not bring success either. In the sample code I get the same error.

ESP8266 (d1 mini) + also ESP32 IDE: 1.8.15 ESP Core: 2.7.4

Google API Key is unchanged, the query via Postman is OK. postman

define DEBUG_WIFI_LOCATION 1 is set, enclosed the log output. (thats all..)

22:45:32.276 -> Status = 6 22:45:32.771 -> Connected 22:45:32.771 -> Waiting for NTP time sync: 22:45:32.771 -> Current time: Tue Aug 10 20:45:31 2021 22:45:34.211 -> HTTPS error 22:45:34.211 -> Location request data 22:45:35.787 -> 5 WiFi networks found 22:45:35.787 -> WiFi list : 22:45:35.787 -> [ 22:45:35.787 -> {"macAddress":"xxx","signalStrength":-59,"channel":1}, 22:45:35.787 -> {"macAddress":"xxx","signalStrength":-57,"channel":1}, 22:45:35.787 -> {"macAddress":"xxx","signalStrength":-69,"channel":1}, 22:45:35.787 -> {"macAddress":"xxx","signalStrength":-76,"channel":1}, 22:45:35.787 -> {"macAddress":"xxx","signalStrength":-86,"channel":1}] 22:45:35.787 -> [ 22:45:35.787 -> {"macAddress":"xxx","signalStrength":-59,"channel":1}, 22:45:35.832 -> {"macAddress":"xxx","signalStrength":-57,"channel":1}, 22:45:35.832 -> {"macAddress":"xxx","signalStrength":-69,"channel":1}, 22:45:35.832 -> {"macAddress":"xxx","signalStrength":-76,"channel":1}, 22:45:35.832 -> {"macAddress":"xxx","signalStrength":-86,"channel":1}] 22:45:35.832 -> Location: 0.0000000,0.0000000 22:45:35.832 -> Accuracy: 40000 22:45:35.832 -> Result: API connection error

Does anyone have an idea where the error is? I suspect something is wrong with the certificate / SSL connection.

SebasCarranza commented 3 years ago

I have the same issue. I'm already looking for a solution.

gmag11 commented 3 years ago

Yes I guess Google has renewed their certificates. I'll update it here, You can change it on your code if you cannot wait.

gmag11 commented 3 years ago

Valid certificate should be this:

-----BEGIN CERTIFICATE-----
MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkG
A1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jv
b3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAw
MDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9i
YWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJHbG9iYWxT
aWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDaDuaZ
jc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavp
xy0Sy6scTHAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp
1Wrjsok6Vjk4bwY8iGlbKk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdG
snUOhugZitVtbNV4FpWi6cgKOOvyJBNPc1STE4U6G7weNLWLBYy5d4ux2x8gkasJ
U26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrXgzT/LCrBbBlDSgeF59N8
9iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8E
BTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0B
AQUFAAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOz
yj1hTdNGCbM+w6DjY1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE
38NflNUVyRRBnMRddWQVDf9VMOyGj/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymP
AbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhHhm4qxFYxldBniYUr+WymXUad
DKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveCX4XSQRjbgbME
HMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==
-----END CERTIFICATE-----

May you test it?

richie241 commented 3 years ago

back in business 👍 will the certificate amendment continue to work beyond 2021?

11:13:42.415 -> Status = 6 11:13:42.910 -> Connected 11:13:42.910 -> Waiting for NTP time sync: 11:13:42.910 -> Current time: Wed Aug 11 09:13:42 2021 11:13:45.340 -> Connected to API endpoint 11:13:46.916 -> 7 WiFi networks found 11:13:46.916 -> WiFi list : 11:13:46.961 -> [ 11:13:46.961 -> {"macAddress":"xxx","signalStrength":-57,"channel":1}, 11:13:46.961 -> {"macAddress":"xxx","signalStrength":-72,"channel":1}, 11:13:46.961 -> {"macAddress":"xxx","signalStrength":-54,"channel":1}, 11:13:46.961 -> {"macAddress":"xxx","signalStrength":-76,"channel":1}, 11:13:46.961 -> {"macAddress":"xxx","signalStrength":-87,"channel":1}, 11:13:46.961 -> {"macAddress":"xxx","signalStrength":-90,"channel":1}, 11:13:46.961 -> {"macAddress":"xxx","signalStrength":-88,"channel":1}] 11:13:46.961 -> requesting URL: /geolocation/v1/geolocate?key=AIzaSyB-SbdSlE2881-lF_Y7i1iNfYi7EA7UPk8 11:13:47.006 -> request: 11:13:47.006 -> POST /geolocation/v1/geolocate?key=AIzaSyB-SbdSlE2881-lF_Y7i1iNfYi7EA7UPk8 HTTP/1.1 11:13:47.006 -> Host: www.googleapis.com 11:13:47.006 -> User-Agent: ESP8266 11:13:47.006 -> Content-Type:application/json 11:13:47.006 -> Content-Length:524 11:13:47.006 -> Connection: keep-alive 11:13:47.006 -> 11:13:47.006 -> {"considerIP":false,"wifiAccessPoints":[ 11:13:47.006 -> {"macAddress":"xxx","signalStrength":-57,"channel":1}, 11:13:47.006 -> {"macAddress":"xxx","signalStrength":-72,"channel":1}, 11:13:47.006 -> {"macAddress":"xxx","signalStrength":-54,"channel":1}, 11:13:47.051 -> {"macAddress":"xxx","signalStrength":-76,"channel":1}, 11:13:47.051 -> {"macAddress":"xxx","signalStrength":-87,"channel":1}, 11:13:47.051 -> {"macAddress":"xxx","signalStrength":-90,"channel":1}, 11:13:47.051 -> {"macAddress":"xxx","signalStrength":-88,"channel":1}]} 11:13:47.096 -> request sent 11:13:47.096 -> Free heap: 20704 11:13:47.096 -> . 11:13:52.137 -> Got response: 11:13:52.137 -> HTTP/1.1 200 OK 11:13:52.137 -> Content-Type: application/json; charset=UTF-8 11:13:52.137 -> Vary: X-Origin 11:13:52.137 -> Vary: Referer 11:13:52.137 -> Date: Wed, 11 Aug 2021 09:13:47 GMT 11:13:52.137 -> Server: scaffolding on HTTPServer2 11:13:52.137 -> Cache-Control: private 11:13:52.137 -> X-XSS-Protection: 0 11:13:52.137 -> X-Frame-Options: SAMEORIGIN 11:13:52.137 -> X-Content-Type-Options: nosniff 11:13:52.137 -> Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43" 11:13:52.182 -> Accept-Ranges: none 11:13:52.182 -> Vary: Origin,Accept-Encoding 11:13:52.182 -> Transfer-Encoding: chunked 11:13:52.182 -> 11:13:52.182 -> 59 11:13:52.182 -> { 11:13:52.182 -> "location": { 11:13:52.182 -> "lat": 51.0819256, 11:13:52.182 -> "lng": 6.241569 11:13:52.182 -> }, 11:13:52.182 -> "accuracy": 13.948 11:13:52.182 -> } 11:13:52.182 -> 11:13:52.182 -> 0 11:13:52.182 -> 11:13:52.182 -> 11:13:52.182 -> 11:13:52.182 -> Lat: 51.0819244 11:13:52.182 -> Lon: 6.2415690 11:13:52.182 -> Accuracy: 13 11:13:52.182 -> 11:13:52.182 -> Location request data 11:13:53.757 -> 7 WiFi networks found 11:13:53.757 -> WiFi list : 11:13:53.757 -> [ 11:13:53.757 -> {"macAddress":"xxx","signalStrength":-46,"channel":1}, 11:13:53.757 -> {"macAddress":"xxx","signalStrength":-75,"channel":1}, 11:13:53.802 -> {"macAddress":"xxx","signalStrength":-86,"channel":1}, 11:13:53.802 -> {"macAddress":"xxx","signalStrength":-73,"channel":1}, 11:13:53.802 -> {"macAddress":"xxx","signalStrength":-70,"channel":1}, 11:13:53.802 -> {"macAddress":"xxx","signalStrength":-86,"channel":1}, 11:13:53.802 -> {"macAddress":"xxx","signalStrength":-91,"channel":1}] 11:13:53.802 -> [ 11:13:53.802 -> {"macAddress":"xxx","signalStrength":-46,"channel":1}, 11:13:53.802 -> {"macAddress":"xxx","signalStrength":-75,"channel":1}, 11:13:53.847 -> {"macAddress":"xxx","signalStrength":-86,"channel":1}, 11:13:53.847 -> {"macAddress":"xxx","signalStrength":-73,"channel":1}, 11:13:53.847 -> {"macAddress":"xxx","signalStrength":-70,"channel":1}, 11:13:53.847 -> {"macAddress":"xxx","signalStrength":-86,"channel":1}, 11:13:53.847 -> {"macAddress":"xxx","signalStrength":-91,"channel":1}] 11:13:53.847 -> Location: 51.0819244,6.2415690 11:13:53.847 -> Accuracy: 13 11:13:53.847 -> Result: OK

gmag11 commented 3 years ago

Thanks for testing it.

This certificate is valid until 2028

image

Code will work until then unless Google changes its root Certification Authority. This will probably happen a few months before 2028.

Last certificate was valid until next December and has failed this month.

gmag11 commented 3 years ago

Solved in version 1.2.9 https://github.com/gmag11/WifiLocation/commit/41ef6bedd4d3fc781447d1e3e466925fe17332f7