Archive for the ‘Palm OS’ Category.

Using Http library for the Palm OS

I was asked some time ago to look into the possibility of SSL communications with Palm OS phone based devices. The NetLib was already being used, but it did not have native support to communicate over SSL.

After a bit of searching, I decided to try to use the Http library that is provided on certain models of Palm OS devices (OS 5.x devices such as Centro, Treo, LifeDrive, and some Tungstens). The model was not an issue, as the customer was already using Treos, and the library seemed to have everything I needed to make a go of it.

The documentation seemed pretty thin on the Http library, about the only things I could find was some mention of the library in the PDF document Palm Developer Guide, Palm OS Platform Software and Hardware (Revision J, April 30, 2008), and an example program on using the library.

I downloaded the sample code provided by Palm, and with some small tests it seemed to work like gangbusters in both http and https mode. However, the first time I threw a real-world test at it, the code started erroring pretty quickly.

After much consternation, I finally tracked the problem down to the READ_CHUNK constant defined in the Peer.c file. By changing it to 32000 instead of 65535, it seemed to work much better.

The reason for this would appear to be that the READ_CHUNK constant is compared with and assigned to 32-bit integers, but this value is cast to a 16-bit integer when used in the NetLib calls, which was of course causing all sorts of wackiness.

Also, I quickly discovered that, since we were using a test SSL certificate, that the communications were failing early on in the initialization process. As a result, I had to set up a callback function that was used by HS_HTTPLibSetSSLServerCertConfirmProc. This callback in turn calls HS_HTTPLibServerCertConfirm and then just returns zero, which allows the invalid SSL certificate to be used.