Thank you for the pull request, that part of code isn't reached in my deployment and obviously haven't tested it properly (I use Linux with command-line openssl). I've merged the request into my tree.
Originally Posted by akleiw
Well, it's not perfect yet, because I can't download anything from Amazon's cloud (it's stuck as pending) but I've successfully loaded some books from my calibre library. I'll report back when I take a better look at this issue.
Hm, Amazon books should be downloaded directly by the device -- KSP should be replying with a 302 redirect pointing to the Amazon URL if the device tries to download a book not in Calibre's library. It works fine for me both on the Kindle 4 and in Kindle for PC.
If the download gets stuck somehow (happened to me a lot during development, especially when KSP was throwing some exception), you can try restarting the device and re-downloading the book. If it gets stuck again, then it is indeeed a problem. Is it stuck at 0% or 100%?