improvements for the ssl-support branch

The commits in this pull request are based on the two commits by @artichikin in the *ssl-support* branch.  We've been using these commits in our app for a bit, and the SSL/TLS/HTTPS support seems to be working fine and we'd love to see it integrated into master.   We have only been testing on Android, but various versions of Android.

The two commits by @artichikin have been rebased on top of today's master, they didn't need any changes.