StephenBlackWasAlreadyTaken / xDrip

Android Application that collects dex signals, allows calibrations, and uploads
GNU General Public License v3.0
208 stars 176 forks source link

Use HttpsURLConnection instead of Apache HTTP Client for Nightscout uploading #108

Open ebarendt opened 9 years ago

ebarendt commented 9 years ago

I ran into a problem setting up my nephew's uploader to submit to the Nightscout API instead of MongoDB directly. According to this ssl test, it should work with Android 4.4.2, but "This site works only in browsers with SNI support." (news to me, but that's a different problem).

From the Android SSL docs:

Fortunately, HttpsURLConnection supports SNI since Android 2.3. Unfortunately, Apache HTTP Client does not, which is one of the many reasons we discourage its use. One workaround if you need to support Android 2.2 (and older) or Apache HTTP Client is to set up an alternative virtual host on a unique port so that it's unambiguous which server certificate to return.

I checked and sure enough, the Nightscout uploader uses the Apache library.

The other option appears to be to use a newer version of Apache's library, which probably requires fewer changes.

Any interest?

ebarendt commented 9 years ago

I see that 2.0.2 Beta3 has "Updated Mongo Library to support new Mongo DB versions", so that probably addresses why we were moving to the API. But if it's recommended to upload to Nightscout via the API, then this would still be valuable.