A few more fixes and SSL support

As it turns out, my new employer is interested in the nginx LDAP authentication module as well. So here we go, a few stability fixes and support for encrypted ldaps:// connections.